Skip to content

Commit a8d774f

Browse files
committed
Merge branch '2.15' into 2.16
* 2.15: TokensAnalyzer::isUnarySuccessorOperator fix for array curly braces Fix: Alias should not be required Improve static analysis
2 parents 27b076e + a4df718 commit a8d774f

File tree

10 files changed

+73
-3
lines changed

10 files changed

+73
-3
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ Choose from the list of available rules:
670670
- ``annotation-black-list`` (``array``): class level annotations tags that must be
671671
omitted to fix the class, even if all of the white list ones are used
672672
as well. (case insensitive); defaults to ``['@final', '@Entity',
673-
'@ORM\\Entity']``
673+
'@ORM\\Entity', '@ORM\\Mapping\\Entity', '@Mapping\\Entity']``
674674
- ``annotation-white-list`` (``array``): class level annotations tags that must be
675675
set in order to fix the class. (case insensitive); defaults to
676676
``['@internal']``

src/Fixer/ClassNotation/FinalInternalClassFixer.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@ protected function createConfigurationDefinition()
155155
(new FixerOptionBuilder('annotation-black-list', 'Class level annotations tags that must be omitted to fix the class, even if all of the white list ones are used as well. (case insensitive)'))
156156
->setAllowedTypes(['array'])
157157
->setAllowedValues($annotationsAsserts)
158-
->setDefault(['@final', '@Entity', '@ORM\Entity'])
158+
->setDefault([
159+
'@final',
160+
'@Entity',
161+
'@ORM\Entity',
162+
'@ORM\Mapping\Entity',
163+
'@Mapping\Entity',
164+
])
159165
->setNormalizer($annotationsNormalizer)
160166
->getOption(),
161167
(new FixerOptionBuilder('consider-absent-docblock-as-internal-class', 'Should classes without any DocBlock be fixed to final?'))

src/Fixer/Operator/IncrementStyleFixer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ private function findEnd(Tokens $tokens, $index)
145145
'[',
146146
[CT::T_DYNAMIC_PROP_BRACE_OPEN],
147147
[CT::T_DYNAMIC_VAR_BRACE_OPEN],
148+
[CT::T_ARRAY_INDEX_CURLY_BRACE_OPEN],
148149
[T_NS_SEPARATOR],
149150
[T_STATIC],
150151
[T_STRING],

src/Tokenizer/Tokens.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*
2525
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
2626
*
27+
* @extends \SplFixedArray<Token>
28+
*
2729
* @method Token current()
2830
* @method Token offsetGet($index)
2931
*/

src/Tokenizer/TokensAnalyzer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ public function isUnarySuccessorOperator($index)
388388
']',
389389
[T_STRING],
390390
[T_VARIABLE],
391+
[CT::T_ARRAY_INDEX_CURLY_BRACE_CLOSE],
391392
[CT::T_DYNAMIC_PROP_BRACE_CLOSE],
392393
[CT::T_DYNAMIC_VAR_BRACE_CLOSE],
393394
];

tests/Fixer/ClassNotation/FinalClassFixerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function provideFixCases()
3939
return [
4040
['<?php /** @Entity */ class MyEntity {}'],
4141
['<?php use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity */ class MyEntity {}'],
42+
['<?php use Doctrine\ORM\Mapping; /** @Mapping\Entity */ class MyEntity {}'],
43+
['<?php use Doctrine\ORM; /** @ORM\Mapping\Entity */ class MyEntity {}'],
4244
['<?php /** @entity */ class MyEntity {}'],
4345
['<?php use Doctrine\ORM\Mapping as ORM; /** @orm\entity */ class MyEntity {}'],
4446
['<?php abstract class MyAbstract {}'],

tests/Fixer/ControlStructure/NoSuperfluousElseifFixerTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,48 @@ public function provideFixCases()
235235
],
236236
];
237237
}
238+
239+
/**
240+
* @param string $expected
241+
* @param string $input
242+
*
243+
* @dataProvider provideFix70Cases
244+
* @requires PHP 7.0
245+
*/
246+
public function testFix70($expected, $input)
247+
{
248+
$this->doTest($expected, $input);
249+
}
250+
251+
public function provideFix70Cases()
252+
{
253+
return [
254+
[
255+
'<?php
256+
257+
if ($foo) {
258+
return 1;
259+
}
260+
if ($bar) {
261+
return 2;
262+
}
263+
if ($baz) {
264+
throw new class extends Exception{};
265+
} else {
266+
return 4;
267+
}',
268+
'<?php
269+
270+
if ($foo) {
271+
return 1;
272+
} elseif ($bar) {
273+
return 2;
274+
} else if ($baz) {
275+
throw new class extends Exception{};
276+
} else {
277+
return 4;
278+
}',
279+
],
280+
];
281+
}
238282
}

tests/Fixer/ControlStructure/NoUselessElseFixerTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,11 @@ public function provideConditionsWithoutBracesCases()
708708
'foreach($a as $b){throw new Exception($i);}',
709709
];
710710

711+
if (\PHP_VERSION_ID >= 70000) {
712+
$statements[] = 'throw new class extends Exception{};';
713+
$statements[] = 'throw new class ($a, 9) extends Exception{ public function z($a, $b){ echo 7;} };';
714+
}
715+
711716
$ifTemplate = '<?php
712717
if ($a === false)
713718
{

tests/Fixer/Operator/IncrementStyleFixerTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ public function provideFixPreIncrementCases()
114114
'<?php ++$a[0];',
115115
'<?php $a[0]++;',
116116
],
117+
[
118+
'<?php ++$a{0};',
119+
'<?php $a{0}++;',
120+
],
117121
[
118122
'<?php ++$a[$b];',
119123
'<?php $a[$b]++;',
@@ -138,6 +142,7 @@ public function provideFixPreIncrementCases()
138142
['<?php foo($a, ++$b);'],
139143
['<?php $a[++$b];'],
140144
['<?php echo ++$a;'],
145+
['<?= ++$a;'],
141146

142147
[
143148
'<?php class Test {

tests/Tokenizer/TokensAnalyzerTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,14 @@ public function provideIsUnarySuccessorOperatorCases()
920920
'<?php $foo->{"bar"}++;',
921921
[6 => true],
922922
],
923-
[
923+
'array access' => [
924924
'<?php $a["foo"]++;',
925925
[5 => true],
926926
],
927+
'array curly access' => [
928+
'<?php $a{"foo"}++;',
929+
[5 => true],
930+
],
927931
];
928932
}
929933

0 commit comments

Comments
 (0)