Browse Source

Merge branch 'master' into 3.0

# Conflicts:
#	tests/Test/AbstractFixerTestCase.php
Dariusz Ruminski 4 years ago
parent
commit
05df75406f

+ 20 - 0
doc/rules/php_unit/php_unit_dedicate_assert_internal_type.rst

@@ -30,6 +30,26 @@ Example #1
 
 *Default* configuration.
 
+.. code-block:: diff
+
+   --- Original
+   +++ New
+   @@ -3,7 +3,7 @@
+    {
+        public function testMe()
+        {
+   -        $this->assertInternalType("array", $var);
+   -        $this->assertInternalType("boolean", $var);
+   +        $this->assertIsArray($var);
+   +        $this->assertIsBool($var);
+        }
+    }
+
+Example #2
+~~~~~~~~~~
+
+With configuration: ``['target' => '7.5']``.
+
 .. code-block:: diff
 
    --- Original

+ 12 - 0
doc/usage.rst

@@ -181,6 +181,18 @@ Then, add the following command to your CI:
 
 Where ``$COMMIT_RANGE`` is your range of commits, e.g. ``$TRAVIS_COMMIT_RANGE`` or ``HEAD~..HEAD``.
 
+Environment options
+-------------------
+
+The ``PHP_CS_FIXER_IGNORE_ENV`` environment variable can be used to ignore any environment requirements.
+This includes requirements like missing PHP extensions, unsupported PHP versions or by using HHVM.
+
+NOTE: Execution may be unstable when used.
+
+.. code-block:: console
+
+    $ PHP_CS_FIXER_IGNORE_ENV=1 php php-cs-fixer.phar fix /path/to/dir
+
 Exit code
 ---------
 

+ 4 - 0
php-cs-fixer

@@ -27,6 +27,10 @@ if (defined('HHVM_VERSION_ID')) {
     if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
         fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.\n");
     } else {
+        fwrite(STDERR, "To ignore this requirement please set `PHP_CS_FIXER_IGNORE_ENV`.\n");
+        fwrite(STDERR, "If you use PHP version higher than supported, you may experience code modified in a wrong way.\n");
+        fwrite(STDERR, "Please report such cases at https://github.com/FriendsOfPHP/PHP-CS-Fixer .\n");
+
         exit(1);
     }
 }

+ 13 - 0
src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php

@@ -69,6 +69,19 @@ final class MyTest extends \PHPUnit\Framework\TestCase
 }
 '
                 ),
+                new CodeSample(
+                    '<?php
+final class MyTest extends \PHPUnit\Framework\TestCase
+{
+    public function testMe()
+    {
+        $this->assertInternalType("array", $var);
+        $this->assertInternalType("boolean", $var);
+    }
+}
+',
+                    ['target' => PhpUnitTargetVersion::VERSION_7_5]
+                ),
             ],
             null,
             'Risky when PHPUnit methods are overridden or when project has PHPUnit incompatibilities.'