Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b21630e

Browse files
committed
Merge branch '2.3'
2 parents 6dc5756 + c2520fe commit b21630e

8 files changed

Lines changed: 202 additions & 7 deletions

File tree

src/Fixer/Phpdoc/PhpdocIndentFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
9292
if (
9393
$prevToken->isGivenKind(T_OPEN_TAG)
9494
|| ($prevToken->isWhitespace(" \t") && !$tokens[$index - 2]->isGivenKind(T_OPEN_TAG))
95-
|| $prevToken->equalsAny([';', '{'])
95+
|| $prevToken->equalsAny([';', ',', '{', '('])
9696
) {
9797
continue;
9898
}

tests/AutoReview/ProjectCodeTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ final class ProjectCodeTest extends TestCase
3838
\PhpCsFixer\Console\Command\SelfUpdateCommand::class,
3939
\PhpCsFixer\Console\Output\NullOutput::class,
4040
\PhpCsFixer\Differ\DiffConsoleFormatter::class,
41-
\PhpCsFixer\Differ\NullDiffer::class,
42-
\PhpCsFixer\Differ\SebastianBergmannDiffer::class,
43-
\PhpCsFixer\Differ\SebastianBergmannShortDiffer::class,
4441
\PhpCsFixer\Doctrine\Annotation\Tokens::class,
4542
\PhpCsFixer\FileRemoval::class,
4643
\PhpCsFixer\FixerConfiguration\FixerOptionValidatorGenerator::class,

tests/Console/Command/ReadmeCommandTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ public function testIfReadmeFileIsCorrect()
4040

4141
$fileContent = file_get_contents(__DIR__.'/../../../README.rst');
4242

43-
$this->assertSame(
44-
$output->fetch(),
45-
$fileContent,
43+
$this->assertTrue(
44+
$output->fetch() === $fileContent,
4645
'README.rst file is not up to date! Do not modify it manually! Regenerate readme with command: `php php-cs-fixer readme > README.rst`.'
4746
);
4847
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/*
4+
* This file is part of PHP CS Fixer.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
* Dariusz Rumiński <[email protected]>
8+
*
9+
* This source file is subject to the MIT license that is bundled
10+
* with this source code in the file LICENSE.
11+
*/
12+
13+
namespace PhpCsFixer\Tests\Differ;
14+
15+
use PHPUnit\Framework\TestCase;
16+
17+
/**
18+
* @author Andreas Möller <[email protected]>
19+
*
20+
* @internal
21+
*/
22+
abstract class AbstractDifferTestCase extends TestCase
23+
{
24+
final public function testIsDiffer()
25+
{
26+
$className = preg_replace(
27+
'/Test$/',
28+
'',
29+
str_replace(
30+
'PhpCsFixer\\Tests\\Differ\\',
31+
'PhpCsFixer\\Differ\\',
32+
get_called_class()
33+
)
34+
);
35+
36+
$differ = new $className();
37+
38+
$this->assertInstanceOf('PhpCsFixer\Differ\DifferInterface', $differ);
39+
}
40+
41+
final protected function oldCode()
42+
{
43+
return <<<'PHP'
44+
<?php
45+
class Foo extends Bar {
46+
function __construct($foo, $bar) {
47+
$this->foo = $foo;
48+
$this->bar = $bar;
49+
}
50+
}
51+
PHP;
52+
}
53+
54+
final protected function newCode()
55+
{
56+
return <<<'PHP'
57+
<?php
58+
class Foo extends Bar {
59+
public function __construct($foo, $bar)
60+
{
61+
$this->foo = $foo;
62+
$this->bar = $bar;
63+
}
64+
}
65+
PHP;
66+
}
67+
}

tests/Differ/NullDifferTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of PHP CS Fixer.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
* Dariusz Rumiński <[email protected]>
8+
*
9+
* This source file is subject to the MIT license that is bundled
10+
* with this source code in the file LICENSE.
11+
*/
12+
13+
namespace PhpCsFixer\Tests\Differ;
14+
15+
use PhpCsFixer\Differ\NullDiffer;
16+
17+
/**
18+
* @author Andreas Möller <[email protected]>
19+
*
20+
* @internal
21+
*
22+
* @covers \PhpCsFixer\Differ\NullDiffer
23+
*/
24+
final class NullDifferTest extends AbstractDifferTestCase
25+
{
26+
public function testDiffReturnsEmptyString()
27+
{
28+
$diff = '';
29+
30+
$differ = new NullDiffer();
31+
32+
$this->assertSame($diff, $differ->diff($this->oldCode(), $this->newCode()));
33+
}
34+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/*
4+
* This file is part of PHP CS Fixer.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
* Dariusz Rumiński <[email protected]>
8+
*
9+
* This source file is subject to the MIT license that is bundled
10+
* with this source code in the file LICENSE.
11+
*/
12+
13+
namespace PhpCsFixer\Tests\Differ;
14+
15+
use PhpCsFixer\Differ\SebastianBergmannDiffer;
16+
17+
/**
18+
* @author Andreas Möller <[email protected]>
19+
*
20+
* @internal
21+
*
22+
* @covers \PhpCsFixer\Differ\SebastianBergmannDiffer
23+
*/
24+
final class SebastianBergmannDifferTest extends AbstractDifferTestCase
25+
{
26+
public function testDiffReturnsDiff()
27+
{
28+
$diff = <<<'TXT'
29+
--- Original
30+
+++ New
31+
@@ @@
32+
<?php
33+
class Foo extends Bar {
34+
- function __construct($foo, $bar) {
35+
+ public function __construct($foo, $bar)
36+
+ {
37+
$this->foo = $foo;
38+
$this->bar = $bar;
39+
}
40+
}
41+
42+
TXT;
43+
44+
$differ = new SebastianBergmannDiffer();
45+
46+
$this->assertSame($diff, $differ->diff($this->oldCode(), $this->newCode()));
47+
}
48+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
/*
4+
* This file is part of PHP CS Fixer.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
* Dariusz Rumiński <[email protected]>
8+
*
9+
* This source file is subject to the MIT license that is bundled
10+
* with this source code in the file LICENSE.
11+
*/
12+
13+
namespace PhpCsFixer\Tests\Differ;
14+
15+
use PhpCsFixer\Differ\SebastianBergmannShortDiffer;
16+
17+
/**
18+
* @author Andreas Möller <[email protected]>
19+
*
20+
* @internal
21+
*
22+
* @covers \PhpCsFixer\Differ\SebastianBergmannShortDiffer
23+
*/
24+
final class SebastianBergmannShortDifferTest extends AbstractDifferTestCase
25+
{
26+
public function testDiffReturnsDiff()
27+
{
28+
$diff = <<<'TXT'
29+
--- Original
30+
+++ New
31+
- function __construct($foo, $bar) {
32+
+ public function __construct($foo, $bar)
33+
+ {
34+
35+
TXT;
36+
37+
$differ = new SebastianBergmannShortDiffer();
38+
39+
$this->assertSame($diff, $differ->diff($this->oldCode(), $this->newCode()));
40+
}
41+
}

tests/Fixer/Phpdoc/PhpdocIndentFixerTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,15 @@ public function bar()
381381
',
382382
];
383383

384+
$cases[] = [
385+
'<?php
386+
function foo()
387+
{
388+
$foo->bar(/** oops */$baz);
389+
$foo->bar($a,/** oops */$baz);
390+
}',
391+
];
392+
384393
return $cases;
385394
}
386395
}

0 commit comments

Comments
 (0)