Browse Source

Merge branch 'master' into 3.0

Julien Falque 4 years ago
parent
commit
fc2f4e87f5

+ 2 - 2
.travis.yml

@@ -83,14 +83,14 @@ jobs:
             <<: *STANDARD_TEST_JOB
             stage: Test
             php: 7.1
-            name: 7.1 | Symfony 4.1
+            name: 7.1 | Symfony ~4.1.0
             env: SYMFONY_DEPRECATIONS_HELPER=disabled SYMFONY_VERSION="~4.1.0"
 
         -
             <<: *STANDARD_TEST_JOB
             stage: Test
             php: 7.2
-            name: 7.2 | Symfony 5.0
+            name: 7.2 | Symfony ^5.0
             env: SYMFONY_DEPRECATIONS_HELPER=disabled PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER=1 SYMFONY_VERSION="^5.0"
 
         -

+ 1 - 1
composer.json

@@ -42,7 +42,7 @@
         "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1",
         "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1",
         "phpunitgoodpractices/traits": "^1.8",
-        "symfony/phpunit-bridge": "^4.3 || ^5.0",
+        "symfony/phpunit-bridge": "^5.1",
         "symfony/yaml": "^3.0 || ^4.0 || ^5.0"
     },
     "suggest": {

+ 1 - 1
dev-tools/install.sh

@@ -32,7 +32,7 @@ bin/checkbashisms --version
 
 echo λλλ shellcheck
 if [ ! -x bin/shellcheck ]; then
-    wget -qO- "https://storage.googleapis.com/shellcheck/shellcheck-${VERSION_SC}.linux.x86_64.tar.xz" \
+    wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${VERSION_SC}/shellcheck-${VERSION_SC}.linux.x86_64.tar.xz" \
         | tar -xJv -O shellcheck-${VERSION_SC}/shellcheck \
         > bin/shellcheck
     chmod u+x bin/shellcheck

+ 1 - 1
php-cs-fixer

@@ -11,7 +11,7 @@
  * with this source code in the file LICENSE.
  */
 
-error_reporting(-1);
+error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
 
 if (defined('HHVM_VERSION_ID')) {
     fwrite(STDERR, "HHVM is not supported.\n");

+ 5 - 5
tests/Fixer/CastNotation/LowercaseCastFixerTest.php

@@ -13,6 +13,7 @@
 namespace PhpCsFixer\Tests\Fixer\CastNotation;
 
 use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
+use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
 
 /**
  * @author SpacePossum
@@ -23,6 +24,8 @@ use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  */
 final class LowercaseCastFixerTest extends AbstractFixerTestCase
 {
+    use ExpectDeprecationTrait;
+
     /**
      * @param string      $expected
      * @param null|string $input
@@ -55,14 +58,11 @@ final class LowercaseCastFixerTest extends AbstractFixerTestCase
      * @dataProvider provideFixDeprecatedCases
      * @requires PHP 7.4
      * @group legacy
-     * @expectedDeprecation Unsilenced deprecation: The (real) cast is deprecated, use (float) instead
-     * @expectedDeprecation Unsilenced deprecation: The (real) cast is deprecated, use (float) instead
-     * @expectedDeprecation Unsilenced deprecation: The (real) cast is deprecated, use (float) instead
-     * @expectedDeprecation Unsilenced deprecation: The (real) cast is deprecated, use (float) instead
-     * @expectedDeprecation Unsilenced deprecation: The (real) cast is deprecated, use (float) instead
      */
     public function testFix74Deprecated($expected, $input = null)
     {
+        $this->expectDeprecation('The (real) cast is deprecated, use (float) instead');
+
         $this->doTest($expected, $input);
     }
 

+ 5 - 1
tests/Fixer/CastNotation/ShortScalarCastFixerTest.php

@@ -13,6 +13,7 @@
 namespace PhpCsFixer\Tests\Fixer\CastNotation;
 
 use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
+use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
 
 /**
  * @author SpacePossum
@@ -23,6 +24,8 @@ use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  */
 final class ShortScalarCastFixerTest extends AbstractFixerTestCase
 {
+    use ExpectDeprecationTrait;
+
     /**
      * @param string      $expected
      * @param null|string $input
@@ -55,10 +58,11 @@ final class ShortScalarCastFixerTest extends AbstractFixerTestCase
      * @dataProvider provideFixDeprecatedCases
      * @requires PHP 7.4
      * @group legacy
-     * @expectedDeprecation Unsilenced deprecation: The (real) cast is deprecated, use (float) instead
      */
     public function testFix74Deprecated($expected, $input = null)
     {
+        $this->expectDeprecation('The (real) cast is deprecated, use (float) instead');
+
         $this->doTest($expected, $input);
     }
 

+ 6 - 6
tests/Fixer/Comment/HeaderCommentFixerTest.php

@@ -505,7 +505,7 @@ echo 1;'
     public function testMisconfiguration($configuration, $exceptionMessage)
     {
         $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class);
-        $this->expectExceptionMessage('[header_comment] '.$exceptionMessage);
+        $this->expectExceptionMessageRegExp("#^\\[header_comment\\] {$exceptionMessage}$#");
 
         $this->configureFixerWithAliasedOptions($configuration);
     }
@@ -516,35 +516,35 @@ echo 1;'
             [[], 'Missing required configuration: The required option "header" is missing.'],
             [
                 ['header' => 1],
-                'Invalid configuration: The option "header" with value 1 is expected to be of type "string", but is of type "integer".',
+                'Invalid configuration: The option "header" with value 1 is expected to be of type "string", but is of type "(int|integer)"\.',
             ],
             [
                 [
                     'header' => '',
                     'comment_type' => 'foo',
                 ],
-                'Invalid configuration: The option "comment_type" with value "foo" is invalid. Accepted values are: "PHPDoc", "comment".',
+                'Invalid configuration: The option "comment_type" with value "foo" is invalid\. Accepted values are: "PHPDoc", "comment"\.',
             ],
             [
                 [
                     'header' => '',
                     'comment_type' => new \stdClass(),
                 ],
-                'Invalid configuration: The option "comment_type" with value stdClass is invalid. Accepted values are: "PHPDoc", "comment".',
+                'Invalid configuration: The option "comment_type" with value stdClass is invalid\. Accepted values are: "PHPDoc", "comment"\.',
             ],
             [
                 [
                     'header' => '',
                     'location' => new \stdClass(),
                 ],
-                'Invalid configuration: The option "location" with value stdClass is invalid. Accepted values are: "after_open", "after_declare_strict".',
+                'Invalid configuration: The option "location" with value stdClass is invalid\. Accepted values are: "after_open", "after_declare_strict"\.',
             ],
             [
                 [
                     'header' => '',
                     'separate' => new \stdClass(),
                 ],
-                'Invalid configuration: The option "separate" with value stdClass is invalid. Accepted values are: "both", "top", "bottom", "none".',
+                'Invalid configuration: The option "separate" with value stdClass is invalid\. Accepted values are: "both", "top", "bottom", "none"\.',
             ],
         ];
     }

+ 3 - 7
tests/Fixer/ControlStructure/YodaStyleFixerTest.php

@@ -700,11 +700,7 @@ $a#4
     public function testInvalidConfig(array $config, $expectedMessage)
     {
         $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class);
-        $this->expectExceptionMessageRegExp(sprintf(
-            '#^\[%s\] %s$#',
-            $this->fixer->getName(),
-            preg_quote($expectedMessage, '#')
-        ));
+        $this->expectExceptionMessageRegExp("#^\\[{$this->fixer->getName()}\\] {$expectedMessage}$#");
 
         $this->fixer->configure($config);
     }
@@ -715,8 +711,8 @@ $a#4
     public function provideInvalidConfigurationCases()
     {
         return [
-            [['equal' => 2], 'Invalid configuration: The option "equal" with value 2 is expected to be of type "bool" or "null", but is of type "integer".'],
-            [['_invalid_' => true], 'Invalid configuration: The option "_invalid_" does not exist. Defined options are: "always_move_variable", "equal", "identical", "less_and_greater".'],
+            [['equal' => 2], 'Invalid configuration: The option "equal" with value 2 is expected to be of type "bool" or "null", but is of type "(int|integer)"\.'],
+            [['_invalid_' => true], 'Invalid configuration: The option "_invalid_" does not exist\. Defined options are: "always_move_variable", "equal", "identical", "less_and_greater"\.'],
         ];
     }
 

+ 1 - 1
tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php

@@ -808,7 +808,7 @@ $b;
     {
         $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class);
         $this->expectExceptionMessageRegExp(
-            '/^\[binary_operator_spaces\] Invalid configuration: The option "operators" with value true is expected to be of type "array", but is of type "boolean"\.$/'
+            '/^\[binary_operator_spaces\] Invalid configuration: The option "operators" with value true is expected to be of type "array", but is of type "(bool|boolean)"\.$/'
         );
 
         $this->fixer->configure(['operators' => true]);

+ 28 - 13
tests/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixerTest.php

@@ -42,15 +42,13 @@ final class PhpdocAddMissingParamAnnotationFixerTest extends AbstractFixerTestCa
     /**
      * @dataProvider provideConfigureRejectsInvalidConfigurationValueCases
      *
-     * @param mixed $value
+     * @param mixed  $value
+     * @param string $expectedMessage
      */
-    public function testConfigureRejectsInvalidConfigurationValue($value)
+    public function testConfigureRejectsInvalidConfigurationValue($value, $expectedMessage)
     {
         $this->expectException(\PhpCsFixer\ConfigurationException\InvalidConfigurationException::class);
-        $this->expectExceptionMessage(sprintf(
-            'expected to be of type "bool", but is of type "%s".',
-            \is_object($value) ? \get_class($value) : \gettype($value)
-        ));
+        $this->expectExceptionMessageRegExp($expectedMessage);
 
         $this->fixer->configure([
             'only_untyped' => $value,
@@ -58,16 +56,33 @@ final class PhpdocAddMissingParamAnnotationFixerTest extends AbstractFixerTestCa
     }
 
     /**
-     * @return array
+     * @return iterable<string, array>
      */
     public function provideConfigureRejectsInvalidConfigurationValueCases()
     {
-        return [
-            'null' => [null],
-            'int' => [1],
-            'array' => [[]],
-            'float' => [0.1],
-            'object' => [new \stdClass()],
+        yield 'null' => [
+            null,
+            '#expected to be of type "bool", but is of type "(null|NULL)"\.$#',
+        ];
+
+        yield 'int' => [
+            1,
+            '#expected to be of type "bool", but is of type "(int|integer)"\.$#',
+        ];
+
+        yield 'array' => [
+            [],
+            '#expected to be of type "bool", but is of type "array"\.$#',
+        ];
+
+        yield 'float' => [
+            0.1,
+            '#expected to be of type "bool", but is of type "(float|double)"\.$#',
+        ];
+
+        yield 'object' => [
+            new \stdClass(),
+            '#expected to be of type "bool", but is of type "stdClass"\.$#',
         ];
     }