Skip to content

Commit 641222f

Browse files
authored
Merge pull request #19 from php-fig-rectified/php7
1.0.0 prep - PHP7.2+
2 parents 3052ce7 + c536b61 commit 641222f

File tree

65 files changed

+447
-1259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+447
-1259
lines changed

.editorconfig

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
; This file is for unifying the coding style for different editors and IDEs.
2-
; More information at http://editorconfig.org
3-
2+
; More information at https://editorconfig.org
43
root = true
54

65
[*]
@@ -16,6 +15,3 @@ end_of_line = crlf
1615
[*.yml]
1716
indent_style = space
1817
indent_size = 2
19-
20-
[*.neon]
21-
indent_style = space

.gitattributes

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
# Define the line ending behavior of the different file extensions
2-
# Set default behaviour, in case users don't have core.autocrlf set.
3-
* text=auto
4-
* text eol=lf
5-
6-
# Explicitly declare text files we want to always be normalized and converted
7-
# to native line endings on checkout.
8-
*.php text
9-
*.txt text
10-
*.xml text
11-
*.yml text
12-
.htaccess text
2+
# Set default behavior, in case users don't have core.autocrlf set.
3+
* text text=auto eol=lf
134

145
# Declare files that will always have CRLF line endings on checkout.
156
*.bat eol=crlf
@@ -18,4 +9,14 @@
189
*.pem eol=lf
1910

2011
# Denote all files that are truly binary and should not be modified.
12+
*.jpg binary
13+
*.png binary
2114
*.phar binary
15+
16+
# Remove files for archives generated using `git archive`
17+
phpunit.xml.dist export-ignore
18+
.travis.yml export-ignore
19+
.gitignore export-ignore
20+
.gitattributes export-ignore
21+
.editorconfig export-ignore
22+
tests/ export-ignore

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
/vendor/*
1+
/vendor/
22
/phpunit.phar
3-
.phpunit.result.cache
3+
/.phpunit.result.cache
44
/composer.phar
55
/composer.lock
6-
.idea
7-
clover.xml
6+
/.idea/
7+
/clover.xml

.travis.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
language: php
22

3-
sudo: false
4-
53
php:
6-
- 5.6
7-
- 7.3
8-
- 7.4snapshot
4+
- 7.2
5+
- 7.4
96

107
env:
118
global:
129
- DEFAULT=1
1310

1411
matrix:
1512
include:
16-
- php: 7.2
13+
- php: 7.3
1714
env: CHECKS=1 DEFAULT=0
1815

1916
fast_finish: true
@@ -22,7 +19,7 @@ before_script:
2219
- composer install --prefer-dist --no-interaction
2320

2421
script:
25-
- if [[ $CHECKS == 1 ]]; then composer phpstan-setup && composer phpstan ; fi
22+
- if [[ $CHECKS == 1 ]]; then composer stan ; fi
2623
- composer cs-check
2724

2825
notifications:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Mark Scherer
3+
Copyright (c) 2016-present Mark Scherer
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

PSR2R/Sniffs/Classes/ClassCreateInstanceSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function process(File $phpcsFile, $stackPtr) {
3434
// We can only invoke the fixer if we know this is a static constructor function call.
3535
if ($tokens[$constructorIndex]['code'] !== T_STRING && $tokens[$constructorIndex]['code'] !== T_NS_SEPARATOR) {
3636
$phpcsFile->addError($error, $stackPtr, 'ParenthesisMissing');
37+
3738
return;
3839
}
3940

PSR2R/Sniffs/Classes/ClassFileNameSniff.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
/**
33
* Squiz_Sniffs_Classes_ClassFileNameSniff.
44
*
5-
* PHP version 5
6-
*
7-
* @category PHP
8-
* @package PHP_CodeSniffer
9-
* @author Greg Sherwood <gsherwood@squiz.net>
10-
* @author Marc McIntyre <mmcintyre@squiz.net>
5+
* @package PHP_CodeSniffer
6+
* @author Greg Sherwood <gsherwood@squiz.net>
7+
* @author Marc McIntyre <mmcintyre@squiz.net>
118
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12-
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13-
* @link http://pear.php.net/package/PHP_CodeSniffer
9+
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
10+
* @link http://pear.php.net/package/PHP_CodeSniffer
1411
*/
1512

1613
namespace PSR2R\Sniffs\Classes;
@@ -24,12 +21,12 @@
2421
* Tests that the file name and the name of the class contained within the file
2522
* match.
2623
*
27-
* @author Greg Sherwood <gsherwood@squiz.net>
28-
* @author Marc McIntyre <mmcintyre@squiz.net>
24+
* @author Greg Sherwood <gsherwood@squiz.net>
25+
* @author Marc McIntyre <mmcintyre@squiz.net>
2926
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
30-
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
31-
* @version Release: @package_version@
32-
* @link http://pear.php.net/package/PHP_CodeSniffer
27+
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
28+
* @version Release: @package_version@
29+
* @link http://pear.php.net/package/PHP_CodeSniffer
3330
*/
3431
class ClassFileNameSniff extends AbstractSniff {
3532

PSR2R/Sniffs/Classes/PropertyDeclarationSniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
/**
1010
* Verifies that properties are declared correctly.
1111
*
12-
* @author Greg Sherwood <gsherwood@squiz.net>
12+
* @author Greg Sherwood <gsherwood@squiz.net>
1313
* @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
14-
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14+
* @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
1515
*
16-
* @version Release: @package_version@
16+
* @version Release: @package_version@
1717
*
18-
* @link http://pear.php.net/package/PHP_CodeSniffer
18+
* @link http://pear.php.net/package/PHP_CodeSniffer
1919
*/
2020
class PropertyDeclarationSniff extends AbstractVariableSniff {
2121

PSR2R/Sniffs/Classes/SelfAccessorSniff.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function process(File $phpcsFile, $stackPtr) {
3131

3232
if ($tokens[$stackPtr]['code'] === T_SELF) {
3333
$this->checkSelf($phpcsFile, $stackPtr);
34+
3435
return;
3536
}
3637

@@ -50,11 +51,13 @@ public function process(File $phpcsFile, $stackPtr) {
5051
for ($i = $startIndex + 1; $i < $endIndex; $i++) {
5152
if ($tokens[$i]['code'] === T_NEW) {
5253
$this->checkNew($phpcsFile, $i, $name);
54+
5355
continue;
5456
}
5557

5658
if ($tokens[$i]['code'] === T_DOUBLE_COLON) {
5759
$this->checkDoubleColon($phpcsFile, $i, $name);
60+
5861
continue;
5962
}
6063
}
@@ -63,6 +66,7 @@ public function process(File $phpcsFile, $stackPtr) {
6366
/**
6467
* @param \PHP_CodeSniffer\Files\File $phpcsFile
6568
* @param int $stackPtr
69+
*
6670
* @return void
6771
*/
6872
protected function checkSelf(File $phpcsFile, $stackPtr) {
@@ -83,6 +87,7 @@ protected function checkSelf(File $phpcsFile, $stackPtr) {
8387
* @param \PHP_CodeSniffer\Files\File $phpcsFile
8488
* @param int $i
8589
* @param string $name
90+
*
8691
* @return void
8792
*/
8893
protected function checkNew(File $phpcsFile, $i, $name) {
@@ -104,6 +109,7 @@ protected function checkNew(File $phpcsFile, $i, $name) {
104109
* @param \PHP_CodeSniffer\Files\File $phpcsFile
105110
* @param int $index
106111
* @param string $name
112+
*
107113
* @return void
108114
*/
109115
protected function fixNameToSelf(File $phpcsFile, $index, $name) {
@@ -125,6 +131,7 @@ protected function fixNameToSelf(File $phpcsFile, $index, $name) {
125131
* @param \PHP_CodeSniffer\Files\File $phpcsFile
126132
* @param int $i
127133
* @param string $name
134+
*
128135
* @return void
129136
*/
130137
protected function checkDoubleColon(File $phpcsFile, $i, $name) {

PSR2R/Sniffs/Commenting/DocBlockParamAllowDefaultValueSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public function process(File $phpCsFile, $stackPointer) {
6666

6767
if ($tokens[$classNameIndex]['type'] !== 'T_DOC_COMMENT_STRING') {
6868
$phpCsFile->addError('Missing type in param doc block', $i, 'CommentAllowDefault');
69+
6970
continue;
7071
}
7172

PSR2R/Sniffs/Commenting/DocBlockParamSniff.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function process(File $phpCsFile, $stackPointer) {
6363

6464
if ($tokens[$classNameIndex]['type'] !== 'T_DOC_COMMENT_STRING') {
6565
$phpCsFile->addError('Missing type in param doc block', $i, 'MissingParamType');
66+
6667
continue;
6768
}
6869

@@ -89,6 +90,7 @@ public function process(File $phpCsFile, $stackPointer) {
8990

9091
if (count($docBlockParams) !== count($methodSignature)) {
9192
$phpCsFile->addError('Doc Block params do not match method signature', $stackPointer, 'ParamTypeMismatch');
93+
9294
return;
9395
}
9496

@@ -129,6 +131,7 @@ public function process(File $phpCsFile, $stackPointer) {
129131
*
130132
* @param \PHP_CodeSniffer\Files\File $phpCsFile
131133
* @param int $stackPtr
134+
*
132135
* @return array
133136
*/
134137
private function getMethodSignature(File $phpCsFile, $stackPtr) {

PSR2R/Sniffs/Commenting/DocBlockReturnTagSniff.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function __construct() {
2525
/**
2626
* @param \PHP_CodeSniffer\Files\File $phpcsFile
2727
* @param int $stackPtr
28+
*
2829
* @return void
2930
*/
3031
protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) {
@@ -69,6 +70,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop
6970
// '@return' is separate token from return value
7071
if (strpos($currentComment, '@return') !== false) {
7172
$commentWithReturn = $i;
73+
7274
break;
7375
}
7476
}
@@ -87,11 +89,13 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop
8789
if (!$commentWithReturn && !$haveInheritDoc) {
8890
$error = 'Missing @return tag in function comment';
8991
$phpcsFile->addError($error, $stackPtr, 'Missing');
92+
9093
return;
9194
}
9295
if ($commentWithReturn && $haveInheritDoc) {
9396
$error = 'Should not have both @inheritDoc and @return in function comment';
9497
$phpcsFile->addError($error, $stackPtr, 'RedundantReturn');
98+
9599
return;
96100
}
97101

@@ -102,6 +106,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop
102106
if ($phpcsFile->fixer->enabled === true) {
103107
$phpcsFile->fixer->replaceToken($commentWithReturn, '');
104108
}
109+
105110
return;
106111
}
107112
}

PSR2R/Sniffs/Commenting/DocBlockReturnVoidSniff.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function process(File $phpcsFile, $stackPtr) {
3434
$nextIndex = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true);
3535
if ($tokens[$nextIndex]['content'] === '__construct' || $tokens[$nextIndex]['content'] === '__destruct') {
3636
$this->checkConstructorAndDestructor($phpcsFile, $nextIndex);
37+
3738
return;
3839
}
3940

@@ -60,6 +61,7 @@ public function process(File $phpcsFile, $stackPtr) {
6061
$phpcsFile->addError('Method does not have a return statement in doc block: ' .
6162
$tokens[$nextIndex]['content'], $nextIndex, 'NoReturnDoc1');
6263
}
64+
6365
return;
6466
}
6567

@@ -73,6 +75,7 @@ public function process(File $phpcsFile, $stackPtr) {
7375
if ($returnType === null) {
7476
$phpcsFile->addError('Method does not have a return statement in doc block: ' .
7577
$tokens[$nextIndex]['content'], $nextIndex, 'NoReturnDoc2');
78+
7679
return;
7780
}
7881

@@ -88,6 +91,7 @@ public function process(File $phpcsFile, $stackPtr) {
8891
/**
8992
* @param \PHP_CodeSniffer\Files\File $phpcsFile
9093
* @param int $index
94+
*
9195
* @return void
9296
*/
9397
protected function checkConstructorAndDestructor(File $phpcsFile, $index) {
@@ -162,6 +166,7 @@ protected function detectReturnTypeVoid(File $phpcsFile, $index) {
162166
if ($this->isGivenKind([T_FUNCTION], $tokens[$i])) {
163167
$endIndex = $tokens[$i]['scope_closer'];
164168
$i = $endIndex;
169+
165170
continue;
166171
}
167172

PSR2R/Sniffs/Commenting/DocBlockShortTypeSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Use short types for boolean and integer in doc blocks.
1010
*
11-
* @author Mark Scherer
11+
* @author Mark Scherer
1212
* @license MIT
1313
*/
1414
class DocBlockShortTypeSniff extends AbstractSniff {

PSR2R/Sniffs/Commenting/DocBlockSniff.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function process(File $phpcsFile, $stackPtr) {
3333
$nextIndex = $phpcsFile->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true);
3434
if ($tokens[$nextIndex]['content'] === '__construct' || $tokens[$nextIndex]['content'] === '__destruct') {
3535
$this->checkConstructorAndDestructor($phpcsFile, $nextIndex);
36+
3637
return;
3738
}
3839

@@ -51,6 +52,7 @@ public function process(File $phpcsFile, $stackPtr) {
5152
$returnType = $this->detectReturnTypeVoid($phpcsFile, $stackPtr);
5253
if ($returnType === null) {
5354
$phpcsFile->addError('Method does not have a doc block: ' . $tokens[$nextIndex]['content'] . '()', $nextIndex, 'DocBlockMissing');
55+
5456
return;
5557
}
5658

@@ -155,6 +157,7 @@ protected function detectReturnTypeVoid(File $phpcsFile, $index) {
155157
if ($this->isGivenKind([T_FUNCTION], $tokens[$i])) {
156158
$endIndex = $tokens[$i]['scope_closer'];
157159
$i = $endIndex;
160+
158161
continue;
159162
}
160163

PSR2R/Sniffs/Commenting/DocBlockTagTypesSniff.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Verifies that only whitelisted `@...` tags are being used.
1010
*
11-
* @author Mark Scherer
11+
* @author Mark Scherer
1212
* @license MIT
1313
*/
1414
class DocBlockTagTypesSniff extends AbstractSniff {
@@ -135,6 +135,7 @@ public function process(File $phpcsFile, $stackPtr) {
135135
$error = 'Unexpected tag type `' . $tokens[$i]['content'] . '` in doc block';
136136
if (!array_key_exists($content, static::$mapping) && !in_array($content, static::$blacklistedTags, true)) {
137137
$phpcsFile->addWarning($error, $i, 'Unknown');
138+
138139
continue;
139140
}
140141

@@ -149,13 +150,15 @@ public function process(File $phpcsFile, $stackPtr) {
149150
$phpcsFile->findNext([T_DOC_COMMENT_STAR, T_DOC_COMMENT_CLOSE_TAG], $i + 1, $docBlockEndIndex + 1);
150151
if (!$prevAsterix || !$nextAsterix) {
151152
$phpcsFile->addError($error, $i, 'Invalid');
153+
152154
continue;
153155
}
154156

155157
$phpcsFile->addFixableError($error, $i, 'Invalid');
156158
if ($phpcsFile->fixer->enabled) {
157159
if ($mappingTag) {
158160
$phpcsFile->fixer->replaceToken($i, $mappingTag);
161+
159162
continue;
160163
}
161164

0 commit comments

Comments
 (0)