Merge pull request #4 from weirdan/prophecy-support

Prophecy support
This commit is contained in:
Matthew Brown 2018-12-08 17:55:26 -05:00 committed by GitHub
commit 059684417f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 13 deletions

View File

@ -14,5 +14,6 @@ class Plugin implements PluginEntryPointInterface
$psalm->addStubFile(__DIR__ . '/stubs/TestCase.php');
$psalm->addStubFile(__DIR__ . '/stubs/MockBuilder.php');
$psalm->addStubFile(__DIR__ . '/stubs/InvocationMocker.php');
$psalm->addStubFile(__DIR__ . '/stubs/Prophecy.php');
}
}

View File

@ -29,7 +29,6 @@
"scripts" : {
"check": [
"@cs-check",
"@test",
"@analyze"
],
"analyze": "psalm",

View File

@ -9,6 +9,7 @@
<directory name="." />
<ignoreFiles>
<directory name="vendor" />
<directory name="stubs" />
</ignoreFiles>
</projectFiles>
@ -16,17 +17,5 @@
<LessSpecificReturnType errorLevel="info" />
<PropertyNotSetInConstructor>
<errorLevel type="suppress">
<directory name="tests" />
</errorLevel>
</PropertyNotSetInConstructor>
<TypeCoercion>
<errorLevel type="suppress">
<directory name="tests" />
</errorLevel>
</TypeCoercion>
</issueHandlers>
</psalm>

26
stubs/Prophecy.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace Prophecy\Prophecy {
/** @template T */
class ObjectProphecy implements ProphecyInterface
{
/** @return T */
public function reveal() {}
}
class MethodProphecy
{
public function willReturn(...$values): self {}
}
}
namespace Prophecy {
use Prophecy\Argument\Token;
class Argument
{
/** @param callable():bool $callback */
public static function that(callable $callback): Token\CallbackToken {}
/** @param mixed ...$tokens */
public static function allOf(...$tokens): Token\LogicalAndToken {}
}
}

View File

@ -24,4 +24,12 @@ abstract class TestCase extends Assert implements Test, SelfDescribing
* @return MockBuilder<T>
*/
public function getMockBuilder(string $className) {}
/**
* @template T
* @template-typeof T $classOrInterface
* @param class-string $classOrInterface
* @return ObjectProphecy<T>
*/
public function prophesize($classOrInterface): ObjectProphecy {}
}