File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
dev/tests/static/framework/Magento/MessDetector Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <ruleset name =" Magento Specific Design Rules"
3
+ xmlns =" http://pmd.sf.net/ruleset/1.0.0"
4
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
5
+ xsi : schemaLocation =" http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6
+ xsi : noNamespaceSchemaLocation =" http://pmd.sf.net/ruleset_xml_schema.xsd" >
7
+ <rule name =" FinalImplementation"
8
+ class =" Magento\MessDetector\Rule\Design\FinalImplementation"
9
+ message = " The {0} {1} declared as final." >
10
+ <description >
11
+ <![CDATA[
12
+ Final keyword is prohibited in Magento as this decreases extensibility and customizability.
13
+ Final classes and method are not compatible with plugins and proxies.
14
+ ]]>
15
+ </description >
16
+ <priority >1</priority >
17
+ <properties />
18
+ <example >
19
+ <![CDATA[
20
+ final class Foo
21
+ {
22
+ public function bar() {}
23
+ }
24
+ class Baz {
25
+ final public function bad() {}
26
+ }
27
+ ]]>
28
+ </example >
29
+ </rule >
30
+ </ruleset >
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2013-2017 Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ namespace Magento \MessDetector \Rule \Design ;
8
+
9
+ use PHPMD \AbstractNode ;
10
+ use PHPMD \AbstractRule ;
11
+ use PHPMD \Rule \ClassAware ;
12
+ use PHPMD \Rule \MethodAware ;
13
+
14
+ /**
15
+ * Magento is a highly extensible and customizable platform.
16
+ * Usage of final classes and methods is prohibited.
17
+ */
18
+ class FinalImplementation extends AbstractRule implements ClassAware, MethodAware
19
+ {
20
+
21
+ /**
22
+ * @inheritdoc
23
+ */
24
+ public function apply (AbstractNode $ node )
25
+ {
26
+ if ($ node ->isFinal ()) {
27
+ $ this ->addViolation ($ node , [$ node ->getType (), $ node ->getFullQualifiedName ()]);
28
+ }
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments