Skip to content

Instantly share code, notes, and snippets.

@Epskampie
Created August 21, 2019 14:57
Show Gist options
  • Save Epskampie/427c512722b8e6c4cbf5f1340b87986b to your computer and use it in GitHub Desktop.
Save Epskampie/427c512722b8e6c4cbf5f1340b87986b to your computer and use it in GitHub Desktop.
#!/bin/php
<?php
/**
* Helper script to use php-cs-fixer with stdin / stdout
**/
$temp_file = tempnam(sys_get_temp_dir(), 'fix_');
$input = file_get_contents("php://stdin");
file_put_contents($temp_file, $input);
$output = [];
$returnCode;
exec('bin/php-cs-fixer fix --quiet ' . $temp_file, $output, $returnCode);
if ($returnCode) {
// Error occurred
exit($returnCode);
}
echo file_get_contents($temp_file);
unlink($temp_file);
@tsialas
Copy link

tsialas commented May 22, 2023

@Epskampie you absolute hero.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment