Skip to content

Commit e9fe982

Browse files
committed
Merge branch '2.15'
# Conflicts: # src/Console/Application.php
2 parents 4031ea3 + 705490b commit e9fe982

File tree

8 files changed

+197
-39
lines changed

8 files changed

+197
-39
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ jobs:
145145

146146
-
147147
stage: Deployment
148-
php: 7.1
148+
php: 7.3
149149
install: ./dev-tools/build.sh
150150
script:
151151
- PHP_CS_FIXER_TEST_ALLOW_SKIPPING_SMOKE_TESTS=0 vendor/bin/phpunit tests/Smoke/

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ CHANGELOG for PHP CS Fixer
33

44
This file contains changelogs for stable releases only.
55

6+
Changelog for v2.15.3
7+
---------------------
8+
9+
* bug #4533 Revert PHP7.4 - Add "str_split" => "mb_str_split" mapping (keradus)
10+
* minor #4264 DX: AutoReview - ensure Travis handle all needed PHP versions (keradus)
11+
* minor #4524 MethodArgumentSpaceFixerTest - make explicit configuration to prevent fail on configuration change (keradus)
12+
613
Changelog for v2.15.2
714
---------------------
815

@@ -66,6 +73,13 @@ Changelog for v2.15.0
6673
* minor #4398 New ruleset "@PHP73Migration" (gharlan)
6774
* minor #4399 Fix 2.15 line (keradus)
6875

76+
Changelog for v2.14.6
77+
---------------------
78+
79+
* bug #4533 Revert PHP7.4 - Add "str_split" => "mb_str_split" mapping (keradus)
80+
* minor #4264 DX: AutoReview - ensure Travis handle all needed PHP versions (keradus)
81+
* minor #4524 MethodArgumentSpaceFixerTest - make explicit configuration to prevent fail on configuration change (keradus)
82+
6983
Changelog for v2.14.5
7084
---------------------
7185

@@ -317,6 +331,13 @@ Changelog for v2.13.0
317331
* minor #3873 Add the native_function_invocation fixer in the Symfony:risky ruleset (stof)
318332
* minor #3979 DX: enable php_unit_method_casing (keradus)
319333

334+
Changelog for v2.12.12
335+
----------------------
336+
337+
* bug #4533 Revert PHP7.4 - Add "str_split" => "mb_str_split" mapping (keradus)
338+
* minor #4264 DX: AutoReview - ensure Travis handle all needed PHP versions (keradus)
339+
* minor #4524 MethodArgumentSpaceFixerTest - make explicit configuration to prevent fail on configuration change (keradus)
340+
320341
Changelog for v2.12.11
321342
----------------------
322343

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ or with specified version:
4646

4747
.. code-block:: bash
4848
49-
$ wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.15.2/php-cs-fixer.phar -O php-cs-fixer
49+
$ wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.15.3/php-cs-fixer.phar -O php-cs-fixer
5050
5151
or with curl:
5252

@@ -1912,7 +1912,7 @@ Config file
19121912

19131913
Instead of using command line options to customize the rule, you can save the
19141914
project configuration in a ``.php_cs.dist`` file in the root directory of your project.
1915-
The file must return an instance of `PhpCsFixer\\ConfigInterface <https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.15.2/src/ConfigInterface.php>`_
1915+
The file must return an instance of `PhpCsFixer\\ConfigInterface <https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.15.3/src/ConfigInterface.php>`_
19161916
which lets you configure the rules, the files and directories that
19171917
need to be analyzed. You may also create ``.php_cs`` file, which is
19181918
the local configuration that will be used instead of the project configuration. It

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@
4040
"php-cs-fixer/accessible-object": "^1.0",
4141
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.1",
4242
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1",
43-
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1",
43+
"phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1",
4444
"phpunitgoodpractices/traits": "^1.8",
45-
"symfony/phpunit-bridge": "^4.3"
45+
"symfony/phpunit-bridge": "^4.3",
46+
"symfony/yaml": "^3.0 || ^4.0"
4647
},
4748
"suggest": {
4849
"ext-mbstring": "For handling non-UTF8 characters in cache signature.",

src/Fixer/Alias/MbStrFunctionsFixer.php

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ final class MbStrFunctionsFixer extends AbstractFunctionReferenceFixer
2828
* @var array the list of the string-related function names and their mb_ equivalent
2929
*/
3030
private static $functionsMap = [
31-
'str_split' => ['alternativeName' => 'mb_str_split', 'argumentCount' => [1, 2, 3]],
3231
'stripos' => ['alternativeName' => 'mb_stripos', 'argumentCount' => [2, 3]],
3332
'stristr' => ['alternativeName' => 'mb_stristr', 'argumentCount' => [2, 3]],
3433
'strlen' => ['alternativeName' => 'mb_strlen', 'argumentCount' => [1]],
@@ -43,23 +42,6 @@ final class MbStrFunctionsFixer extends AbstractFunctionReferenceFixer
4342
'substr_count' => ['alternativeName' => 'mb_substr_count', 'argumentCount' => [2, 3, 4]],
4443
];
4544

46-
/**
47-
* @var array<string, array>
48-
*/
49-
private $functions;
50-
51-
public function __construct()
52-
{
53-
parent::__construct();
54-
55-
$this->functions = array_filter(
56-
self::$functionsMap,
57-
static function (array $mapping) {
58-
return \function_exists($mapping['alternativeName']);
59-
}
60-
);
61-
}
62-
6345
/**
6446
* {@inheritdoc}
6547
*/
@@ -104,7 +86,7 @@ public function isCandidate(Tokens $tokens)
10486
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
10587
{
10688
$argumentsAnalyzer = new ArgumentsAnalyzer();
107-
foreach ($this->functions as $functionIdentity => $functionReplacement) {
89+
foreach (self::$functionsMap as $functionIdentity => $functionReplacement) {
10890
$currIndex = 0;
10991
while (null !== $currIndex) {
11092
// try getting function reference and translate boundaries for humans

tests/AutoReview/TravisTest.php

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?php
2+
3+
/*
4+
* This file is part of PHP CS Fixer.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
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\AutoReview;
14+
15+
use PhpCsFixer\Preg;
16+
use PhpCsFixer\Tests\TestCase;
17+
use PhpCsFixer\Tokenizer\Tokens;
18+
use PHPUnit\Framework\Constraint\TraversableContains;
19+
use Symfony\Component\Yaml\Yaml;
20+
21+
/**
22+
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
23+
*
24+
* @internal
25+
*
26+
* @coversNothing
27+
* @group auto-review
28+
* @group covers-nothing
29+
*/
30+
final class TravisTest extends TestCase
31+
{
32+
public function testTestJobsRunOnEachPhp()
33+
{
34+
$expectedVersions = [];
35+
$expectedMinPhp = (float) $this->getMinPhpVersionFromEntryFile();
36+
$expectedMaxPhp = (float) $this->getMaxPhpVersionFromEntryFile();
37+
38+
if ($expectedMinPhp < 7) {
39+
$expectedMinPhp = 7;
40+
$expectedVersions[] = '5.6';
41+
}
42+
43+
for ($version = $expectedMinPhp; $version <= $expectedMaxPhp; $version += 0.1) {
44+
$expectedVersions[] = sprintf('%.1f', $version);
45+
}
46+
47+
$jobs = array_filter($this->getTravisJobs(), function ($job) {
48+
return false !== strpos($job['stage'], 'Test');
49+
});
50+
static::assertGreaterThanOrEqual(1, \count($jobs));
51+
52+
$versions = array_map(function ($job) {
53+
return $job['php'];
54+
}, $jobs);
55+
56+
foreach ($expectedVersions as $expectedVersion) {
57+
static::assertContains($expectedVersion, $versions);
58+
}
59+
60+
if (!class_exists(TraversableContains::class)) {
61+
static::markTestSkipped('TraversableContains not available.');
62+
}
63+
64+
static::assertThat($versions, static::logicalOr(
65+
new TraversableContains('nightly'),
66+
new TraversableContains(sprintf('%.1fsnapshot', end($expectedVersions) + 0.1))
67+
));
68+
}
69+
70+
public function testDeploymentJobsRunOnLatestPhp()
71+
{
72+
$jobs = array_filter($this->getTravisJobs(), function ($job) {
73+
return 'Deployment' === $job['stage'];
74+
});
75+
static::assertGreaterThanOrEqual(1, \count($jobs));
76+
77+
$expectedPhp = $this->getMaxPhpVersionFromEntryFile();
78+
79+
foreach ($jobs as $job) {
80+
$jobPhp = (string) $job['php'];
81+
static::assertTrue(
82+
version_compare($expectedPhp, $jobPhp, 'eq'),
83+
sprintf('Expects %s to be %s', $jobPhp, $expectedPhp)
84+
);
85+
}
86+
}
87+
88+
private function convertPhpVerIdToNiceVer($verId)
89+
{
90+
$matchResult = Preg::match('/^(?<major>\d{1,2})(?<minor>\d{2})(?<patch>\d{2})$/', $verId, $capture);
91+
if (1 !== $matchResult) {
92+
throw new \LogicException("Can't parse version id.");
93+
}
94+
95+
return sprintf('%d.%d', $capture['major'], $capture['minor']);
96+
}
97+
98+
private function getMaxPhpVersionFromEntryFile()
99+
{
100+
$tokens = Tokens::fromCode(file_get_contents(__DIR__.'/../../php-cs-fixer'));
101+
$sequence = $tokens->findSequence([
102+
[T_STRING, 'PHP_VERSION_ID'],
103+
[T_IS_GREATER_OR_EQUAL],
104+
[T_LNUMBER],
105+
]);
106+
107+
if (null === $sequence) {
108+
throw new \LogicException("Can't find version - perhaps entry file was modified?");
109+
}
110+
111+
$phpVerId = end($sequence)->getContent();
112+
113+
return $this->convertPhpVerIdToNiceVer((string) ($phpVerId - 100));
114+
}
115+
116+
private function getMinPhpVersionFromEntryFile()
117+
{
118+
$tokens = Tokens::fromCode(file_get_contents(__DIR__.'/../../php-cs-fixer'));
119+
$sequence = $tokens->findSequence([
120+
[T_STRING, 'PHP_VERSION_ID'],
121+
'<',
122+
[T_LNUMBER],
123+
]);
124+
125+
if (null === $sequence) {
126+
throw new \LogicException("Can't find version - perhaps entry file was modified?");
127+
}
128+
129+
$phpVerId = end($sequence)->getContent();
130+
131+
return $this->convertPhpVerIdToNiceVer($phpVerId);
132+
}
133+
134+
private function getTravisJobs()
135+
{
136+
$yaml = Yaml::parse(file_get_contents(__DIR__.'/../../.travis.yml'));
137+
138+
return $yaml['jobs']['include'];
139+
}
140+
}

tests/Fixer/Alias/MbStrFunctionsFixerTest.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testFix($expected, $input = null)
3737

3838
public function provideFixCases()
3939
{
40-
$cases = [
40+
return [
4141
['<?php $x = "strlen";'],
4242
['<?php $x = Foo::strlen("bar");'],
4343
['<?php $x = new strlen("bar");'],
@@ -62,18 +62,5 @@ public function strtolower($a);
6262
}',
6363
],
6464
];
65-
66-
if (\function_exists('mb_str_split')) {
67-
$cases[] = [
68-
'<?php $a = mb_str_split($a);',
69-
'<?php $a = str_split($a);',
70-
];
71-
} else {
72-
$cases[] = [
73-
'<?php $a = str_split($a);',
74-
];
75-
}
76-
77-
return $cases;
7865
}
7966
}

tests/Fixer/FunctionNotation/MethodArgumentSpaceFixerTest.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,40 @@ function xyz(
333333
);
334334
",
335335
],
336-
'with_random_comments' => [
336+
'with_random_comments on_multiline:ignore' => [
337337
'<?php xyz#
338338
(#
339339
""#
340340
,#
341341
$a#
342342
);',
343+
null,
344+
['on_multiline' => 'ignore'],
345+
],
346+
'with_random_comments on_multiline:ensure_single_line' => [
347+
'<?php xyz#
348+
(#
349+
""#
350+
,#
351+
$a#
352+
);',
353+
null,
354+
['on_multiline' => 'ensure_single_line'],
355+
],
356+
'with_random_comments on_multiline:ensure_fully_multiline' => [
357+
'<?php xyz#
358+
(#
359+
""#
360+
,#
361+
$a#
362+
);',
363+
'<?php xyz#
364+
(#
365+
""#
366+
,#
367+
$a#
368+
);',
369+
['on_multiline' => 'ensure_fully_multiline'],
343370
],
344371
'keep_multiple_spaces_after_comma_with_newlines' => [
345372
"<?php xyz(\$a=10,\n\$b=20);",

0 commit comments

Comments
 (0)