Rule php_unit_dedicate_assert_internal_type¶
PHPUnit assertions like assertIsArray should be used over
assertInternalType.
Warning¶
Using this rule is risky¶
Risky when PHPUnit methods are overridden or when project has PHPUnit incompatibilities.
Configuration¶
target¶
Target version of PHPUnit.
Allowed values: '7.5' and 'newest'
Default value: 'newest'
Examples¶
Example #1¶
Default configuration.
--- Original
+++ New
<?php
final class MyTest extends \PHPUnit\Framework\TestCase
{
public function testMe()
{
- $this->assertInternalType("array", $var);
- $this->assertInternalType("boolean", $var);
+ $this->assertIsArray($var);
+ $this->assertIsBool($var);
}
}
Example #2¶
With configuration: ['target' => '7.5'].
--- Original
+++ New
<?php
final class MyTest extends \PHPUnit\Framework\TestCase
{
public function testMe()
{
- $this->assertInternalType("array", $var);
- $this->assertInternalType("boolean", $var);
+ $this->assertIsArray($var);
+ $this->assertIsBool($var);
}
}
Rule sets¶
The rule is part of the following rule sets:
@PHPUnit7x5Migration:risky with config:
['target' => '7.5']@PHPUnit8x4Migration:risky with config:
['target' => '7.5']@PHPUnit9x1Migration:risky with config:
['target' => '7.5']@PHPUnit10x0Migration:risky with config:
['target' => '7.5']@PHPUnit75Migration:risky (deprecated) with config:
['target' => '7.5']@PHPUnit84Migration:risky (deprecated) with config:
['target' => '7.5']@PHPUnit91Migration:risky (deprecated) with config:
['target' => '7.5']@PHPUnit100Migration:risky (deprecated) with config:
['target' => '7.5']
References¶
Fixer class: PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertInternalTypeFixer
Test class: PhpCsFixer\Tests\Fixer\PhpUnit\PhpUnitDedicateAssertInternalTypeFixerTest
The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.