/** * Tidy up source code as a file * - executes the phptidy.php script via php CLI functionality * * @param string $path to file * @return void; * @throws OutOfBoundsException */ public static function file($path) { if (is_array($path)) { foreach ($path as $_path) { PhpTidy::file($_path); } return; } if (!is_file($path)) { throw new OutOfBoundsException('PhpTidy::file() unable to find file (should be a full path) ' . $path); } $phpexe = exec('which php'); if (empty($phpexe)) { $phpexe = 'php'; } $cmd = sprintf('%s %s replace %s', $phpexe, escapeshellarg(PhpTidy::script()), escapeshellarg($path)); return exec($cmd); }
/** * */ public function testPhpTidyScript() { $expect = dirname(dirname(dirname(__DIR__))) . DS . 'Vendor' . DS . 'phptidy.php'; $this->assertEquals($expect, PhpTidy::script()); }