Commit: 5eaaf2b1a172554baf261131d07c7fbe837f20a9
Author: David Persson | Date: 2009-12-03 21:34:55 +0100
diff --git a/extensions/command/BranchUpgrade.php b/extensions/command/BranchUpgrade.php
new file mode 100644
index 0000000..309864e
--- /dev/null
+++ b/extensions/command/BranchUpgrade.php
@@ -0,0 +1,111 @@
+<?php
+/**
+ * Lithium Hooks: A collection of git hooks & scripts that can be used for development in the
+ * Lithium core and with Lithium applications.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace app\extensions\command;
+
+/**
+ * When pushing a new version, cleans up all local version-dependent feature branches which are
+ * based on the existing version, and re-clones them based on the new version. For example:
+ *
+ * {{{li3 branch_upgrade --project=/path/to 1.5 1.6}}}
+ *
+ * Given the local branch `data`, cloned from `origin/1.5-data`, the `data` branch will be dropped
+ * and re-checked-out from `origin/1.6-data`.
+ *
+ * For more information on feature/version branching schemes, see
+ * (http://rad-dev.org/wiki/guides/branch-strategy)
+ */
+class BranchUpgrade extends \lithium\console\Command {
+
+ public $project;
+
+ public function run() {
+ if (count($this->request->params['passed']) < 2) {
+ $this->_stop();
+ }
+ if (!$this->project) {
+ $this->project = $this->request->env['working'];
+ }
+ list($old, $new) = $this->request->params['passed'];
+ $locals = $remotes = $trackings = array();
+ $current = null;
+
+ chdir($this->project);
+ `git pull origin`;
+ `git remote prune origin`;
+
+ foreach (array_map('trim', explode("\n", trim(`git branch -a`))) as $branch) {
+ if (strpos($branch, 'remotes/') === 0) {
+ $remotes[] = substr($branch, 8);
+ continue;
+ }
+ $locals[] = $branch;
+ }
+
+ foreach ($locals as $i => $branch) {
+ if (strpos($branch, '*') === 0) {
+ $locals[$i] = $branch = substr($branch, 2);
+ $current = $branch;
+ }
+ $cmd = "git config --get branch.{$branch}";
+
+ $remote = trim(str_replace('refs/heads/', '', `{$cmd}.merge`));
+ $trackings[$branch] = $remote;
+ }
+
+ if ($current != 'master') {
+ `git checkout master`;
+ }
+
+ $merged = array_map('trim', explode(
+ "\n", str_replace('*', '', trim(`git branch --merged`))
+ ));
+
+ foreach ($trackings + array('stable' => $old) as $local => $remote) {
+ if (strpos($remote, "{$old}-") !== 0) {
+ continue;
+ }
+ if (!in_array($local, $merged) && $local != 'stable') {
+ $this->out("Branch {$local} has not been merged into HEAD - aborting.");
+ $this->_stop();
+ }
+ $this->out("Dropping branch {$local} (tracks origin/{$remote})");
+
+ if ($result = `git branch -d {$local}` && !preg_match('/^Deleted branch/', $result)) {
+ $this->out("Problem encountered when dropping local branch {$local}: {$result}");
+ $this->_stop();
+ }
+ }
+
+ foreach ($remotes as $branch) {
+ if (!strpos($branch = str_replace('origin/', '', $branch), $new) === 0) {
+ continue;
+ }
+ if ($branch == $new) {
+ $this->out("Checking out branch stable, tracking origin/{$new}");
+ `git checkout -b stable --track origin/{$new}`;
+ continue;
+ }
+ if (!strpos($branch, '-')) {
+ continue;
+ }
+ list($version, $branch) = explode('-', $branch, 2);
+
+ if ($version != $new) {
+ continue;
+ }
+
+ $this->out("Checking out branch {$branch}, tracking origin/{$new}-{$branch}");
+ `git checkout -b {$branch} --track origin/{$new}-{$branch}`;
+ }
+ `git checkout stable`;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/extensions/command/Syntax.php b/extensions/command/Syntax.php
new file mode 100644
index 0000000..d29d93f
--- /dev/null
+++ b/extensions/command/Syntax.php
@@ -0,0 +1,179 @@
+<?php
+/**
+ * Lithium Hooks: A collection of git hooks & scripts that can be used for development in the
+ * Lithium core and with Lithium applications.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace app\extensions\command;
+
+use lithium\core\Libraries;
+use lithium\util\Inflector;
+use lithium\util\String;
+use \RecursiveIteratorIterator;
+use \RecursiveDirectoryIterator;
+
+class Syntax extends \lithium\console\Command {
+
+ public $checks;
+
+ public $project;
+
+ public $exclude = '\.';
+
+ public $metrics;
+
+ public $blame;
+
+ protected $_vcs;
+
+ public function run($file = null) {
+ if (!$this->checks) {
+ $this->help();
+ return 1;
+ }
+ $this->checks = explode(',' , $this->checks);
+
+ if (!$this->project) {
+ $this->project = $this->request->env['working'];
+ }
+ $this->project = realpath($this->project);
+
+ if (is_dir($this->project . '/.git')) {
+ $this->_vcs = 'git';
+ }
+
+ if ($file[0] !== '/') {
+ $file = $this->project . '/' . $file;
+ }
+ $failures = is_file($file) ? $this->_checkFile($file) : $this->_checkDirectory($file);
+
+ if ($this->metrics) {
+ $this->_metrics($failures);
+ }
+ return $failures ? 1 : 0;
+ }
+
+ protected function _checkFile($file) {
+ $message = 'Checking `' . str_replace($this->project . '/', null, $file) .'`. ';
+ $this->out($message, false);
+ $failures = array();
+
+ foreach ($this->checks as $check) {
+ $class = Libraries::locate('command.syntax', Inflector::camelize($check));
+ $check = new $class(array('request' => $this->request));
+
+ if (!$check->accepts($file)) {
+ $this->out("Skipped. ", false);
+ } elseif ($failures = $check->process($file)) {
+ $this->out("Failed. ", false);
+ } else {
+ $this->out("Passed. ", false);
+ }
+ }
+ $this->nl();
+
+ if ($failures) {
+ foreach ($failures as &$failure) {
+ $failure['author'] = $this->_blame($failure);
+ $this->error(sprintf(
+ $this->blame ? '%1$4u| %2$3u| %3$20s| %4$s' : '%1$4u| %2$3u| %4$s',
+ $failure['line'] ?: '??',
+ $failure['column'] ?: '??',
+ $failure['author'] ?: '??',
+ $failure['message'] ?: '??'
+ ));
+ }
+ $this->nl();
+ return $failures;
+ }
+ }
+
+ protected function _checkDirectory($directory) {
+ $base = new RecursiveDirectoryIterator($directory);
+ $iterator = new RecursiveIteratorIterator($base);
+ $failures = array();
+
+ foreach ($iterator as $item) {
+ $basename = $item->getBasename();
+ $file = $item->getPathname();
+
+ if (preg_match('/\/' . $this->exclude . '/', $file) || $basename == 'empty') {
+ continue;
+ }
+ if ($result = $this->_checkFile($file)) {
+ $failures = array_merge($failures, $result);
+ }
+ }
+ return $failures;
+ }
+
+ public function checks() {
+ $this->header('Available Checks:');
+ $classes = array_unique(Libraries::locate('command.syntax', null, array(
+ 'recursive' => false
+ )));
+ foreach ($classes as $command) {
+ $command = explode('\\', $command);
+ $this->out(' - ' . Inflector::underscore(array_pop($command)));
+ }
+ }
+
+ public function help() {
+ $message = 'Usage: li3 syntax [--project=PROJECT] [--exclude=REGEX] ';
+ $message .= '[--metrics] [--blame] ';
+ $message .= '--checks=CHECK[,CHECK] [FILE]';
+ $this->out($message);
+ }
+
+ protected function _metrics($failures) {
+ $this->header('Failures by author and message');
+ $this->nl();
+ $byAuthor = array();
+
+ foreach ($failures as $failure) {
+ $byAuthor[$failure['author']][$failure['message']][] = $failure;
+ }
+ ksort($byAuthor);
+
+ foreach ($byAuthor as $author => $failures) {
+ if (!$author) {
+ continue;
+ }
+ $this->out($author);
+ ksort($failures);
+
+ foreach ($failures as $message => $messageFailures) {
+ $this->out(' - `' . $message . '` ('. count($messageFailures) .')');
+ }
+ $this->nl();
+ }
+ }
+
+ protected function _blame($failure) {
+ if (!$this->_vcs == 'git') {
+ return null;
+ }
+ $backup = getcwd();
+ chdir($this->project);
+ $lines = count(file($failure['file']));
+
+ $command = 'git blame -L{:start},{:end} --porcelain {:file}';
+ $replace = array(
+ 'start' => $failure['line'],
+ 'end' => $lines == $failure['line'] ? $failure['line'] : $failure['line'] + 1,
+ 'file' => $failure['file']
+ );
+ exec(String::insert($command, $replace), $output, $return);
+ chdir($backup);
+
+ if ($return == 0) {
+ list(, $author) = explode(' ', $output[1], 2);
+ return $author;
+ }
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/extensions/command/syntax/Base.php b/extensions/command/syntax/Base.php
new file mode 100644
index 0000000..c3ede58
--- /dev/null
+++ b/extensions/command/syntax/Base.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Lithium Hooks: A collection of git hooks & scripts that can be used for development in the
+ * Lithium core and with Lithium applications.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace app\extensions\command\syntax;
+
+/**
+ * This is the base class all verification command need to extend.
+ */
+abstract class Base extends \lithium\console\Command {
+
+ /**
+ * Checks if given file can be checked.
+ *
+ * @param string $file Absolute path to file.
+ * @return boolean
+ */
+ abstract public function accepts($file);
+
+ /**
+ * Process a file by checking it's contents.
+ *
+ * @param string $file Absolute path to file.
+ * @return array|boolean|void `false` if file cannot be processed or - if applicable -
+ * an array of violation messages.
+ */
+ abstract public function process($file);
+}
+
+?>
\ No newline at end of file
diff --git a/extensions/command/syntax/Jsl.php b/extensions/command/syntax/Jsl.php
new file mode 100644
index 0000000..153b424
--- /dev/null
+++ b/extensions/command/syntax/Jsl.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Lithium Hooks: A collection of git hooks & scripts that can be used for development in the
+ * Lithium core and with Lithium applications.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace app\extensions\command\syntax;
+
+use lithium\util\String;
+
+class Jsl extends \app\extensions\command\syntax\Base {
+
+ public function accepts($file) {
+ return file_exists($file) && preg_match('/\.js$/', $file);
+ }
+
+ public function process($file) {
+ $command = '{:jsl} -nologo -nosummary -nofilelisting -nocontext -process {:file}';
+ $replace = array(
+ 'jsl' => 'jsl',
+ 'file' => $file
+ );
+ exec(String::insert($command, $replace), $output, $return);
+
+ if ($return != 3) {
+ return null;
+ }
+ $format = function($line) use ($file) {
+ $regex = '/\((?P<line>\d+)\)\:\s(?P<message>.*)/';
+ preg_match($regex, $line, $matches);
+ return array(
+ 'file' => $file,
+ 'line' => isset($matches['line']) ? $matches['line'] : null,
+ 'column' => null,
+ 'message' => isset($matches['message']) ? $matches['message'] : null
+ );
+ };
+ return array_map($format, $output);
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/extensions/command/syntax/Phpca.php b/extensions/command/syntax/Phpca.php
new file mode 100644
index 0000000..bdfe28a
--- /dev/null
+++ b/extensions/command/syntax/Phpca.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Lithium Hooks: A collection of git hooks & scripts that can be used for development in the
+ * Lithium core and with Lithium applications.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace app\extensions\command\syntax;
+
+use lithium\util\String;
+
+class Phpca extends \app\extensions\command\syntax\Base {
+
+ public function accepts($file) {
+ return file_exists($file) && preg_match('/\.php$/', $file);
+ }
+
+ public function process($file) {
+ $plugin = dirname(dirname(dirname(__DIR__)));
+ $command = '{:php} {:phpca} -p {:php} --standard {:standard} {:file}';
+ $replace = array(
+ 'php' => trim(shell_exec('which php')),
+ 'phpca' => $plugin . '/libraries/phpca/src/phpca.php',
+ 'standard' => $plugin . '/config/phpca_lithium_standard.ini',
+ 'file' => $file
+ );
+ exec(String::insert($command, $replace), $output, $return);
+
+ if ($return == 0) {
+ return null;
+ }
+ $format = function($line) use ($file) {
+ $regex = '/(?P<line>\d+)\|.*(?P<column>\d+)\|\s+(?P<message>.*)/';
+ preg_match($regex, $line, $matches);
+
+ return array(
+ 'file' => $file,
+ 'line' => isset($matches['line']) ? $matches['line'] : null,
+ 'column' => isset($matches['column']) ? $matches['column'] : null,
+ 'message' => isset($matches['message']) ? $matches['message'] : null
+ );
+ };
+ return array_map($format, array_filter(array_slice($output, 9, -3)));
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/extensions/command/syntax/Phpl.php b/extensions/command/syntax/Phpl.php
new file mode 100644
index 0000000..eebdad4
--- /dev/null
+++ b/extensions/command/syntax/Phpl.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Lithium Hooks: A collection of git hooks & scripts that can be used for development in the
+ * Lithium core and with Lithium applications.
+ *
+ * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace app\extensions\command\syntax;
+
+use lithium\util\String;
+
+class Phpl extends \app\extensions\command\syntax\Base {
+
+ public function accepts($file) {
+ return file_exists($file) && preg_match('/\.php$/', $file);
+ }
+
+ public function process($file) {
+ $command = '{:php} -l {:file} 2> /dev/null';
+ $replace = array(
+ 'php' => 'php',
+ 'file' => $file
+ );
+ exec(String::insert($command, $replace), $output, $return);
+
+ if ($return == 0) {
+ return null;
+ }
+ $filter = function($failure) {
+ return !empty($failure) && $failure[0] == 'P';
+ };
+ $format = function($line) use ($file) {
+ $regex = '/(?P<message>.*)\sin\s(?P<file>.*)\son\sline\s(?P<line>\d+)/';
+ preg_match($regex, $line, $matches);
+ return array(
+ 'file' => $file,
+ 'line' => isset($matches['line']) ? $matches['line'] : null,
+ 'column' => null,
+ 'message' => isset($matches['message']) ? $matches['message'] : null
+ );
+ };
+ return array_map($format, array_filter($output, $filter));
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/extensions/commands/BranchUpgrade.php b/extensions/commands/BranchUpgrade.php
deleted file mode 100644
index ed06a7e..0000000
--- a/extensions/commands/BranchUpgrade.php
+++ /dev/null
@@ -1,111 +0,0 @@
-<?php
-/**
- * Lithium Hooks: A collection of git hooks & scripts that can be used for development in the
- * Lithium core and with Lithium applications.
- *
- * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
- * @license http://opensource.org/licenses/bsd-license.php The BSD License
- */
-
-namespace app\extensions\commands;
-
-/**
- * When pushing a new version, cleans up all local version-dependent feature branches which are
- * based on the existing version, and re-clones them based on the new version. For example:
- *
- * {{{li3 branch_upgrade --project=/path/to 1.5 1.6}}}
- *
- * Given the local branch `data`, cloned from `origin/1.5-data`, the `data` branch will be dropped
- * and re-checked-out from `origin/1.6-data`.
- *
- * For more information on feature/version branching schemes, see
- * (http://rad-dev.org/wiki/guides/branch-strategy)
- */
-class BranchUpgrade extends \lithium\console\Command {
-
- public $project;
-
- public function run() {
- if (count($this->request->params['passed']) < 2) {
- $this->_stop();
- }
- if (!$this->project) {
- $this->project = $this->request->env['working'];
- }
- list($old, $new) = $this->request->params['passed'];
- $locals = $remotes = $trackings = array();
- $current = null;
-
- chdir($this->project);
- `git pull origin`;
- `git remote prune origin`;
-
- foreach (array_map('trim', explode("\n", trim(`git branch -a`))) as $branch) {
- if (strpos($branch, 'remotes/') === 0) {
- $remotes[] = substr($branch, 8);
- continue;
- }
- $locals[] = $branch;
- }
-
- foreach ($locals as $i => $branch) {
- if (strpos($branch, '*') === 0) {
- $locals[$i] = $branch = substr($branch, 2);
- $current = $branch;
- }
- $cmd = "git config --get branch.{$branch}";
-
- $remote = trim(str_replace('refs/heads/', '', `{$cmd}.merge`));
- $trackings[$branch] = $remote;
- }
-
- if ($current != 'master') {
- `git checkout master`;
- }
-
- $merged = array_map('trim', explode(
- "\n", str_replace('*', '', trim(`git branch --merged`))
- ));
-
- foreach ($trackings + array('stable' => $old) as $local => $remote) {
- if (strpos($remote, "{$old}-") !== 0) {
- continue;
- }
- if (!in_array($local, $merged) && $local != 'stable') {
- $this->out("Branch {$local} has not been merged into HEAD - aborting.");
- $this->_stop();
- }
- $this->out("Dropping branch {$local} (tracks origin/{$remote})");
-
- if ($result = `git branch -d {$local}` && !preg_match('/^Deleted branch/', $result)) {
- $this->out("Problem encountered when dropping local branch {$local}: {$result}");
- $this->_stop();
- }
- }
-
- foreach ($remotes as $branch) {
- if (!strpos($branch = str_replace('origin/', '', $branch), $new) === 0) {
- continue;
- }
- if ($branch == $new) {
- $this->out("Checking out branch stable, tracking origin/{$new}");
- `git checkout -b stable --track origin/{$new}`;
- continue;
- }
- if (!strpos($branch, '-')) {
- continue;
- }
- list($version, $branch) = explode('-', $branch, 2);
-
- if ($version != $new) {
- continue;
- }
-
- $this->out("Checking out branch {$branch}, tracking origin/{$new}-{$branch}");
- `git checkout -b {$branch} --track origin/{$new}-{$branch}`;
- }
- `git checkout stable`;
- }
-}
-
-?>
\ No newline at end of file
diff --git a/extensions/commands/Syntax.php b/extensions/commands/Syntax.php
deleted file mode 100644
index 7c08f4f..0000000
--- a/extensions/commands/Syntax.php
+++ /dev/null
@@ -1,179 +0,0 @@
-<?php
-/**
- * Lithium Hooks: A collection of git hooks & scripts that can be used for development in the
- * Lithium core and with Lithium applications.
- *
- * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
- * @license http://opensource.org/licenses/bsd-license.php The BSD License
- */
-
-namespace app\extensions\commands;
-
-use lithium\core\Libraries;
-use lithium\util\Inflector;
-use lithium\util\String;
-use \RecursiveIteratorIterator;
-use \RecursiveDirectoryIterator;
-
-class Syntax extends \lithium\console\Command {
-
- public $checks;
-
- public $project;
-
- public $exclude = '\.';
-
- public $metrics;
-
- public $blame;
-
- protected $_vcs;
-
- public function run($file = null) {
- if (!$this->checks) {
- $this->help();
- return 1;
- }
- $this->checks = explode(',' , $this->checks);
-
- if (!$this->project) {
- $this->project = $this->request->env['working'];
- }
- $this->project = realpath($this->project);
-
- if (is_dir($this->project . '/.git')) {
- $this->_vcs = 'git';
- }
-
- if ($file[0] !== '/') {
- $file = $this->project . '/' . $file;
- }
- $failures = is_file($file) ? $this->_checkFile($file) : $this->_checkDirectory($file);
-
- if ($this->metrics) {
- $this->_metrics($failures);
- }
- return $failures ? 1 : 0;
- }
-
- protected function _checkFile($file) {
- $message = 'Checking `' . str_replace($this->project . '/', null, $file) .'`. ';
- $this->out($message, false);
- $failures = array();
-
- foreach ($this->checks as $check) {
- $class = Libraries::locate('commands.syntax', Inflector::camelize($check));
- $check = new $class(array('request' => $this->request));
-
- if (!$check->accepts($file)) {
- $this->out("Skipped. ", false);
- } elseif ($failures = $check->process($file)) {
- $this->out("Failed. ", false);
- } else {
- $this->out("Passed. ", false);
- }
- }
- $this->nl();
-
- if ($failures) {
- foreach ($failures as &$failure) {
- $failure['author'] = $this->_blame($failure);
- $this->error(sprintf(
- $this->blame ? '%1$4u| %2$3u| %3$20s| %4$s' : '%1$4u| %2$3u| %4$s',
- $failure['line'] ?: '??',
- $failure['column'] ?: '??',
- $failure['author'] ?: '??',
- $failure['message'] ?: '??'
- ));
- }
- $this->nl();
- return $failures;
- }
- }
-
- protected function _checkDirectory($directory) {
- $base = new RecursiveDirectoryIterator($directory);
- $iterator = new RecursiveIteratorIterator($base);
- $failures = array();
-
- foreach ($iterator as $item) {
- $basename = $item->getBasename();
- $file = $item->getPathname();
-
- if (preg_match('/\/' . $this->exclude . '/', $file) || $basename == 'empty') {
- continue;
- }
- if ($result = $this->_checkFile($file)) {
- $failures = array_merge($failures, $result);
- }
- }
- return $failures;
- }
-
- public function checks() {
- $this->header('Available Checks:');
- $classes = array_unique(Libraries::locate('commands.syntax', null, array(
- 'recursive' => false
- )));
- foreach ($classes as $command) {
- $command = explode('\\', $command);
- $this->out(' - ' . Inflector::underscore(array_pop($command)));
- }
- }
-
- public function help() {
- $message = 'Usage: li3 syntax [--project=PROJECT] [--exclude=REGEX] ';
- $message .= '[--metrics] [--blame] ';
- $message .= '--checks=CHECK[,CHECK] [FILE]';
- $this->out($message);
- }
-
- protected function _metrics($failures) {
- $this->header('Failures by author and message');
- $this->nl();
- $byAuthor = array();
-
- foreach ($failures as $failure) {
- $byAuthor[$failure['author']][$failure['message']][] = $failure;
- }
- ksort($byAuthor);
-
- foreach ($byAuthor as $author => $failures) {
- if (!$author) {
- continue;
- }
- $this->out($author);
- ksort($failures);
-
- foreach ($failures as $message => $messageFailures) {
- $this->out(' - `' . $message . '` ('. count($messageFailures) .')');
- }
- $this->nl();
- }
- }
-
- protected function _blame($failure) {
- if (!$this->_vcs == 'git') {
- return null;
- }
- $backup = getcwd();
- chdir($this->project);
- $lines = count(file($failure['file']));
-
- $command = 'git blame -L{:start},{:end} --porcelain {:file}';
- $replace = array(
- 'start' => $failure['line'],
- 'end' => $lines == $failure['line'] ? $failure['line'] : $failure['line'] + 1,
- 'file' => $failure['file']
- );
- exec(String::insert($command, $replace), $output, $return);
- chdir($backup);
-
- if ($return == 0) {
- list(, $author) = explode(' ', $output[1], 2);
- return $author;
- }
- }
-}
-
-?>
\ No newline at end of file
diff --git a/extensions/commands/syntax/Base.php b/extensions/commands/syntax/Base.php
deleted file mode 100644
index 10d916e..0000000
--- a/extensions/commands/syntax/Base.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * Lithium Hooks: A collection of git hooks & scripts that can be used for development in the
- * Lithium core and with Lithium applications.
- *
- * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
- * @license http://opensource.org/licenses/bsd-license.php The BSD License
- */
-
-namespace app\extensions\commands\syntax;
-
-/**
- * This is the base class all verification commands need to extend.
- */
-abstract class Base extends \lithium\console\Command {
-
- /**
- * Checks if given file can be checked.
- *
- * @param string $file Absolute path to file.
- * @return boolean
- */
- abstract public function accepts($file);
-
- /**
- * Process a file by checking it's contents.
- *
- * @param string $file Absolute path to file.
- * @return array|boolean|void `false` if file cannot be processed or - if applicable -
- * an array of violation messages.
- */
- abstract public function process($file);
-}
-
-?>
\ No newline at end of file
diff --git a/extensions/commands/syntax/Jsl.php b/extensions/commands/syntax/Jsl.php
deleted file mode 100644
index 3e5dbb3..0000000
--- a/extensions/commands/syntax/Jsl.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-/**
- * Lithium Hooks: A collection of git hooks & scripts that can be used for development in the
- * Lithium core and with Lithium applications.
- *
- * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
- * @license http://opensource.org/licenses/bsd-license.php The BSD License
- */
-
-namespace app\extensions\commands\syntax;
-
-use lithium\util\String;
-
-class Jsl extends \app\extensions\commands\syntax\Base {
-
- public function accepts($file) {
- return file_exists($file) && preg_match('/\.js$/', $file);
- }
-
- public function process($file) {
- $command = '{:jsl} -nologo -nosummary -nofilelisting -nocontext -process {:file}';
- $replace = array(
- 'jsl' => 'jsl',
- 'file' => $file
- );
- exec(String::insert($command, $replace), $output, $return);
-
- if ($return != 3) {
- return null;
- }
- $format = function($line) use ($file) {
- $regex = '/\((?P<line>\d+)\)\:\s(?P<message>.*)/';
- preg_match($regex, $line, $matches);
- return array(
- 'file' => $file,
- 'line' => isset($matches['line']) ? $matches['line'] : null,
- 'column' => null,
- 'message' => isset($matches['message']) ? $matches['message'] : null
- );
- };
- return array_map($format, $output);
- }
-}
-
-?>
\ No newline at end of file
diff --git a/extensions/commands/syntax/Phpca.php b/extensions/commands/syntax/Phpca.php
deleted file mode 100644
index 49a0965..0000000
--- a/extensions/commands/syntax/Phpca.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-/**
- * Lithium Hooks: A collection of git hooks & scripts that can be used for development in the
- * Lithium core and with Lithium applications.
- *
- * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
- * @license http://opensource.org/licenses/bsd-license.php The BSD License
- */
-
-namespace app\extensions\commands\syntax;
-
-use lithium\util\String;
-
-class Phpca extends \app\extensions\commands\syntax\Base {
-
- public function accepts($file) {
- return file_exists($file) && preg_match('/\.php$/', $file);
- }
-
- public function process($file) {
- $plugin = dirname(dirname(dirname(__DIR__)));
- $command = '{:php} {:phpca} -p {:php} --standard {:standard} {:file}';
- $replace = array(
- 'php' => trim(shell_exec('which php')),
- 'phpca' => $plugin . '/libraries/phpca/src/phpca.php',
- 'standard' => $plugin . '/config/phpca_lithium_standard.ini',
- 'file' => $file
- );
- exec(String::insert($command, $replace), $output, $return);
-
- if ($return == 0) {
- return null;
- }
- $format = function($line) use ($file) {
- $regex = '/(?P<line>\d+)\|.*(?P<column>\d+)\|\s+(?P<message>.*)/';
- preg_match($regex, $line, $matches);
-
- return array(
- 'file' => $file,
- 'line' => isset($matches['line']) ? $matches['line'] : null,
- 'column' => isset($matches['column']) ? $matches['column'] : null,
- 'message' => isset($matches['message']) ? $matches['message'] : null
- );
- };
- return array_map($format, array_filter(array_slice($output, 9, -3)));
- }
-}
-
-?>
\ No newline at end of file
diff --git a/extensions/commands/syntax/Phpl.php b/extensions/commands/syntax/Phpl.php
deleted file mode 100644
index b176725..0000000
--- a/extensions/commands/syntax/Phpl.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-/**
- * Lithium Hooks: A collection of git hooks & scripts that can be used for development in the
- * Lithium core and with Lithium applications.
- *
- * @copyright Copyright 2009, Union of Rad, Inc. (http://union-of-rad.org)
- * @license http://opensource.org/licenses/bsd-license.php The BSD License
- */
-
-namespace app\extensions\commands\syntax;
-
-use lithium\util\String;
-
-class Phpl extends \app\extensions\commands\syntax\Base {
-
- public function accepts($file) {
- return file_exists($file) && preg_match('/\.php$/', $file);
- }
-
- public function process($file) {
- $command = '{:php} -l {:file} 2> /dev/null';
- $replace = array(
- 'php' => 'php',
- 'file' => $file
- );
- exec(String::insert($command, $replace), $output, $return);
-
- if ($return == 0) {
- return null;
- }
- $filter = function($failure) {
- return !empty($failure) && $failure[0] == 'P';
- };
- $format = function($line) use ($file) {
- $regex = '/(?P<message>.*)\sin\s(?P<file>.*)\son\sline\s(?P<line>\d+)/';
- preg_match($regex, $line, $matches);
- return array(
- 'file' => $file,
- 'line' => isset($matches['line']) ? $matches['line'] : null,
- 'column' => null,
- 'message' => isset($matches['message']) ? $matches['message'] : null
- );
- };
- return array_map($format, array_filter($output, $filter));
- }
-}
-
-?>
\ No newline at end of file