diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 886ef9fb..fe107e69 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,9 +4,11 @@ When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change. -Please note we have [a code of conduct](#code-of-conduct), please follow it in all your interactions +Please note we have [a code of conduct][], please follow it in all your interactions with the project. +[a code of conduct]: https://github.com/Dealerdirect/phpcodesniffer-composer-installer/blob/master/CODE_OF_CONDUCT.md + ## Issues and feature requests You've found a bug in the source code, a mistake in the documentation or maybe diff --git a/LICENSE.md b/LICENSE.md index c7b46086..893aafb7 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2016-2021 Dealerdirect B.V. +Copyright (c) 2016-2022 Dealerdirect B.V. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index f6bc946c..b8ae2201 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ This plugin is compatible with: Basically, this plugin executes the following steps: -- This plugin searches for [`phpcodesniffer-standard` packages] in all of your currently installed Composer packages. +- This plugin searches for [`phpcodesniffer-standard` packages][] in all of your currently installed Composer packages. - Matching packages and the project itself are scanned for PHP_CodeSniffer rulesets. - The plugin will call PHP_CodeSniffer and configure the `installed_paths` option. @@ -235,7 +235,7 @@ For a full list of all author and/or contributors, check [the contributors page] The MIT License (MIT) -Copyright (c) 2016-2021 Dealerdirect B.V. +Copyright (c) 2016-2022 Dealerdirect B.V. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/composer.json b/composer.json index e033dd34..46e65c7e 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "composer-plugin", "keywords": [ "composer", "installer", "plugin", - "phpcs", "codesniffer", "phpcodesniffer", "php_codesniffer", + "phpcs", "phpcbf", "codesniffer", "phpcodesniffer", "php_codesniffer", "standard", "standards", "style guide", "stylecheck", "qa", "quality", "code quality", "tests" ], @@ -16,6 +16,10 @@ "email": "franck.nijhof@dealerdirect.com", "homepage": "http://www.frenck.nl", "role": "Developer / IT Manager" + }, + { + "name" : "Contributors", + "homepage" : "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" } ], "support": { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 76331384..d052e054 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -20,4 +20,7 @@ and constant visibility was only introduced in PHP 7.1. --> + + + diff --git a/src/Plugin.php b/src/Plugin.php index 5ae09d03..597e9292 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -4,7 +4,7 @@ * This file is part of the Dealerdirect PHP_CodeSniffer Standards * Composer Installer Plugin package. * - * @copyright 2016-2021 Dealerdirect B.V. + * @copyright 2016-2022 Dealerdirect B.V. * @license MIT */ @@ -38,16 +38,17 @@ class Plugin implements PluginInterface, EventSubscriberInterface const MESSAGE_ERROR_WRONG_MAX_DEPTH = 'The value of "%s" (in the composer.json "extra".section) must be an integer larger then %d, %s given.'; - const MESSAGE_NOT_INSTALLED = 'PHPCodeSniffer is not installed'; + + const MESSAGE_NOT_INSTALLED = 'PHPCodeSniffer is not installed'; const MESSAGE_NOTHING_TO_INSTALL = 'Nothing to install or update'; const MESSAGE_PLUGIN_UNINSTALLED = 'PHPCodeSniffer Composer Installer is uninstalled'; - const MESSAGE_RUNNING_INSTALLER = 'Running PHPCodeSniffer Composer Installer'; + const MESSAGE_RUNNING_INSTALLER = 'Running PHPCodeSniffer Composer Installer'; const PACKAGE_NAME = 'squizlabs/php_codesniffer'; const PACKAGE_TYPE = 'phpcodesniffer-standard'; const PHPCS_CONFIG_REGEX = '`%s:[^\r\n]+`'; - const PHPCS_CONFIG_KEY = 'installed_paths'; + const PHPCS_CONFIG_KEY = 'installed_paths'; const PLUGIN_NAME = 'dealerdirect/phpcodesniffer-composer-installer'; @@ -96,12 +97,12 @@ class Plugin implements PluginInterface, EventSubscriberInterface */ public static function run(Event $event) { - $io = $event->getIO(); + $io = $event->getIO(); $composer = $event->getComposer(); $instance = new static(); - $instance->io = $io; + $instance->io = $io; $instance->composer = $composer; $instance->init(); $instance->onDependenciesChangedEvent(); @@ -118,7 +119,7 @@ public static function run(Event $event) public function activate(Composer $composer, IOInterface $io) { $this->composer = $composer; - $this->io = $io; + $this->io = $io; $this->init(); } @@ -147,11 +148,11 @@ public function uninstall(Composer $composer, IOInterface $io) */ private function init() { - $this->cwd = getcwd(); + $this->cwd = getcwd(); $this->installedPaths = array(); $this->processExecutor = new ProcessExecutor($this->io); - $this->filesystem = new Filesystem($this->processExecutor); + $this->filesystem = new Filesystem($this->processExecutor); } /** @@ -179,9 +180,9 @@ public static function getSubscribedEvents() */ public function onDependenciesChangedEvent() { - $io = $this->io; + $io = $this->io; $isVerbose = $io->isVerbose(); - $exitCode = 0; + $exitCode = 0; if ($isVerbose) { $io->write(sprintf('%s', self::MESSAGE_RUNNING_INSTALLER)); @@ -267,8 +268,8 @@ private function saveInstalledPaths() // Check if we found installed paths to set. if (count($this->installedPaths) !== 0) { sort($this->installedPaths); - $paths = implode(',', $this->installedPaths); - $arguments = array('--config-set', self::PHPCS_CONFIG_KEY, $paths); + $paths = implode(',', $this->installedPaths); + $arguments = array('--config-set', self::PHPCS_CONFIG_KEY, $paths); $configMessage = sprintf( 'PHP CodeSniffer Config %s set to %s', self::PHPCS_CONFIG_KEY, @@ -276,7 +277,7 @@ private function saveInstalledPaths() ); } else { // Delete the installed paths if none were found. - $arguments = array('--config-delete', self::PHPCS_CONFIG_KEY); + $arguments = array('--config-delete', self::PHPCS_CONFIG_KEY); $configMessage = sprintf( 'PHP CodeSniffer Config %s delete', self::PHPCS_CONFIG_KEY @@ -305,7 +306,7 @@ private function saveInstalledPaths() array( 'php executable' => $this->getPhpExecCommand(), 'phpcs executable' => $phpcsExecutable, - 'arguments' => implode(' ', $arguments) + 'arguments' => implode(' ', $arguments), ) ); @@ -382,7 +383,7 @@ protected function getPhpExecCommand() : '' ; - $command = ProcessExecutor::escape($phpPath) . + $command = ProcessExecutor::escape($phpPath) . $phpArgs . ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen')) . ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions')) . @@ -405,7 +406,7 @@ private function cleanInstalledPaths() $changes = false; foreach ($this->installedPaths as $key => $path) { // This might be a relative path as well - $alternativePath = realpath($this->getPHPCodeSnifferInstallPath() . DIRECTORY_SEPARATOR . $path); + $alternativePath = realpath($this->getPHPCodeSnifferInstallPath() . \DIRECTORY_SEPARATOR . $path); if ( (is_dir($path) === false || is_readable($path) === false) && @@ -435,13 +436,13 @@ private function updateInstalledPaths() { $changes = false; - $searchPaths = array($this->cwd); + $searchPaths = array($this->cwd); $codingStandardPackages = $this->getPHPCodingStandardPackages(); foreach ($codingStandardPackages as $package) { $installPath = $this->composer->getInstallationManager()->getInstallPath($package); if ($this->filesystem->isAbsolutePath($installPath) === false) { $installPath = $this->filesystem->normalizePath( - $this->cwd . DIRECTORY_SEPARATOR . $installPath + $this->cwd . \DIRECTORY_SEPARATOR . $installPath ); } $searchPaths[] = $installPath; @@ -477,7 +478,7 @@ private function updateInstalledPaths() // De-duplicate and add when directory is not configured. if (in_array($standardsPath, $this->installedPaths, true) === false) { $this->installedPaths[] = $standardsPath; - $changes = true; + $changes = true; } } @@ -593,8 +594,8 @@ private function getMaxDepth() $message = vsprintf( self::MESSAGE_ERROR_WRONG_MAX_DEPTH, array( - 'key' => self::KEY_MAX_DEPTH, - 'min' => $minDepth, + 'key' => self::KEY_MAX_DEPTH, + 'min' => $minDepth, 'given' => var_export($maxDepth, true), ) );