Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Dec 17, 2020
2 parents 39888ba + 302ba4a commit 35db9e9
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
20 changes: 20 additions & 0 deletions doc/rules/php_unit/php_unit_dedicate_assert_internal_type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,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
---------

Expand Down
4 changes: 4 additions & 0 deletions php-cs-fixer
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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);
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ public function testMe()
}
'
),
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.'
Expand Down
1 change: 0 additions & 1 deletion tests/Test/AbstractFixerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ final public function testFixerDefinitions()
// It may only shrink, never add anything to it.
$fixerNamesWithKnownMissingSamplesWithConfig = [ // @TODO 3.0 - remove this
'is_null', // has only one option which is deprecated
'php_unit_dedicate_assert_internal_type',
];

if (\count($configSamplesProvided) < 2) {
Expand Down

0 comments on commit 35db9e9

Please sign in to comment.