From fdf72430df177ed313f52de167aa40349c7f46cb Mon Sep 17 00:00:00 2001 From: Dusan Lukic Date: Tue, 23 Apr 2019 17:27:06 +0200 Subject: [PATCH] Removed class exists checks and added exclude patterns --- Magento2/Sniffs/PHP/LiteralNamespacesSniff.php | 18 +----------------- Magento2/ruleset.xml | 4 ++++ 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Magento2/Sniffs/PHP/LiteralNamespacesSniff.php b/Magento2/Sniffs/PHP/LiteralNamespacesSniff.php index 7b9c85ac..705e154b 100644 --- a/Magento2/Sniffs/PHP/LiteralNamespacesSniff.php +++ b/Magento2/Sniffs/PHP/LiteralNamespacesSniff.php @@ -52,7 +52,7 @@ public function process(File $sourceFile, $stackPtr) $content = preg_replace('|\\\{2,}|', '\\', $content); } - if (preg_match($this->literalNamespacePattern, $content) === 1 && $this->classExists($content)) { + if (preg_match($this->literalNamespacePattern, $content) === 1) { $sourceFile->addWarning( "Use ::class notation instead.", $stackPtr, @@ -60,20 +60,4 @@ public function process(File $sourceFile, $stackPtr) ); } } - - /** - * Checks if class or interface exists. - * - * ToDo: get rig of this check https://github.com/magento/magento-coding-standard/issues/9 - * - * @param string $className - * @return bool - */ - private function classExists($className) - { - if (!isset($this->classNames[$className])) { - $this->classNames[$className] = class_exists($className) || interface_exists($className); - } - return $this->classNames[$className]; - } } diff --git a/Magento2/ruleset.xml b/Magento2/ruleset.xml index 999b6f20..91aa12fb 100644 --- a/Magento2/ruleset.xml +++ b/Magento2/ruleset.xml @@ -245,6 +245,10 @@ 7 warning + */_files/* + */Fixtures/* + */Test/* + *Test.php 7