Skip to content

Commit 07acf2a

Browse files
committed
Merge branch 'master' into report-memory-improvements
2 parents e240bf7 + 20aa783 commit 07acf2a

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,16 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
114114
protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $lineContent)
115115
{
116116
// If the content is a CVS or SVN id in a version tag, or it is
117-
// a license tag with a name and URL, there is nothing the
118-
// developer can do to shorten the line, so don't throw errors.
119-
if (preg_match('|@version[^\$]+\$Id|', $lineContent) !== 0) {
120-
return;
121-
}
122-
123-
if (preg_match('|@license|', $lineContent) !== 0) {
117+
// a license tag with a name and URL, or it is an SVN URL, there
118+
// is nothing the developer can do to shorten the line,
119+
// so don't throw errors.
120+
$regex = '~@license|@version[^\$]+\$Id|\$(Head)?URL[:\$]~';
121+
if (preg_match($regex, $lineContent) !== 0) {
124122
return;
125123
}
126124

127125
if (PHP_CODESNIFFER_ENCODING !== 'iso-8859-1') {
128-
// Not using the detault encoding, so take a bit more care.
126+
// Not using the default encoding, so take a bit more care.
129127
$lineLength = iconv_strlen($lineContent, PHP_CODESNIFFER_ENCODING);
130128
if ($lineLength === false) {
131129
// String contained invalid characters, so revert to default.

CodeSniffer/Standards/Generic/Tests/Files/LineLengthUnitTest.inc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,25 @@ echo 'hi';
4444
<?php
4545
/**
4646
* Comments contining CVS IDs can be long, but should be ignored because
47-
* they cannot be changed by the developer. Same with license URLs.
47+
* they cannot be changed by the developer. Same with license URLs. Also
48+
* and URL/HeadURL in subversion.
4849
*
4950
* @license http://www.freebsd.org/copyright/freebsd-license.html BSD License (2 Clause)
51+
*
52+
* $URL: file/paths/in/subversion/are/prefixed/by/URL/or/HeadURL/and/can/be/very/long/especially/if/they/are/in/a/branch $
53+
* $HeadURL: https://svn.example.org/file/paths/in/subversion/are/prefixed/by/URL/or/HeadURL/and/can/be/very/long/especially/if/they/are/in/a/branch $
5054
*/
55+
56+
// $URL: file/paths/in/subversion/are/prefixed/by/URL/or/HeadURL/and/can/be/very/long/especially/if/they/are/in/a/branch $
57+
// $HeadURL: https://svn.example.org/file/paths/in/subversion/are/prefixed/by/URL/or/HeadURL/and/can/be/very/long/especially/if/they/are/in/a/branch $
58+
59+
echo '$URL: file/paths/in/subversion/are/prefixed/by/URL/or/HeadURL/and/can/be/very/long/especially/if/they/are/in/a/branch $';
60+
echo '$HeadURL: https://svn.example.org/file/paths/in/subversion/are/prefixed/by/URL/or/HeadURL/and/can/be/very/long/especially/if/they/are/in/a/branch $'
61+
5162
?>
5263

64+
* $URL: file/paths/in/subversion/are/prefixed/by/URL/or/HeadURL/and/can/be/very/long/especially/if/they/are/in/a/branch $
65+
* $HeadURL: https://svn.example.org/file/paths/in/subversion/are/prefixed/by/URL/or/HeadURL/and/can/be/very/long/especially/if/they/are/in/a/branch $
66+
5367
<?php
5468
// This is another really long comment that is going to go well over 100 characters, with no closing php tag after it.

CodeSniffer/Standards/Generic/Tests/Files/LineLengthUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function getErrorList()
4545
return array(
4646
31 => 1,
4747
34 => 1,
48-
54 => 1,
48+
68 => 1,
4949
);
5050

5151
}//end getErrorList()

CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $sta
6464

6565
$modifier = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, $stackPtr);
6666
if (($modifier === false) || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line'])) {
67-
$error = 'No scope modifier specified for function "%s"';
67+
$error = 'Visibility must be declared on method "%s"';
6868
$data = array($methodName);
6969
$phpcsFile->addError($error, $stackPtr, 'Missing', $data);
7070
}

package.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
4141
- Added Squiz DisallowBooleanStatementSniff to ban boolean operators outside of control structure conditions
4242
- Coding standard ignore comments can now appear instead doc blocks as well as inline comments
4343
-- Thanks to Stuart Langley for the patch
44+
- Generic LineLengthSniff now ignores SVN URL and Head URL comments
45+
-- Thanks to Karl DeBisschop for the patch
4446
- PEAR MultiLineConditionSniff now has a setting to specify how many spaces code should be indented
4547
-- Default remains at 4; override the 'indent' setting in a ruleset.xml file to change
4648
-- Thanks to Szabolcs Sulik for the patch
@@ -62,6 +64,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
6264
- Squiz ClassFileNameSniff no longer throws errors when checking STDIN
6365
- Squiz CSS sniffs no longer generate errors for IE filters
6466
- Squiz LogicalOperatorSpacingSniff now ignores whitespace at the end of a line
67+
- Squiz.Scope.MethodScope.Missing error message now mentions 'visibility' instead of 'scope modifier'
68+
-- Thanks to Renat Akhmedyanov for the patch
6569
- The PSR2 standard no longer throws errors for additional spacing after a type hint
6670
- Fixed cases where code was incorrectly assigned the T_GOTO_LABEL token when used in a complex CASE condition
6771
- Fixed bug #20026 : Check for multi-line arrays that should be single-line is slightly wrong

0 commit comments

Comments
 (0)