Skip to content

Commit 888c32d

Browse files
committed
Merge branch '2.15' into 2.16
2 parents 47405b1 + d394d3c commit 888c32d

File tree

4 files changed

+92
-6
lines changed

4 files changed

+92
-6
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- composer info -D | sort
3636
before_script:
3737
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then COMMIT_RANGE=$TRAVIS_COMMIT_RANGE; else COMMIT_RANGE="HEAD~..HEAD"; fi;
38-
- export COMMIT_SCA_FILES=`git diff --name-only --diff-filter=ACMRTUXB $COMMIT_RANGE`
38+
- export CHANGED_PHP_FILES=`git diff --name-only --diff-filter=ACMRTUXB $COMMIT_RANGE | grep -E "\.php$"`
3939
script:
4040
# @TODO remove at 3.0
4141
- |
@@ -53,7 +53,7 @@ jobs:
5353
&& (echo "UNKNOWN FILES DETECTED" && travis_terminate 1) || echo "NO UNKNOWN FILES"
5454
- ./check_trailing_spaces.sh || travis_terminate 1
5555
- php -d auto_prepend_file=dev-tools/vendor/autoload.php ./dev-tools/tools/phpstan analyse
56-
- if [ -n "$COMMIT_SCA_FILES" ]; then ./dev-tools/vendor/bin/phpmd `echo "$COMMIT_SCA_FILES" | grep -Ev "^tests/Fixtures" | xargs | sed 's/ /,/g'` text phpmd.xml || travis_terminate 1; fi
56+
- if [ -n "$CHANGED_PHP_FILES" ]; then ./dev-tools/vendor/bin/phpmd `echo "$CHANGED_PHP_FILES" | xargs | sed 's/ /,/g'` text phpmd.xml || travis_terminate 1; fi
5757
- ./dev-tools/tools/composer-require-checker check composer.json --config-file $(realpath .composer-require-checker.json) || travis_terminate 1
5858
- composer normalize -d ./dev-tools ./../composer.json --dry-run
5959
- ./dev-tools/check-shell-scripts.sh

src/Tokenizer/TokensAnalyzer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,14 @@ public function isConstantInvocation($index)
346346
}
347347
}
348348

349-
// check for `implements`/`use` list
349+
// check for `extends`/`implements`/`use` list
350350
if ($this->tokens[$prevIndex]->equals(',')) {
351351
$checkIndex = $prevIndex;
352352
while ($this->tokens[$checkIndex]->equalsAny([',', [T_AS], [CT::T_NAMESPACE_OPERATOR], [T_NS_SEPARATOR], [T_STRING]])) {
353353
$checkIndex = $this->tokens->getPrevMeaningfulToken($checkIndex);
354354
}
355355

356-
if ($this->tokens[$checkIndex]->isGivenKind([CT::T_GROUP_IMPORT_BRACE_OPEN, T_IMPLEMENTS, CT::T_USE_TRAIT])) {
356+
if ($this->tokens[$checkIndex]->isGivenKind([T_EXTENDS, CT::T_GROUP_IMPORT_BRACE_OPEN, T_IMPLEMENTS, CT::T_USE_TRAIT])) {
357357
return false;
358358
}
359359
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
--TEST--
2+
PHP 7.4 test.
3+
--RULESET--
4+
{
5+
"@Symfony": true,
6+
"array_syntax": false,
7+
"braces": false,
8+
"class_definition": false,
9+
"no_null_property_initialization": true,
10+
"no_unset_on_property": true,
11+
"pow_to_exponentiation": true,
12+
"trailing_comma_in_multiline_array": {"after_heredoc": true},
13+
"visibility_required": false
14+
}
15+
--REQUIREMENTS--
16+
{"php": 70400}
17+
--EXPECT--
18+
<?php
19+
20+
// https://wiki.php.net/rfc/numeric_literal_separator
21+
echo 10_0 ** 2;
22+
if (1_000 === $b);
23+
// https://wiki.php.net/rfc/null_coalesce_equal_operator
24+
$a ??= 1;
25+
$a ??= $b;
26+
// https://wiki.php.net/rfc/spread_operator_for_array
27+
$x = array(...$foo);
28+
$x = [...$foo];
29+
$x = array(...$foo, ...$bar);
30+
$x = [...$foo, ...$bar];
31+
$x = array(
32+
...$foo,
33+
...$bar,
34+
);
35+
$x = [
36+
...$foo,
37+
...$bar,
38+
];
39+
$x = array(...$foo, ...$bar);
40+
$x = [...$foo, ...$bar];
41+
// https://wiki.php.net/rfc/typed_properties_v2
42+
class Foo {
43+
private ?int $foo;
44+
protected string $bar;
45+
public iterable $baz;
46+
var ? Foo\Bar $qux;
47+
}
48+
// https://wiki.php.net/rfc/arrow_functions_v2
49+
$foo = fn ($v) => (string) $v;
50+
51+
--INPUT--
52+
<?php
53+
// https://wiki.php.net/rfc/numeric_literal_separator
54+
echo pow(10_0, 2);
55+
if ($b === 1_000);
56+
// https://wiki.php.net/rfc/null_coalesce_equal_operator
57+
$a??=1;
58+
$a ??= $b;
59+
// https://wiki.php.net/rfc/spread_operator_for_array
60+
$x = array(...$foo, );
61+
$x = [...$foo, ];
62+
$x = array(...$foo , ...$bar);
63+
$x = [...$foo , ...$bar];
64+
$x = array(
65+
...$foo,
66+
...$bar
67+
);
68+
$x = [
69+
...$foo,
70+
...$bar
71+
];
72+
$x = array(...$foo,...$bar);
73+
$x = [...$foo,...$bar];
74+
// https://wiki.php.net/rfc/typed_properties_v2
75+
class Foo {
76+
private ?int $foo;
77+
protected string $bar;
78+
public iterable $baz;
79+
var ? Foo\Bar $qux;
80+
}
81+
// https://wiki.php.net/rfc/arrow_functions_v2
82+
$foo = fn ($v)=> (string)$v;

tests/Tokenizer/TokensAnalyzerTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,8 @@ public function testIsConstantInvocation($source, array $expected)
630630
{
631631
$tokensAnalyzer = new TokensAnalyzer(Tokens::fromCode($source));
632632

633-
foreach ($expected as $index => $isLambda) {
634-
static::assertSame($isLambda, $tokensAnalyzer->isConstantInvocation($index), 'Token at index '.$index.' should match the expected value.');
633+
foreach ($expected as $index => $expectedValue) {
634+
static::assertSame($expectedValue, $tokensAnalyzer->isConstantInvocation($index), 'Token at index '.$index.' should match the expected value.');
635635
}
636636
}
637637

@@ -782,6 +782,10 @@ public function provideIsConstantInvocationCases()
782782
'<?php foo(E_USER_DEPRECATED | E_DEPRECATED);',
783783
[3 => true, 7 => true],
784784
],
785+
[
786+
'<?php interface Foo extends Bar, Baz, Qux {}',
787+
[7 => false, 10 => false, 13 => false],
788+
],
785789
];
786790
}
787791

0 commit comments

Comments
 (0)