From ca2eea08e396dc5aca6870576469f0b74ee12de7 Mon Sep 17 00:00:00 2001
From: Marco Stoll <marco.stoll@rocketmail.com>
Date: Wed, 26 Jun 2019 11:45:44 +0200
Subject: [PATCH] [FEATURE] add phpcs using PSR2

---
 bin/phpcs.bat                                             | 3 +++
 composer.json                                             | 1 +
 phpdox.xml                                                | 4 +---
 src/AbstractFactory.php                                   | 2 +-
 src/AbstractSingletonFactory.php                          | 3 +--
 src/ClassLocators/BaseNamespaceClassLocator.php           | 2 +-
 src/ClassLocators/ClassIdentifierAwareInterface.php       | 2 +-
 src/ClassLocators/ClassLocatorInterface.php               | 2 +-
 src/ClassLocators/NamespaceClassLocator.php               | 6 ++++--
 src/ClassLocators/NamespacePrefixedClassLocator.php       | 2 +-
 src/Exceptions/ClassNotFoundException.php                 | 2 +-
 src/Exceptions/InstantiationException.php                 | 2 +-
 tests/AbstractFactoryTest.php                             | 2 +-
 tests/AbstractSingletonFactoryTest.php                    | 2 +-
 tests/ClassLocators/BaseNamespaceClassLocatorTest.php     | 2 +-
 tests/ClassLocators/NamespaceClassLocatorTest.php         | 2 +-
 tests/ClassLocators/NamespacePrefixedClassLocatorTest.php | 2 +-
 17 files changed, 22 insertions(+), 19 deletions(-)
 create mode 100644 bin/phpcs.bat

diff --git a/bin/phpcs.bat b/bin/phpcs.bat
new file mode 100644
index 0000000..dc91dbd
--- /dev/null
+++ b/bin/phpcs.bat
@@ -0,0 +1,3 @@
+@ECHO OFF
+SET PROJECT_HOME=C:\dev\ffe\fastforward\Factories
+vendor\bin\phpcs --report=xml --report-file="%PROJECT_HOME%\logs\phpcs\report.xml" --standard=PSR2 %PROJECT_HOME%\src %PROJECT_HOME%\tests -p
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 2f54bc0..8e5fb28 100644
--- a/composer.json
+++ b/composer.json
@@ -18,6 +18,7 @@
   },
   "require-dev": {
     "phpunit/phpunit": "^8",
+    "squizlabs/php_codesniffer": "^3",
     "theseer/phpdox": "*"
   },
   "repositories": [
diff --git a/phpdox.xml b/phpdox.xml
index e90d769..157f08f 100644
--- a/phpdox.xml
+++ b/phpdox.xml
@@ -85,11 +85,9 @@
                 </source>
 
                 <!-- PHP Code Sniffer findings -->
-                <!--
                 <source type="phpcs">
-                    <file name="logs/phpcs.xml" />
+                    <file name="../logs/phpcs/report.xml" />
                 </source>
-                -->
 
                 <!-- PHPMessDetector -->
                 <!--
diff --git a/src/AbstractFactory.php b/src/AbstractFactory.php
index f9152ea..3bb9af3 100644
--- a/src/AbstractFactory.php
+++ b/src/AbstractFactory.php
@@ -81,4 +81,4 @@ abstract class AbstractFactory
         $this->classLocator = $classLocator;
         return $this;
     }
-}
\ No newline at end of file
+}
diff --git a/src/AbstractSingletonFactory.php b/src/AbstractSingletonFactory.php
index aa0d860..bc56e29 100644
--- a/src/AbstractSingletonFactory.php
+++ b/src/AbstractSingletonFactory.php
@@ -10,7 +10,6 @@ declare(strict_types=1);
 
 namespace FF\Factories;
 
-
 /**
  * Class AbstractSingletonFactory
  *
@@ -52,4 +51,4 @@ abstract class AbstractSingletonFactory extends AbstractFactory
         $this->instanceCache = [];
         return $this;
     }
-}
\ No newline at end of file
+}
diff --git a/src/ClassLocators/BaseNamespaceClassLocator.php b/src/ClassLocators/BaseNamespaceClassLocator.php
index 76edd9a..94356b0 100644
--- a/src/ClassLocators/BaseNamespaceClassLocator.php
+++ b/src/ClassLocators/BaseNamespaceClassLocator.php
@@ -77,4 +77,4 @@ class BaseNamespaceClassLocator extends NamespaceClassLocator
     {
         return parent::buildFqClassName($ns . '\\' . $this->commonSuffix, $classIdentifier);
     }
-}
\ No newline at end of file
+}
diff --git a/src/ClassLocators/ClassIdentifierAwareInterface.php b/src/ClassLocators/ClassIdentifierAwareInterface.php
index a193913..f5195f3 100644
--- a/src/ClassLocators/ClassIdentifierAwareInterface.php
+++ b/src/ClassLocators/ClassIdentifierAwareInterface.php
@@ -23,4 +23,4 @@ interface ClassIdentifierAwareInterface
      * @return string
      */
     public static function getClassIdentifier(): string;
-}
\ No newline at end of file
+}
diff --git a/src/ClassLocators/ClassLocatorInterface.php b/src/ClassLocators/ClassLocatorInterface.php
index 14ee2bf..6faf7bd 100644
--- a/src/ClassLocators/ClassLocatorInterface.php
+++ b/src/ClassLocators/ClassLocatorInterface.php
@@ -26,4 +26,4 @@ interface ClassLocatorInterface
      * @return string|null
      */
     public function locateClass(string $classIdentifier): ?string;
-}
\ No newline at end of file
+}
diff --git a/src/ClassLocators/NamespaceClassLocator.php b/src/ClassLocators/NamespaceClassLocator.php
index 45c192b..5c367ee 100644
--- a/src/ClassLocators/NamespaceClassLocator.php
+++ b/src/ClassLocators/NamespaceClassLocator.php
@@ -60,7 +60,9 @@ class NamespaceClassLocator implements ClassLocatorInterface
     {
         foreach ($this->namespaces as $ns) {
             $fqClassname = $this->buildFqClassName($ns, $classIdentifier);
-            if (!class_exists($fqClassname)) continue;
+            if (!class_exists($fqClassname)) {
+                continue;
+            }
 
             return $fqClassname;
         }
@@ -115,4 +117,4 @@ class NamespaceClassLocator implements ClassLocatorInterface
     {
         array_walk($namespaces, [ClassUtils::class, 'normalizeNamespace']);
     }
-}
\ No newline at end of file
+}
diff --git a/src/ClassLocators/NamespacePrefixedClassLocator.php b/src/ClassLocators/NamespacePrefixedClassLocator.php
index 0d1c376..63ac374 100644
--- a/src/ClassLocators/NamespacePrefixedClassLocator.php
+++ b/src/ClassLocators/NamespacePrefixedClassLocator.php
@@ -81,4 +81,4 @@ class NamespacePrefixedClassLocator extends NamespaceClassLocator
 
         return $ns . '\\' . $subNs . $this->prefix . '\\' . $localClassName;
     }
-}
\ No newline at end of file
+}
diff --git a/src/Exceptions/ClassNotFoundException.php b/src/Exceptions/ClassNotFoundException.php
index 783b85a..62bb360 100644
--- a/src/Exceptions/ClassNotFoundException.php
+++ b/src/Exceptions/ClassNotFoundException.php
@@ -18,4 +18,4 @@ namespace FF\Factories\Exceptions;
 class ClassNotFoundException extends \RuntimeException
 {
 
-}
\ No newline at end of file
+}
diff --git a/src/Exceptions/InstantiationException.php b/src/Exceptions/InstantiationException.php
index cace675..3739ace 100644
--- a/src/Exceptions/InstantiationException.php
+++ b/src/Exceptions/InstantiationException.php
@@ -18,4 +18,4 @@ namespace FF\Factories\Exceptions;
 class InstantiationException extends \RuntimeException
 {
 
-}
\ No newline at end of file
+}
diff --git a/tests/AbstractFactoryTest.php b/tests/AbstractFactoryTest.php
index 7908673..b97f95f 100644
--- a/tests/AbstractFactoryTest.php
+++ b/tests/AbstractFactoryTest.php
@@ -133,4 +133,4 @@ namespace FF\Tests\Factories\Sub {
     {
 
     }
-}
\ No newline at end of file
+}
diff --git a/tests/AbstractSingletonFactoryTest.php b/tests/AbstractSingletonFactoryTest.php
index 04cef83..c78bd88 100644
--- a/tests/AbstractSingletonFactoryTest.php
+++ b/tests/AbstractSingletonFactoryTest.php
@@ -77,4 +77,4 @@ class MySingletonFactory extends AbstractSingletonFactory
 class MySingletonObject
 {
 
-}
\ No newline at end of file
+}
diff --git a/tests/ClassLocators/BaseNamespaceClassLocatorTest.php b/tests/ClassLocators/BaseNamespaceClassLocatorTest.php
index 5527b6b..70ac6fa 100644
--- a/tests/ClassLocators/BaseNamespaceClassLocatorTest.php
+++ b/tests/ClassLocators/BaseNamespaceClassLocatorTest.php
@@ -80,4 +80,4 @@ namespace FF\Tests\Factories\ClassLocators\Sub {
     {
 
     }
-}
\ No newline at end of file
+}
diff --git a/tests/ClassLocators/NamespaceClassLocatorTest.php b/tests/ClassLocators/NamespaceClassLocatorTest.php
index bc80f3c..d083a99 100644
--- a/tests/ClassLocators/NamespaceClassLocatorTest.php
+++ b/tests/ClassLocators/NamespaceClassLocatorTest.php
@@ -115,4 +115,4 @@ namespace FF\Tests\Factories\ClassLocators\Sub {
     {
 
     }
-}
\ No newline at end of file
+}
diff --git a/tests/ClassLocators/NamespacePrefixedClassLocatorTest.php b/tests/ClassLocators/NamespacePrefixedClassLocatorTest.php
index d423349..bb8c887 100644
--- a/tests/ClassLocators/NamespacePrefixedClassLocatorTest.php
+++ b/tests/ClassLocators/NamespacePrefixedClassLocatorTest.php
@@ -92,4 +92,4 @@ namespace FF\Tests\Factories\ClassLocators\Sub\Foo {
     {
 
     }
-}
\ No newline at end of file
+}