diff --git a/.php_cs.dist b/.php_cs.dist index 0f254c63283..84a5f88bf43 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -5,9 +5,9 @@ */ /** - * Pre-commit hook installation: - * vendor/bin/static-review.php hook:install dev/tools/Magento/Tools/StaticReview/pre-commit .git/hooks/pre-commit + * PHP Coding Standards fixer configuration */ + $finder = PhpCsFixer\Finder::create() ->name('*.phtml') ->exclude('dev/tests/functional/generated') diff --git a/composer.json b/composer.json index e0db7a4a99a..766cba3595c 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,6 @@ "pelago/emogrifier": "^2.0.0", "phpseclib/phpseclib": "2.0.*", "ramsey/uuid": "3.6.1", - "sjparkinson/static-review": "~4.1", "symfony/console": "~2.3, !=2.7.0", "symfony/event-dispatcher": "~2.1", "symfony/process": "~2.1", diff --git a/composer.lock b/composer.lock index ee6328ed75b..d0ad72aaf0f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "9114dbda66ca0958916c9e26caf374ce", + "content-hash": "ed9392800aa1b1f4dfb79947e123ea85", "packages": [ { "name": "braintree/braintree_php", @@ -554,55 +554,6 @@ ], "time": "2017-10-21T13:15:38+00:00" }, - { - "name": "league/climate", - "version": "2.6.1", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/climate.git", - "reference": "28851c909017424f61cc6a62089316313c645d1c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/climate/zipball/28851c909017424f61cc6a62089316313c645d1c", - "reference": "28851c909017424f61cc6a62089316313c645d1c", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "mockery/mockery": "dev-master", - "phpunit/phpunit": "4.1.*" - }, - "type": "library", - "autoload": { - "psr-4": { - "League\\CLImate\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Joe Tannenbaum", - "email": "hey@joe.codes", - "homepage": "http://joe.codes/", - "role": "Developer" - } - ], - "description": "PHP's best friend for the terminal. CLImate allows you to easily output colored text, special formats, and more.", - "keywords": [ - "cli", - "colors", - "command", - "php", - "terminal" - ], - "time": "2015-01-18T14:31:58+00:00" - }, { "name": "magento/composer", "version": "1.2.0", @@ -1433,60 +1384,6 @@ ], "time": "2015-10-13T18:44:15+00:00" }, - { - "name": "sjparkinson/static-review", - "version": "4.1.1", - "source": { - "type": "git", - "url": "https://github.com/sjparkinson/static-review.git", - "reference": "493c3410cf146a12fca84209bad126c494e125f0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sjparkinson/static-review/zipball/493c3410cf146a12fca84209bad126c494e125f0", - "reference": "493c3410cf146a12fca84209bad126c494e125f0", - "shasum": "" - }, - "require": { - "league/climate": "~2.0", - "php": ">=5.4.0", - "symfony/console": "~2.0", - "symfony/process": "~2.0" - }, - "require-dev": { - "mockery/mockery": "~0.9", - "phpunit/phpunit": "~4.0", - "sensiolabs/security-checker": "~2.0", - "squizlabs/php_codesniffer": "~1.0" - }, - "suggest": { - "sensiolabs/security-checker": "Required for ComposerSecurityReview.", - "squizlabs/php_codesniffer": "Required for PhpCodeSnifferReview." - }, - "bin": [ - "bin/static-review.php" - ], - "type": "library", - "autoload": { - "psr-4": { - "StaticReview\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Samuel Parkinson", - "email": "sam.james.parkinson@gmail.com", - "homepage": "http://samp.im" - } - ], - "description": "An extendable framework for version control hooks.", - "abandoned": "phpro/grumphp", - "time": "2014-09-22T08:40:36+00:00" - }, { "name": "symfony/console", "version": "v2.8.34", diff --git a/dev/tools/Magento/Tools/StaticReview/PhpCsFixerReview.php b/dev/tools/Magento/Tools/StaticReview/PhpCsFixerReview.php deleted file mode 100644 index 113b139555d..00000000000 --- a/dev/tools/Magento/Tools/StaticReview/PhpCsFixerReview.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @see http://github.com/sjparkinson/static-review/blob/master/LICENSE.md - */ -namespace Magento\Tools\StaticReview; - -use StaticReview\File\FileInterface; -use StaticReview\Reporter\ReporterInterface; -use StaticReview\Review\AbstractReview; - -class PhpCsFixerReview extends AbstractReview -{ - /** - * @var array - */ - protected $options; - - /** - * @param array $options - */ - public function __construct($options = []) - { - $this->options = $options; - } - - /** - * Obtained from .php_cs configuration file. - * - * @param FileInterface $file - * @return bool - */ - public function canReview(FileInterface $file) - { - return in_array($file->getExtension(), ['php', 'phtml', 'xml', 'yml']); - } - - /** - * Checks and fixes PHP files using PHP Coding Standards Fixer. - * - * @param ReporterInterface $reporter - * @param FileInterface $file - * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function review(ReporterInterface $reporter, FileInterface $file) - { - $cmd = 'vendor/bin/php-cs-fixer -vvv '; - foreach ($this->options as $key => $value) { - $cmd .= ' --' . $key . '=' . escapeshellarg($value); - } - $cmd .= ' fix ' . escapeshellarg($file->getRelativePath()); - - $process = $this->getProcess($cmd); - $process->run(); - - $process = $this->getProcess('git add ' . escapeshellarg($file->getRelativePath())); - $process->run(); - } -} diff --git a/dev/tools/Magento/Tools/StaticReview/pre-commit b/dev/tools/Magento/Tools/StaticReview/pre-commit deleted file mode 100755 index 0bbb62797f4..00000000000 --- a/dev/tools/Magento/Tools/StaticReview/pre-commit +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env php - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @see https://github.com/sjparkinson/static-review/blob/master/LICENSE - */ -$included = include __DIR__ . '/../../../../../vendor/autoload.php'; -if (!$included) { - echo 'You must set up the project dependencies, run the following commands:' . PHP_EOL - . 'curl -sS https://getcomposer.org/installer | php' . PHP_EOL - . 'php composer.phar install' . PHP_EOL; - - exit(1); -} - -// Installation: -// vendor/bin/static-review.php hook:install dev/tools/Magento/Tools/StaticReview/pre-commit .git/hooks/pre-commit - -// Reference the required classes and the reviews you want to use. -use League\CLImate\CLImate; -use StaticReview\Reporter\Reporter; -use StaticReview\Review\Composer\ComposerLintReview; -use StaticReview\Review\General\LineEndingsReview; -use StaticReview\Review\General\NoCommitTagReview; -use StaticReview\Review\PHP\PhpLeadingLineReview; -use StaticReview\Review\PHP\PhpLintReview; -use Magento\Tools\StaticReview\PhpCsFixerReview; -use StaticReview\StaticReview; -use StaticReview\VersionControl\GitVersionControl; - -$reporter = new Reporter(); -$climate = new CLImate(); -$git = new GitVersionControl(); - -// Apply review which modifies staged files first -$review = new StaticReview($reporter); -$phpCsFixer = new PhpCsFixerReview(); -$review->addReview($phpCsFixer); -$review->review($git->getStagedFiles()); - -// Apply read-only review then -$review = new StaticReview($reporter); -$review->addReview(new LineEndingsReview()) - ->addReview(new PhpLeadingLineReview()) - ->addReview(new NoCommitTagReview()) - ->addReview(new PhpLintReview()) - ->addReview(new ComposerLintReview()); -$review->review($git->getStagedFiles()); - -// Check if any matching issues were found. -if ($reporter->hasIssues()) { - $climate->out('')->out(''); - - foreach ($reporter->getIssues() as $issue) { - $climate->red($issue); - } - - $climate->out('')->red('✘ Please fix the errors above.'); - - exit(1); -} else { - $climate->out('')->green('✔ Looking good.')->white('Have you tested everything?'); - - exit(0); -}