Skip to content

Commit f2e6273

Browse files
committed
Merge master.
2 parents b8665d7 + 7eb462b commit f2e6273

39 files changed

+787
-473
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ end_of_line = crlf
1616
[*.yml]
1717
indent_style = space
1818
indent_size = 2
19+
20+
[*.neon]
21+
indent_style = space

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/vendor/*
22
/phpunit.phar
3+
.phpunit.result.cache
34
/composer.phar
45
/composer.lock
5-
/.idea
6+
.idea
67
clover.xml
7-
/composer.lock

.travis.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,31 @@ language: php
33
sudo: false
44

55
php:
6-
- 5.4
7-
- 5.5
86
- 5.6
7+
- 7.3
8+
- 7.4snapshot
9+
10+
env:
11+
global:
12+
- CHECKS=1
913

1014
matrix:
1115
include:
12-
- php: 7.0
13-
env: PHPCS=1 DEFAULT=0
16+
- php: 7.2
17+
env: CHECKS=1 DEFAULT=0
1418

1519
fast_finish: true
1620

1721
before_script:
18-
- composer self-update
1922
- composer install --prefer-dist --no-interaction
2023

21-
script:
22-
- sh -c "if [ '$DEFAULT' = '1' ]; then phpunit; fi"
24+
- if [[ $CHECKS != 1 ]]; then composer require --dev phpunit/phpunit:"^6.0"; fi
2325

24-
- sh -c "if [ '$COVERALLS' = '1' ]; then phpunit --coverage-clover build/logs/clover.xml; fi"
25-
- sh -c "if [ '$COVERALLS' = '1' ]; then vendor/bin/coveralls -c .coveralls.yml -v; fi"
26+
script:
27+
- if [[ $DEFAULT == 1 ]]; then vendor/bin/phpunit; fi
2628

27-
- sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -p --extensions=php --standard=PSR2R/ruleset.xml --ignore=vendor/,tests/files/,*.inc,*.fixed . ; fi"
29+
- if [[ $CHECKS == 1 ]]; then composer phpstan-setup && composer phpstan ; fi
30+
- if [[ $CHECKS == 1 ]]; then composer cs-check ; fi
2831

2932
notifications:
3033
email: false

PSR2R/Sniffs/Commenting/DocBlockEndingSniff.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
*/
1515
class DocBlockEndingSniff implements Sniff {
1616

17+
/**
18+
* @inheritDoc
19+
*/
20+
public function register() {
21+
return Tokens::$commentTokens;
22+
}
23+
1724
/**
1825
* @inheritDoc
1926
*/
@@ -65,7 +72,7 @@ public function process(File $phpcsFile, $stackPtr) {
6572
foreach ($comments as $commentPointer) {
6673
// Check the spacing after each asterisk.
6774
$content = $tokens[$commentPointer]['content'];
68-
/* @noinspection SubStrUsedAsArrayAccessInspection */
75+
/** @noinspection SubStrUsedAsArrayAccessInspection */
6976
$firstChar = substr($content, 0, 1);
7077
$lastChar = substr($content, -1);
7178
if ($firstChar === '/' || $lastChar !== '/') {
@@ -88,11 +95,4 @@ public function process(File $phpcsFile, $stackPtr) {
8895
}
8996
}
9097

91-
/**
92-
* @inheritDoc
93-
*/
94-
public function register() {
95-
return Tokens::$commentTokens;
96-
}
97-
9898
}

PSR2R/Sniffs/Commenting/DocBlockParamAllowDefaultValueSniff.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ class DocBlockParamAllowDefaultValueSniff extends AbstractSniff {
1919
use CommentingTrait;
2020
use SignatureTrait;
2121

22+
/**
23+
* @inheritDoc
24+
*/
25+
public function register() {
26+
return [
27+
T_FUNCTION,
28+
];
29+
}
30+
2231
/**
2332
* @inheritDoc
2433
*/
@@ -111,13 +120,4 @@ public function process(File $phpCsFile, $stackPointer) {
111120
}
112121
}
113122

114-
/**
115-
* @inheritDoc
116-
*/
117-
public function register() {
118-
return [
119-
T_FUNCTION,
120-
];
121-
}
122-
123123
}

PSR2R/Sniffs/Commenting/DocBlockParamArraySniff.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ class DocBlockParamArraySniff extends AbstractSniff {
1717

1818
use CommentingTrait;
1919

20+
/**
21+
* @inheritDoc
22+
*/
23+
public function register() {
24+
return [
25+
T_FUNCTION,
26+
];
27+
}
28+
2029
/**
2130
* @inheritDoc
2231
*/
@@ -86,13 +95,4 @@ public function process(File $phpCsFile, $stackPointer) {
8695
}
8796
}
8897

89-
/**
90-
* @inheritDoc
91-
*/
92-
public function register() {
93-
return [
94-
T_FUNCTION,
95-
];
96-
}
97-
9898
}

PSR2R/Sniffs/Commenting/DocBlockParamNoOpSniff.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
*/
1414
class DocBlockParamNoOpSniff extends AbstractSniff {
1515

16+
/**
17+
* @inheritDoc
18+
*/
19+
public function register() {
20+
return [
21+
T_FUNCTION,
22+
];
23+
}
24+
1625
/**
1726
* @inheritDoc
1827
*/
@@ -61,13 +70,4 @@ public function process(File $phpCsFile, $stackPointer) {
6170
}
6271
}
6372

64-
/**
65-
* @inheritDoc
66-
*/
67-
public function register() {
68-
return [
69-
T_FUNCTION,
70-
];
71-
}
72-
7373
}

PSR2R/Sniffs/Commenting/DocBlockParamNotJustNullSniff.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ class DocBlockParamNotJustNullSniff extends AbstractSniff {
1818
use CommentingTrait;
1919
use SignatureTrait;
2020

21+
/**
22+
* @inheritDoc
23+
*/
24+
public function register() {
25+
return [
26+
T_FUNCTION,
27+
];
28+
}
29+
2130
/**
2231
* @inheritDoc
2332
*/
@@ -72,13 +81,4 @@ public function process(File $phpCsFile, $stackPointer) {
7281
}
7382
}
7483

75-
/**
76-
* @inheritDoc
77-
*/
78-
public function register() {
79-
return [
80-
T_FUNCTION,
81-
];
82-
}
83-
8484
}

PSR2R/Sniffs/Commenting/DocBlockParamSniff.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ class DocBlockParamSniff extends AbstractSniff {
1818
use CommentingTrait;
1919
use SignatureTrait;
2020

21+
/**
22+
* @inheritDoc
23+
*/
24+
public function register() {
25+
return [
26+
T_FUNCTION,
27+
];
28+
}
29+
2130
/**
2231
* @inheritDoc
2332
*/
@@ -66,7 +75,7 @@ public function process(File $phpCsFile, $stackPointer) {
6675
$content = substr($content, 0, $spacePos);
6776
}
6877

69-
/* @noinspection NotOptimalRegularExpressionsInspection */
78+
/** @noinspection NotOptimalRegularExpressionsInspection */
7079
preg_match('/\$[^\s]+/', $appendix, $matches);
7180
$variable = $matches ? $matches[0] : '';
7281

@@ -115,15 +124,6 @@ public function process(File $phpCsFile, $stackPointer) {
115124
}
116125
}
117126

118-
/**
119-
* @inheritDoc
120-
*/
121-
public function register() {
122-
return [
123-
T_FUNCTION,
124-
];
125-
}
126-
127127
/**
128128
* //TODO: Replace with SignatureTrait
129129
*

PSR2R/Sniffs/Commenting/DocBlockPipeSpacingSniff.php

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,57 @@
1313
*/
1414
class DocBlockPipeSpacingSniff extends AbstractSniff {
1515

16+
/**
17+
* @inheritDoc
18+
*/
19+
public function register() {
20+
return [
21+
T_DOC_COMMENT_STRING,
22+
];
23+
}
24+
1625
/**
1726
* @inheritDoc
1827
*/
1928
public function process(File $phpcsFile, $stackPtr) {
2029
$tokens = $phpcsFile->getTokens();
2130

2231
$content = $tokens[$stackPtr]['content'];
23-
if (substr_count($content, '|') !== 1) {
32+
$isInlineDocBlock = substr($content, -1, 1) === ' ';
33+
34+
// Fix inline doc blocks
35+
$appendix = '';
36+
$varIndex = strpos($content, '$');
37+
if ($varIndex) {
38+
$appendix = substr($content, $varIndex);
39+
$content = substr($content, 0, $varIndex);
40+
}
41+
42+
if (strpos($content, '|') === false) {
2443
return;
2544
}
2645

27-
list($left, $right) = explode('|', $content);
28-
$newContent = trim($left) . '|' . trim($right);
46+
$pieces = explode('|', $content);
47+
$newContent = [];
48+
foreach ($pieces as $piece) {
49+
$newContent[] = trim($piece);
50+
}
51+
$newContent = implode('|', $newContent);
2952

30-
if ($newContent !== $content) {
53+
if (trim($newContent) !== trim($content)) {
3154
$fix = $phpcsFile->addFixableError('There should be no space around pipes in doc blocks.', $stackPtr,
3255
'PipeSpacing');
3356
if ($fix) {
34-
$phpcsFile->fixer->replaceToken($stackPtr, $newContent);
57+
if ($appendix) {
58+
$appendix = ' ' . $appendix;
59+
}
60+
if ($isInlineDocBlock) {
61+
$appendix .= ' ';
62+
}
63+
64+
$phpcsFile->fixer->replaceToken($stackPtr, $newContent . $appendix);
3565
}
3666
}
3767
}
3868

39-
/**
40-
* @inheritDoc
41-
*/
42-
public function register() {
43-
return [
44-
T_DOC_COMMENT_STRING,
45-
];
46-
}
47-
4869
}

0 commit comments

Comments
 (0)