forked from mediact/coding-standard-magento2
-
Notifications
You must be signed in to change notification settings - Fork 3
Added magento/magento-coding-standard to keep closer to Magento standards #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4dd8363
Update branding in documentation
d25d771
Rename Magento2 coding standard to YouweMagento2
9371055
Remove deprecated standards
cac15ca
Import official Magento2 coding standard
7149206
Avoid unbounded version constraints where possible
d8ef3ff
composer normalize
f243571
Correct minimum version of upstream standard
4af2e56
Merge pull request #2 from fredden/youwe-magento2
leonhelmus 094be80
Update command which needs to be run otherwise Youwe & YouweMagento2 …
l-helmus-youwe 061f546
Added magento/magento-coding-standard to keep closer to Magento stand…
l-helmus-youwe 549d192
Updated changelog.
l-helmus-youwe 5293cfb
Automatically update/set installed_paths for phpcs
3e833fa
Merge pull request #4 from YouweGit/phpcs-installed_paths
leonhelmus a1e845f
Merge remote-tracking branch 'origin/youwe-magento2' into youwe-magento2
l-helmus-youwe 5c29465
Type needs to be changed for dealerdirect/phpcodesniffer-composer-ins…
l-helmus-youwe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
{ | ||
"name": "youwe/coding-standard-magento2", | ||
"description": "Youwe PHP Coding Standard for Magento2", | ||
"type": "phpcs-sniffs", | ||
"homepage": "https://github.com/YouweGit/coding-standard-magento2", | ||
"license": "proprietary", | ||
"type": "phpcodesniffer-standard", | ||
"authors": [ | ||
{ | ||
"name": "Youwe B.V.", | ||
"email": "info@youweagency.com" | ||
} | ||
], | ||
"homepage": "https://github.com/YouweGit/coding-standard-magento2", | ||
"require": { | ||
"youwe/coding-standard": ">=3.3.0" | ||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", | ||
"magento/magento-coding-standard": ">= 9", | ||
"youwe/coding-standard": "^3.5.0" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"MediactMagento2": "src/MediactMagento2", | ||
"Magento2": "src/Magento2" | ||
"YouweMagento2": "src/YouweMagento2" | ||
} | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true | ||
}, | ||
"sort-packages": true | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright Youwe. All rights reserved. | ||
* https://www.youweagency.com | ||
* | ||
* TODO:: Create a separate ruleset for phtml files, since a lot of exceptions need to be made just for adding phtml to code sniffer. | ||
*/ | ||
--> | ||
<ruleset name="YouweMagento2"> | ||
<description>Youwe coding standards for Magento2 websites and modules</description> | ||
<!-- TODO:: Check if these values are correct. Did not see anything about how to configure this in documentation --> | ||
<arg name="extensions" value="php/PHP,phtml/PHP,js/JS,css/CSS,xml/XML,less/CSS" /> | ||
|
||
<!-- Base rules on Youwe --> | ||
<rule ref="Youwe"> | ||
<!-- Magento 2 does not use return types everywhere in the code base yet. So we cannot make this mandatory. --> | ||
<exclude name="GlobalCommon.Php7.ReturnType" /> | ||
<!-- Magento 2 still uses $_ to tell if it's protected, so we cannot mandate this. --> | ||
<exclude name="GlobalCommon.NamingConventions.ValidVariableName" /> | ||
<!-- TODO:: Check if this rule still needs to be excluded. Seems logical that all classes should start with camelcase --> | ||
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" /> | ||
<!--TODO:: Check if this should not be excluded. Seems logical to add throws in function comment. --> | ||
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows" /> | ||
<!-- Magento 2 still does not strict type arguments of functions. This is why this rule is excluded. --> | ||
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing" /> | ||
<!-- Magento 2 still does not strict type arguments of functions. This is why this rule is excluded. --> | ||
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing" /> | ||
</rule> | ||
|
||
<!-- Import most rules from official Magento2 coding standard --> | ||
<rule ref="Magento2"> | ||
<!-- Excluded because short descriptions are not mandatory in Youwe for a method. --> | ||
<exclude name="Magento2.Annotation" /> | ||
<!-- | ||
Excluded because in PHP 8.1 it's already possible to declare what type it is. | ||
Also most class properties are self-explanatory. | ||
--> | ||
<exclude name="Magento2.Commenting.ClassPropertyPHPDocFormatting" /> | ||
</rule> | ||
|
||
<!-- Detects function that use a for-loops call in their function. --> | ||
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed"> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="Generic.Commenting.DocComment"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="Generic.ControlStructures.InlineControlStructure.NotAllowed"> | ||
<!-- Magento 2 templates do not cohere to this rule. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="Generic.Files.LineLength.TooLong"> | ||
<!-- Magento 2 phtml & xml both have long lines think of checkout_index_index.xml --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
<exclude-pattern>*.xml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="PEAR.Functions.FunctionCallSignature"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore"> | ||
<!-- In some cases Magento 2 still uses underscores for their properties. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="PSR2.ControlStructures.ControlStructureSpacing"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="PSR12.ControlStructures.ControlStructureSpacing"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="PSR12.Files.FileHeader.SpacingAfterBlock"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="PSR12.Operators.OperatorSpacing"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="Squiz.ControlStructures.ControlSignature"> | ||
<!-- Magento 2 uses a different notation for patterns like do { / if { for phtml that's why this was excluded. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="Squiz.WhiteSpace.MemberVarSpacing" > | ||
<properties> | ||
<property name="spacingBeforeFirst" value="0"/> | ||
</properties> | ||
</rule> | ||
|
||
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace"> | ||
<!-- Magento 2 phptml files end differently and use endif; for example. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
</ruleset> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking, but maybe a good idea to change this to a different license in the future as the code is open source and not proprietary.