diff --git a/Extdn/Samples/Blocks/DeprecatedFormContainerParent.php b/Extdn/Samples/Blocks/DeprecatedFormContainerParent.php new file mode 100644 index 0000000..f5c812c --- /dev/null +++ b/Extdn/Samples/Blocks/DeprecatedFormContainerParent.php @@ -0,0 +1,6 @@ +getFilename()); + + $class = Reflection::getClass($className); + $parentClass = $class->getParentClass(); + + foreach ($this->getDeprecatedClasses() as $deprecatedClass) { + if ($parentClass->getName() !== $deprecatedClass['class']) { + continue; + } + + $warning = sprintf('Block parent "%s" is deprecated. %s', $deprecatedClass['class'], $deprecatedClass['advice']); + $phpcsFile->addWarning($warning, null, 'deprecated-parent'); + } + } + + /** + * @return array + */ + private function getDeprecatedClasses(): array + { + $url = 'https://github.com/extdn/extdn-phpcs/blob/master/Extdn/Sniffs/Blocks/DeprecatedParentsSniff.md'; + + return [ + [ + 'class' => 'Magento\Backend\Block\Widget\Form\Generic', + 'advice' => 'See '.$url + ], + [ + 'class' => 'Magento\Backend\Block\Widget\Grid\Container', + 'advice' => 'See '.$url + ] + ]; + } +} diff --git a/Extdn/ruleset.xml b/Extdn/ruleset.xml index 9490b4b..3a5c85e 100644 --- a/Extdn/ruleset.xml +++ b/Extdn/ruleset.xml @@ -7,6 +7,8 @@ *.php + +