mirror of
https://github.com/danog/psalm-plugin-phpunit.git
synced 2024-11-30 04:29:08 +01:00
Put asserts in proper place
This commit is contained in:
parent
fa76f65209
commit
b49f07b34b
@ -10,6 +10,7 @@ class Plugin implements PluginEntryPointInterface
|
||||
/** @return void */
|
||||
public function __invoke(RegistrationInterface $psalm, SimpleXMLElement $config = null)
|
||||
{
|
||||
$psalm->addStubFile(__DIR__ . '/stubs/Assert.php');
|
||||
$psalm->addStubFile(__DIR__ . '/stubs/TestCase.php');
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,9 @@
|
||||
"squizlabs/php_codesniffer": "^3.3"
|
||||
},
|
||||
"extra": {
|
||||
"pluginClass": "Psalm\\PhpUnitPlugin\\Plugin"
|
||||
"psalm": {
|
||||
"pluginClass": "Psalm\\PhpUnitPlugin\\Plugin"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
94
stubs/Assert.php
Normal file
94
stubs/Assert.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace PHPUnit\Framework;
|
||||
|
||||
abstract class Assert
|
||||
{
|
||||
/**
|
||||
* Asserts that a variable is of a given type.
|
||||
*
|
||||
* @param class-string $expected
|
||||
* @param mixed $actual
|
||||
* @param string $message
|
||||
*
|
||||
* @template T
|
||||
* @template-typeof T $expected
|
||||
* @psalm-assert T $actual
|
||||
*/
|
||||
public static function assertInstanceOf($expected, $actual, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a variable is of a given type.
|
||||
*
|
||||
* @param class-string $expected
|
||||
* @param mixed $actual
|
||||
* @param string $message
|
||||
*
|
||||
* @template T
|
||||
* @template-typeof T $expected
|
||||
* @psalm-assert !T $actual
|
||||
*/
|
||||
public static function assertNotInstanceOf($expected, $actual, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a condition is true.
|
||||
*
|
||||
* @param bool $condition
|
||||
* @param string $message
|
||||
*
|
||||
* @throws AssertionFailedError
|
||||
* @psalm-assert true $actual
|
||||
*/
|
||||
public static function assertTrue($condition, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a condition is not true.
|
||||
*
|
||||
* @param bool $condition
|
||||
* @param string $message
|
||||
*
|
||||
* @throws AssertionFailedError
|
||||
* @psalm-assert !true $actual
|
||||
*/
|
||||
public static function assertNotTrue($condition, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a condition is false.
|
||||
*
|
||||
* @param bool $condition
|
||||
* @param string $message
|
||||
*
|
||||
* @throws AssertionFailedError
|
||||
* @psalm-assert false $actual
|
||||
*/
|
||||
public static function assertFalse($condition, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a condition is not false.
|
||||
*
|
||||
* @param bool $condition
|
||||
* @param string $message
|
||||
*
|
||||
* @throws AssertionFailedError
|
||||
* @psalm-assert !false $actual
|
||||
*/
|
||||
public static function assertNotFalse($condition, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a variable is null.
|
||||
*
|
||||
* @param mixed $actual
|
||||
* @param string $message
|
||||
* @psalm-assert null $actual
|
||||
*/
|
||||
public static function assertNull($actual, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a variable is not null.
|
||||
*
|
||||
* @param mixed $actual
|
||||
* @param string $message
|
||||
* @psalm-assert !null $actual
|
||||
*/
|
||||
public static function assertNotNull($actual, $message = '') {}
|
||||
}
|
@ -13,92 +13,4 @@ abstract class TestCase extends Assert implements Test, SelfDescribing
|
||||
* @return MockObject&T
|
||||
*/
|
||||
public function createMock($class) {}
|
||||
|
||||
/**
|
||||
* Asserts that a variable is of a given type.
|
||||
*
|
||||
* @param class-string $expected
|
||||
* @param mixed $actual
|
||||
* @param string $message
|
||||
*
|
||||
* @template T
|
||||
* @template-typeof T $expected
|
||||
* @psalm-assert T $actual
|
||||
*/
|
||||
public static function assertInstanceOf($expected, $actual, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a variable is of a given type.
|
||||
*
|
||||
* @param class-string $expected
|
||||
* @param mixed $actual
|
||||
* @param string $message
|
||||
*
|
||||
* @template T
|
||||
* @template-typeof T $expected
|
||||
* @psalm-assert !T $actual
|
||||
*/
|
||||
public static function assertNotInstanceOf($expected, $actual, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a condition is true.
|
||||
*
|
||||
* @param bool $condition
|
||||
* @param string $message
|
||||
*
|
||||
* @throws AssertionFailedError
|
||||
* @psalm-assert true $actual
|
||||
*/
|
||||
public static function assertTrue($condition, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a condition is not true.
|
||||
*
|
||||
* @param bool $condition
|
||||
* @param string $message
|
||||
*
|
||||
* @throws AssertionFailedError
|
||||
* @psalm-assert !true $actual
|
||||
*/
|
||||
public static function assertNotTrue($condition, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a condition is false.
|
||||
*
|
||||
* @param bool $condition
|
||||
* @param string $message
|
||||
*
|
||||
* @throws AssertionFailedError
|
||||
* @psalm-assert false $actual
|
||||
*/
|
||||
public static function assertFalse($condition, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a condition is not false.
|
||||
*
|
||||
* @param bool $condition
|
||||
* @param string $message
|
||||
*
|
||||
* @throws AssertionFailedError
|
||||
* @psalm-assert !false $actual
|
||||
*/
|
||||
public static function assertNotFalse($condition, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a variable is null.
|
||||
*
|
||||
* @param mixed $actual
|
||||
* @param string $message
|
||||
* @psalm-assert null $actual
|
||||
*/
|
||||
public static function assertNull($actual, $message = '') {}
|
||||
|
||||
/**
|
||||
* Asserts that a variable is not null.
|
||||
*
|
||||
* @param mixed $actual
|
||||
* @param string $message
|
||||
* @psalm-assert !null $actual
|
||||
*/
|
||||
public static function assertNotNull($actual, $message = '') {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user