From b905338ca6b08ef5e6832ac7d102b9f0d441e120 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 8 Dec 2019 22:18:42 +0100 Subject: [PATCH] CS: fix compliance with PSR12 PHPCS 3.5.0+ contains a far more complete PSR12 ruleset. 1. The current code didn't fully comply with that ruleset. Some minor code tweaks fix that. 2. PSR12 demands constant visibility to be declared, but as this project still supports PHP 5.3 and constant visibility wasn't introduced until PHP 7.1, this is not desirable. Excluding that particular rule from within the ruleset fixes that. --- phpcs.xml.dist | 6 +++++- src/Plugin.php | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index c2e6d539..76331384 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -15,5 +15,9 @@ - + + + + diff --git a/src/Plugin.php b/src/Plugin.php index ce17952b..3539a2c3 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -269,7 +269,8 @@ private function cleanInstalledPaths() // This might be a relative path as well $alternativePath = realpath($this->getPHPCodeSnifferInstallPath() . DIRECTORY_SEPARATOR . $path); - if ((is_dir($path) === false || is_readable($path) === false) && + if ( + (is_dir($path) === false || is_readable($path) === false) && (is_dir($alternativePath) === false || is_readable($alternativePath) === false) ) { unset($this->installedPaths[$key]); @@ -362,7 +363,8 @@ function (PackageInterface $package) { } ); - if (! $this->composer->getPackage() instanceof RootpackageInterface + if ( + ! $this->composer->getPackage() instanceof RootpackageInterface && $this->composer->getPackage()->getType() === self::PACKAGE_TYPE ) { $codingStandardPackages[] = $this->composer->getPackage(); @@ -441,7 +443,8 @@ private function getMaxDepth() $maxDepth = $extra[self::KEY_MAX_DEPTH]; $minDepth = $this->getMinDepth(); - if ((string) (int) $maxDepth !== (string) $maxDepth /* Must be an integer or cleanly castable to one */ + if ( + (string) (int) $maxDepth !== (string) $maxDepth /* Must be an integer or cleanly castable to one */ || $maxDepth <= $minDepth /* Larger than the minimum */ || is_float($maxDepth) === true /* Within the boundaries of integer */ ) {