Skip to content

Commit c82fd6c

Browse files
committed
Subtracted mixed component type even for array access
1 parent 6d06a10 commit c82fd6c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Type/Nette/ComponentModelArrayAccessDynamicReturnTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function getTypeFromMethodCall(
4141
$defaultType = ParametersAcceptorSelector::selectSingle($calledOnType->getMethod('createComponent', $scope)->getVariants())->getReturnType();
4242
$defaultType = TypeCombinator::remove($defaultType, new NullType());
4343
if ($defaultType->isSuperTypeOf(new ObjectType('Nette\ComponentModel\IComponent'))->yes()) {
44-
$defaultType = new MixedType();
44+
$defaultType = new MixedType(false, new NullType());
4545
}
4646
$args = $methodCall->getArgs();
4747
if (count($args) !== 1) {

tests/Type/Nette/data/componentModelArrayAccess.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ public function createComponent(string $name): AnotherControl {
3535

3636
$someControl = new SomeControl();
3737
assertType('PHPStan\Type\Nette\Data\ComponentModelArrayAccess\SomeControl', $someControl['some']);
38-
assertType('mixed', $someControl['unknown']);
38+
assertType('mixed~null', $someControl['unknown']);
3939

4040
$anotherControl = new AnotherControl();
4141
assertType('PHPStan\Type\Nette\Data\ComponentModelArrayAccess\AnotherControl', $anotherControl['another']);
4242
assertType('PHPStan\Type\Nette\Data\ComponentModelArrayAccess\SomeControl', $anotherControl['some']);
43-
assertType('mixed', $anotherControl['unknown']);
43+
assertType('mixed~null', $anotherControl['unknown']);
4444

4545
$overrideCreateControl = new OverrideCreateControl();
4646
assertType('PHPStan\Type\Nette\Data\ComponentModelArrayAccess\AnotherControl', $overrideCreateControl['some']);

0 commit comments

Comments
 (0)