Ver Fonte

Coding standards.

Frederic G. MARAND há 7 anos atrás
pai
commit
a9aa9decec

+ 2 - 1
ComposerCheck/DrushReporter.php

@@ -10,7 +10,7 @@ class DrushReporter extends ReporterBase {
   /**
    * {@inheritdoc}
    */
-  public function report(MergeBox $mergeBox): string {
+  public function report(MergeBox $mergeBox) : string {
     $header = ['Name', 'Kind', 'Requirement', 'Version'];
     $rows = [$header];
     foreach ($mergeBox->getRows() as $kind => $kindPackages) {
@@ -23,6 +23,7 @@ class DrushReporter extends ReporterBase {
         ];
       }
     }
+
     ksort($rows);
     drush_print_table($rows, FALSE);
   }

+ 3 - 2
ComposerCheck/JsonReporter.php

@@ -10,8 +10,9 @@ class JsonReporter extends ReporterBase {
   /**
    * {@inheritdoc}
    */
-  public function report(MergeBox $mergeBox): string {
-    return json_encode($mergeBox->getRows(), JSON_PRETTY_PRINT);
+  public function report(MergeBox $mergeBox) : string {
+    $json = json_encode($mergeBox->getRows(), JSON_PRETTY_PRINT);
+    return $json;
   }
 
 }

+ 1 - 0
ComposerCheck/LoaderFactory.php

@@ -25,6 +25,7 @@ class LoaderFactory {
     if (empty($validatedDirectory)) {
       throw new \InvalidArgumentException("Unusable directory: $directory");
     }
+
     $this->directory = $validatedDirectory;
   }
 

+ 7 - 1
ComposerCheck/MergeBox.php

@@ -38,7 +38,9 @@ class MergeBox {
    * @param bool $all
    *   Include all packages or only those required ?
    */
-  public function __construct(RequirementsLoader $requirementsLoader, LockLoader $lockLoader, bool $all) {
+  public function __construct(RequirementsLoader $requirementsLoader,
+    LockLoader $lockLoader,
+    bool $all) {
     $this->requirements = $requirementsLoader;
     $this->lock = $lockLoader;
     $this->all = $all;
@@ -56,12 +58,14 @@ class MergeBox {
         $packages['run'][$package]['requirement'] = $requirement;
       }
     }
+
     foreach ($this->requirements->getDev() as $package => $requirement) {
       if ($this->all || !empty($requirement)) {
         $package = strtolower($package);
         $packages['dev'][$package]['requirement'] = $requirement;
       }
     }
+
     foreach ($this->lock->getRun() as $packageInfo) {
       $package = strtolower($packageInfo['name']);
       if ($this->all || !empty($packages['run'][$package])) {
@@ -69,6 +73,7 @@ class MergeBox {
         $packages['run'][$package]['version'] = $version;
       }
     }
+
     foreach ($this->lock->getDev() as $packageInfo) {
       $package = strtolower($packageInfo['name']);
       if ($this->all || !empty($packages['dev'][$package])) {
@@ -76,6 +81,7 @@ class MergeBox {
         $packages['dev'][$package]['version'] = $version;
       }
     }
+
     ksort($packages['dev']);
     ksort($packages['run']);
     $this->packages = $packages;

+ 1 - 1
ComposerCheck/ReporterBase.php

@@ -16,6 +16,6 @@ abstract class ReporterBase implements ReporterInterface {
    * @return string
    *   The formatted report output.
    */
-  public abstract function report(MergeBox $mergeBox): string;
+  abstract public function report(MergeBox $mergeBox): string;
 
 }

+ 3 - 2
ComposerCheck/YamlReporter.php

@@ -12,8 +12,9 @@ class YamlReporter extends ReporterBase {
   /**
    * {@inheritdoc}
    */
-  public function report(MergeBox $mergeBox): string {
-    return Yaml::dump($mergeBox->getRows(), 3);
+  public function report(MergeBox $mergeBox) : string {
+    $yaml = Yaml::dump($mergeBox->getRows(), 3);
+    return $yaml;
   }
 
 }

+ 4 - 3
composer.json

@@ -16,11 +16,12 @@
   },
   "require-dev": {
     "phpunit/phpunit": "^5.7",
-    "phpspec/prophecy": "^1.6"
+    "phpspec/prophecy": "^1.6",
+    "squizlabs/php_codesniffer": "^2.8"
   },
-  "type": "drupal-drush",
   "support": {
     "issues": "http://code.osinet.fr/fgm/drush_plugin__composer_check/issues",
     "source": "http://code.osinet.fr/fgm/drush_plugin__composer_check.git"
-  }
+  },
+  "type": "drupal-drush"
 }

+ 93 - 0
phpcs.xml.dist

@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset name="pcsg-generated-ruleset">
+  <description>Created with the PHP Coding Standard Generator. http://edorian.github.com/php-coding-standard-generator/
+  </description>
+  <rule ref="Generic.Classes.DuplicateClassName"/>
+  <rule ref="Generic.CodeAnalysis.EmptyStatement"/>
+  <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
+  <rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
+  <rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
+  <rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
+  <rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
+  <rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
+  <rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
+  <rule ref="Generic.Commenting.Fixme"/>
+  <rule ref="Generic.ControlStructures.InlineControlStructure"/>
+  <rule ref="Generic.Files.ByteOrderMark"/>
+  <rule ref="Generic.Files.LineEndings"/>
+  <rule ref="Generic.Files.LineLength"/>
+  <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
+  <rule ref="Generic.Formatting.SpaceAfterCast"/>
+  <rule ref="Generic.Functions.CallTimePassByReference"/>
+  <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
+  <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
+  <rule ref="Generic.Metrics.CyclomaticComplexity"/>
+  <rule ref="Generic.Metrics.NestingLevel"/>
+  <rule ref="Generic.NamingConventions.ConstructorName"/>
+  <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
+  <rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>
+  <rule ref="Generic.PHP.DeprecatedFunctions"/>
+  <rule ref="Generic.PHP.DisallowShortOpenTag"/>
+  <rule ref="Generic.PHP.ForbiddenFunctions"/>
+  <rule ref="Generic.PHP.NoSilencedErrors">
+    <properties>
+      <property name="error" value="false"/>
+    </properties>
+  </rule>
+  <rule ref="Generic.PHP.UpperCaseConstant"/>
+  <rule ref="Generic.Strings.UnnecessaryStringConcat"/>
+  <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
+  <rule ref="Generic.WhiteSpace.ScopeIndent">
+    <properties>
+      <property name="indent" value="2"/>
+    </properties>
+  </rule>
+  <rule ref="MySource.PHP.EvalObjectFactory"/>
+  <rule ref="MySource.PHP.ReturnFunctionValue"/>
+  <rule ref="MySource.PHP.AjaxNullComparison"/>
+  <rule ref="PSR1.Classes.ClassDeclaration"/>
+  <rule ref="PSR1.Files.SideEffects"/>
+  <!--<rule ref="PSR2.Classes.ClassDeclaration"/>-->
+  <rule ref="PSR2.Classes.PropertyDeclaration"/>
+  <rule ref="PSR2.ControlStructures.ControlStructureSpacing"/>
+  <rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
+  <rule ref="PSR2.ControlStructures.SwitchDeclaration">
+    <properties>
+      <property name="indent" value="2"/>
+    </properties>
+  </rule>
+  <rule ref="PSR2.Files.EndFileNewline"/>
+  <rule ref="PSR2.Methods.MethodDeclaration"/>
+  <rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
+  <rule ref="PSR2.Namespaces.UseDeclaration"/>
+  <rule ref="Squiz.PHP.CommentedOutCode"/>
+  <rule ref="Squiz.PHP.DisallowMultipleAssignments"/>
+  <rule ref="Squiz.PHP.DisallowObEndFlush"/>
+  <rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/>
+  <rule ref="Squiz.PHP.DiscouragedFunctions"/>
+  <rule ref="Squiz.PHP.Eval"/>
+  <rule ref="Squiz.PHP.ForbiddenFunctions"/>
+  <rule ref="Squiz.PHP.GlobalKeyword"/>
+  <rule ref="Squiz.PHP.InnerFunctions"/>
+  <rule ref="Squiz.PHP.LowercasePHPFunctions"/>
+  <rule ref="Squiz.PHP.NonExecutableCode"/>
+  <rule ref="Squiz.Scope.MemberVarScope"/>
+  <rule ref="Squiz.Scope.MethodScope"/>
+  <rule ref="Squiz.Scope.StaticThisUsage"/>
+  <rule ref="Squiz.WhiteSpace.CastSpacing"/>
+  <rule ref="Squiz.WhiteSpace.ControlStructureSpacing"/>
+  <rule ref="Squiz.WhiteSpace.FunctionSpacing">
+    <properties>
+      <property name="spacing" value="1"/>
+    </properties>
+  </rule>
+  <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
+  <rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
+  <rule ref="Squiz.WhiteSpace.MemberVarSpacing"/>
+  <rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing"/>
+  <rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
+  <rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
+  <rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
+  <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
+  <rule ref="Zend.Files.ClosingTag"/>
+</ruleset>