Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/PHPStan/Command/AnalyseApplicationIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private function runPath(string $path, int $expectedStatusCode): string

$symfonyOutput = new SymfonyOutput(
$output,
new \PHPStan\Command\Symfony\SymfonyStyle(new SymfonyStyle($this->createMock(InputInterface::class), $output)),
new \PHPStan\Command\Symfony\SymfonyStyle(new SymfonyStyle($this->createStub(InputInterface::class), $output)),
);

$relativePathHelper = new FuzzyRelativePathHelper(new NullRelativePathHelper(), __DIR__, [], DIRECTORY_SEPARATOR);
Expand All @@ -88,7 +88,7 @@ private function runPath(string $path, int $expectedStatusCode): string
null,
null,
null,
$this->createMock(InputInterface::class),
$this->createStub(InputInterface::class),
);
$statusCode = $errorFormatter->formatErrors($analysisResult, $symfonyOutput);

Expand Down
16 changes: 8 additions & 8 deletions tests/PHPStan/Parser/CachedParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PHPStan\File\FileReader;
use PHPStan\Testing\PHPStanTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\MockObject\Stub;

class CachedParserTest extends PHPStanTestCase
{
Expand All @@ -21,7 +21,7 @@ public function testParseFileClearCache(
): void
{
$parser = new CachedParser(
$this->getParserMock(),
$this->getParserStub(),
$cachedNodesByStringCountMax,
);

Expand Down Expand Up @@ -62,19 +62,19 @@ public static function dataParseFileClearCache(): Generator
];
}

private function getParserMock(): Parser&MockObject
private function getParserStub(): Parser&Stub
{
$mock = $this->createMock(Parser::class);
$mock = $this->createStub(Parser::class);

$mock->method('parseFile')->willReturn([$this->getPhpParserNodeMock()]);
$mock->method('parseString')->willReturn([$this->getPhpParserNodeMock()]);
$mock->method('parseFile')->willReturn([$this->getPhpParserNodeStub()]);
$mock->method('parseString')->willReturn([$this->getPhpParserNodeStub()]);

return $mock;
}

private function getPhpParserNodeMock(): Node&MockObject
private function getPhpParserNodeStub(): Node&Stub
{
return $this->createMock(Node::class);
return $this->createStub(Node::class);
}

public function testParseTheSameFileWithDifferentMethod(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ public function testMethods(string $className, array $methods): void
{
$reflectionProvider = self::createReflectionProvider();
$class = $reflectionProvider->getClass($className);
$scope = $this->createMock(Scope::class);
$scope = $this->createStub(Scope::class);
$scope->method('isInClass')->willReturn(true);
$scope->method('getClassReflection')->willReturn($class);
$scope->method('canCallMethod')->willReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function testProperties(string $className, array $properties): void
{
$reflectionProvider = self::createReflectionProvider();
$class = $reflectionProvider->getClass($className);
$scope = $this->createMock(Scope::class);
$scope = $this->createStub(Scope::class);
$scope->method('isInClass')->willReturn(true);
$scope->method('getClassReflection')->willReturn($class);
$scope->method('canAccessProperty')->willReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function testDeprecatedAnnotations(bool $deprecated, string $className, ?
{
$reflectionProvider = self::createReflectionProvider();
$class = $reflectionProvider->getClass($className);
$scope = $this->createMock(Scope::class);
$scope = $this->createStub(Scope::class);
$scope->method('isInClass')->willReturn(true);
$scope->method('getClassReflection')->willReturn($class);
$scope->method('canAccessProperty')->willReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testFinalAnnotations(bool $final, string $className, array $fina
{
$reflectionProvider = self::createReflectionProvider();
$class = $reflectionProvider->getClass($className);
$scope = $this->createMock(Scope::class);
$scope = $this->createStub(Scope::class);
$scope->method('isInClass')->willReturn(true);
$scope->method('getClassReflection')->willReturn($class);
$scope->method('canAccessProperty')->willReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function testInternalAnnotations(bool $internal, string $className, array
{
$reflectionProvider = self::createReflectionProvider();
$class = $reflectionProvider->getClass($className);
$scope = $this->createMock(Scope::class);
$scope = $this->createStub(Scope::class);
$scope->method('isInClass')->willReturn(true);
$scope->method('getClassReflection')->willReturn($class);
$scope->method('canAccessProperty')->willReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testThrowsAnnotations(string $className, array $throwsAnnotation
{
$reflectionProvider = self::createReflectionProvider();
$class = $reflectionProvider->getClass($className);
$scope = $this->createMock(Scope::class);
$scope = $this->createStub(Scope::class);

foreach ($throwsAnnotations as $methodName => $type) {
$methodAnnotation = $class->getMethod($methodName, $scope);
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Reflection/FunctionReflectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function testMethodHasPhpdoc(string $className, string $methodName, ?stri
{
$reflectionProvider = self::createReflectionProvider();
$class = $reflectionProvider->getClass($className);
$scope = $this->createMock(Scope::class);
$scope = $this->createStub(Scope::class);
$scope->method('isInClass')->willReturn(true);
$scope->method('getClassReflection')->willReturn($class);
$scope->method('canAccessProperty')->willReturn(true);
Expand Down Expand Up @@ -180,7 +180,7 @@ public function testMethodReturnsByReference(string $className, string $methodNa
{
$reflectionProvider = self::createReflectionProvider();
$class = $reflectionProvider->getClass($className);
$scope = $this->createMock(Scope::class);
$scope = $this->createStub(Scope::class);
$scope->method('isInClass')->willReturn(true);
$scope->method('getClassReflection')->willReturn($class);
$scope->method('canAccessProperty')->willReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testMultipleDeprecationsAreJoined(): void

private function createDeprecatedMethod(TrinaryLogic $deprecated, ?string $deprecationText): ExtendedMethodReflection
{
$method = $this->createMock(ExtendedMethodReflection::class);
$method = $this->createStub(ExtendedMethodReflection::class);
$method->method('isDeprecated')->willReturn($deprecated);
$method->method('getDeprecatedDescription')->willReturn($deprecationText);
return $method;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testMultipleDeprecationsAreJoined(): void

private function createDeprecatedMethod(TrinaryLogic $deprecated, ?string $deprecationText): ExtendedMethodReflection
{
$method = $this->createMock(ExtendedMethodReflection::class);
$method = $this->createStub(ExtendedMethodReflection::class);
$method->method('isDeprecated')->willReturn($deprecated);
$method->method('getDeprecatedDescription')->willReturn($deprecationText);
return $method;
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Api/ApiRuleHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function testIsPhpStanCode(
): void
{
$rule = new ApiRuleHelper();
$scope = $this->createMock(Scope::class);
$scope = $this->createStub(Scope::class);
$scope->method('getNamespace')->willReturn($scopeNamespace);
$scope->method('getFile')->willReturn($scopeFile);
$this->assertSame($expected, $rule->isPhpStanCode($scope, $nameToCheck, $declaringFileNameToCheck));
Expand Down
Loading