-
Notifications
You must be signed in to change notification settings - Fork 129
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
Update for PHPCS 2.x series #109
Conversation
- Try to include some better documentation of differences from core standards to help with current and future PHPCS migration tasks - Remove IncludeFileSniff this is no longer part of the Joomla standard - Replace LineLenghtSniff reference with ruleset.xml definition, LineLenghtSniff is no longer part of the Joomla standard - No need to reference core standard sniffs not included in the joomla/coding-standards, remove reference to ScopeIndentSniff and IncludeFileSniff - Where it is known, specify the standard the joomla/coding-standards are based on - add references to all sniffs that are customized as a Joomla sniff
Better documentation of differences from core standards
if not is...
typo correction
- Based on PEAR/Sniffs/Commenting/InlineCommentSniff
There are existing standards that achieve the same results as the customs sniffs, there is no point in having custom sniffs when an existing standard will suffice (keeps us from having to waste resources on maintaining the custom sniffs too).
- Set Squiz.Strings.ConcatenationSpacing spacing value to 1 - Replaces Joomla.Whitespace.ConcatenationSpacing
- Change Error message in rule set to `No scope modifier specified for function "%s`
- Change Error message in rule set to `No scope modifier specified for function "%s`
Source PEAR/Sniffs/ControlStructures/ControlSignatureSniff
New todo item
|
What's the changelist looking like for 3.x? Depending on scope both could On Thursday, October 13, 2016, Walt Sorensen notifications@github.com
|
@mbabker for PHPCS3.x It again breaks backwards compatibility for all custom sniffs and custom reports. An upgrade guide for sniff and report developers is available here: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Version-3.0-Upgrade-Guide it also has a php 5.4 minimum requirement |
on the upside all of the built in sniffs in the |
Oy vey On Thursday, October 13, 2016, Walt Sorensen notifications@github.com
|
could you add support for:
now its saved to: |
$namespaced is the token ID (an INT), so we need to check the type using $tokens[$namespaced]['code'] and not just $namespaced
Ran a test with this branch on the stats server repo. Build result against PHPCS 2.6.2: https://travis-ci.org/joomla-extensions/jstats-server/jobs/168115206 No other custom changes applied. |
@mbabker Some of those items indicate that the stats server repo needs to run a modified version of the coding standards. It doesn't need to reject short array syntax since it's not supporting php 5.3. The readme has some explanations for adjustments. Here is a modified ruleset.xml similar to the one I've been using to test the cms with since the cms has a number of legacy code style issues that have BC implications if changed. <?xml version="1.0"?>
<ruleset name="Joomla-stats">
<arg name="report" value="full"/>
<arg name="tab-width" value="4"/>
<arg name="encoding" value="utf-8"/>
<arg value="sp"/>
<arg name="colors" />
<!-- Exclude folders not containing production code -->
<exclude-pattern>*/build/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/lib/*</exclude-pattern>
<exclude-pattern>*/tmpl/*</exclude-pattern>
<exclude-pattern>*/layouts/*</exclude-pattern>
<!-- Exclude 3rd party libraries. -->
<exclude-pattern>*/libraries/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/editors/*</exclude-pattern>
<rule ref="Joomla">
<exclude name="Joomla.NamingConventions.ValidVariableName.MemberNotCamelCaps"/>
<exclude name="Joomla.NamingConventions.ValidVariableName.NotCamelCaps"/>
<exclude name="Joomla.NamingConventions.ValidFunctionName.ScopeNotCamelCaps"/>
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
</rule>
<rule ref="Joomla.Classes.InstantiateNewClasses">
<properties>
<property name="shortArraySyntax" value="true"/>
</properties>
</rule>
</ruleset> |
@810 I'm not able to replicate the issue you describe with the current version of the standard and phpcs 2.7.0. That also looks like mixed php/html code for a layout/view file. At the moment I'm not sure if we are going to test against those mixed code layout files. In my testing, I intentionally exclude files with mixed php/html code |
Can we merge this pr to new branch, then do a release |
@mbabker what are your thoughts on merging this and preparing for an alpha release? These are the items I still had listed to be addressed
|
We need a plan to communicate this because we WILL break people's stuff going through with this. The current master branch should become a 1.x branch. The phpcs-2 branch should become the master branch. Once that's done, we add the package to Packagist. |
We can't use phpcs-2 now: because jorobo still needs edgedesign/phpqa and that package is only for 1.x |
That package declares Nothing says that every consumer of this repo has to update to PHPCS 2.x as soon as it's merged into this repo. The 1.x compatible sniffer will still be available, you would just need to update the git submodule references to use the appropriate branch since the current definition isn't on Packagist (though we may want to look at if we can make 1.x Composer installable since merging the efforts in this PR will put the whole repo into Packagist). |
According to the travis testing of EdgedesignCZ/phpqa they are testing with phpcs 2.7.1 so there shouldn't be an issue... of course that package has nothing to do with the efforts in this repo. Even jorobo is using a PHPCS 2.x coding standard that was based on this PR... of course that package also has nothing to do with the efforts in this repo. |
I'll throw a post together to run on the dev site announcing the need for the branch change and the new Composer integration so we can get the branches sorted out right. That'll give a couple weeks for anyone who might be pulling the repo to update resources (we can do a 1.x branch and keep it in sync with current master for a short transition period before merging phpcs-2 to master). If I remember, I'll do a once over here and merge over the weekend. |
Sounds good. Let me know what to do about the 5 items listed above. Maybe we open new PR's and/or issues related to those items after this PR is merged into the phpcs-2 branch... |
Return type for magic method in DatabaseQuery is mixed
Reference issue #53
Reference issue #104
Reorder ruleset.xml to better match the Squiz/ruleset.xml
This improves readability when migrating versions
Also increased the max line the comment to 150 chars long since it was that way in the code
The T_DOC_COMMENT token has also been removed, replaced instead by T_DOC_COMMENT_OPEN_TAG
rebuild from source with modifications
-- by adding a comment about what was intentionally removed we will help the coding standard be able to make changes quicker when the source standard changes or has bug fixes applied.
Update rules to use source standards to eliminate unnecessary duplication
add Squiz.WhiteSpace.CastSpacingSniff rule so duplication can be eliminated.
add Generic.WhiteSpace.DisallowSpaceIndentSniff rule
nothing special here, replace with generic rule
nothing special here, replace with Squiz rule
nothing special here, replace with Squiz rule
nothing special here, replace with PEAR rule
Add PSR2.ControlStructures.ElseIfDeclaration rule
note: Sniff is not part of the rule names just the file names
copy PR #106 Better documentation of differences from core standards
Note: this will be composer compatible
For consuming packages there are some items that will typically result in creating their own project
ruleset.xml
, rather than just directly using the Joomla ruleset.xml.Generic.Arrays.DisallowShortArraySyntax
because the consuming package does not support PHP5.3Joomla.NamingConventions.ValidVariableName.NotCamelCaps
because the consuming package is supporting snake_case variable names for backwards compatibility reasons or because they are supporting legacy database schemas that used sname_case naming.ruleset.xml
is easier to maintain and is easy to implement with other modifications.Details on using a project
ruleset.xml
can be found in the PHP Code Sniffer Documentation