Skip to content

Commit 65efd93

Browse files
committed
[BCB] PHPStanTestCase - extensions can no longer be provided by overriding methods from PHPStanTestCase. Use getAdditionalConfigFiles() instead.
1 parent db2f7fb commit 65efd93

File tree

3 files changed

+5
-67
lines changed

3 files changed

+5
-67
lines changed

src/Testing/PHPStanTestCase.php

+4-38
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,11 @@ public function createReflectionProvider(): ReflectionProvider
165165
$setterReflectionProviderProvider->setReflectionProvider($reflectionProvider);
166166

167167
$dynamicReturnTypeExtensionRegistryProvider = new DirectDynamicReturnTypeExtensionRegistryProvider(
168-
array_merge(self::getContainer()->getServicesByTag(BrokerFactory::DYNAMIC_METHOD_RETURN_TYPE_EXTENSION_TAG), $this->getDynamicMethodReturnTypeExtensions()),
169-
array_merge(self::getContainer()->getServicesByTag(BrokerFactory::DYNAMIC_STATIC_METHOD_RETURN_TYPE_EXTENSION_TAG), $this->getDynamicStaticMethodReturnTypeExtensions()),
170-
array_merge(self::getContainer()->getServicesByTag(BrokerFactory::DYNAMIC_FUNCTION_RETURN_TYPE_EXTENSION_TAG), $this->getDynamicFunctionReturnTypeExtensions())
171-
);
172-
$operatorTypeSpecifyingExtensionRegistryProvider = new DirectOperatorTypeSpecifyingExtensionRegistryProvider(
173-
$this->getOperatorTypeSpecifyingExtensions()
168+
self::getContainer()->getServicesByTag(BrokerFactory::DYNAMIC_METHOD_RETURN_TYPE_EXTENSION_TAG),
169+
self::getContainer()->getServicesByTag(BrokerFactory::DYNAMIC_STATIC_METHOD_RETURN_TYPE_EXTENSION_TAG),
170+
self::getContainer()->getServicesByTag(BrokerFactory::DYNAMIC_FUNCTION_RETURN_TYPE_EXTENSION_TAG)
174171
);
172+
$operatorTypeSpecifyingExtensionRegistryProvider = new DirectOperatorTypeSpecifyingExtensionRegistryProvider([]);
175173

176174
$broker = new Broker(
177175
$reflectionProvider,
@@ -605,38 +603,6 @@ public function getCurrentWorkingDirectory(): string
605603
return $this->getFileHelper()->normalizePath(__DIR__ . '/../..');
606604
}
607605

608-
/**
609-
* @return \PHPStan\Type\DynamicMethodReturnTypeExtension[]
610-
*/
611-
public function getDynamicMethodReturnTypeExtensions(): array
612-
{
613-
return [];
614-
}
615-
616-
/**
617-
* @return \PHPStan\Type\DynamicStaticMethodReturnTypeExtension[]
618-
*/
619-
public function getDynamicStaticMethodReturnTypeExtensions(): array
620-
{
621-
return [];
622-
}
623-
624-
/**
625-
* @return \PHPStan\Type\DynamicFunctionReturnTypeExtension[]
626-
*/
627-
public function getDynamicFunctionReturnTypeExtensions(): array
628-
{
629-
return [];
630-
}
631-
632-
/**
633-
* @return \PHPStan\Type\OperatorTypeSpecifyingExtension[]
634-
*/
635-
public function getOperatorTypeSpecifyingExtensions(): array
636-
{
637-
return [];
638-
}
639-
640606
/**
641607
* @param \PhpParser\PrettyPrinter\Standard $printer
642608
* @param \PHPStan\Reflection\ReflectionProvider $reflectionProvider

tests/PHPStan/Rules/Comparison/IfConstantConditionRuleTest.php

-29
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22

33
namespace PHPStan\Rules\Comparison;
44

5-
use PhpParser\Node\Expr\FuncCall;
6-
use PHPStan\Analyser\Scope;
7-
use PHPStan\Reflection\FunctionReflection;
8-
use PHPStan\Type\Constant\ConstantBooleanType;
9-
use PHPStan\Type\DynamicFunctionReturnTypeExtension;
10-
use PHPStan\Type\Type;
11-
125
/**
136
* @extends \PHPStan\Testing\RuleTestCase<IfConstantConditionRule>
147
*/
@@ -39,28 +32,6 @@ protected function shouldTreatPhpDocTypesAsCertain(): bool
3932
return $this->treatPhpDocTypesAsCertain;
4033
}
4134

42-
/**
43-
* @return DynamicFunctionReturnTypeExtension[]
44-
*/
45-
public function getDynamicFunctionReturnTypeExtensions(): array
46-
{
47-
return [
48-
new class implements DynamicFunctionReturnTypeExtension {
49-
50-
public function isFunctionSupported(FunctionReflection $functionReflection): bool
51-
{
52-
return $functionReflection->getName() === 'always_true';
53-
}
54-
55-
public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): Type
56-
{
57-
return new ConstantBooleanType(true);
58-
}
59-
60-
},
61-
];
62-
}
63-
6435
public function testRule(): void
6536
{
6637
$this->treatPhpDocTypesAsCertain = true;

tests/PHPStan/Rules/Comparison/data/function-definition.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
/** @return true */
34
function always_true()
45
{
56
return true;

0 commit comments

Comments
 (0)