Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/backward-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- "master"

env:
COMPOSER_ROOT_VERSION: "1.4.x-dev"
COMPOSER_ROOT_VERSION: "1.5.x-dev"

jobs:
backward-compatibility:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/compiler-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- "master"

env:
COMPOSER_ROOT_VERSION: "1.4.x-dev"
COMPOSER_ROOT_VERSION: "1.5.x-dev"

jobs:
compiler-tests:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- 'compiler/**'

env:
COMPOSER_ROOT_VERSION: "1.4.x-dev"
COMPOSER_ROOT_VERSION: "1.5.x-dev"

jobs:
result-cache-e2e-tests:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- "master"

env:
COMPOSER_ROOT_VERSION: "1.4.x-dev"
COMPOSER_ROOT_VERSION: "1.5.x-dev"

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- 'compiler/**'

env:
COMPOSER_ROOT_VERSION: "1.4.x-dev"
COMPOSER_ROOT_VERSION: "1.5.x-dev"

jobs:
static-analysis:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- 'compiler/**'

env:
COMPOSER_ROOT_VERSION: "1.4.x-dev"
COMPOSER_ROOT_VERSION: "1.5.x-dev"

jobs:
tests:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
"dev-master": "1.5-dev"
},
"patcher": {
"search": "patches"
Expand Down
112 changes: 56 additions & 56 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 34 additions & 4 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -2660,7 +2660,14 @@ private function resolveType(Expr $node): Type
continue;
}

return $dynamicFunctionReturnTypeExtension->getTypeFromFunctionCall($functionReflection, $node, $this);
$resolvedType = $dynamicFunctionReturnTypeExtension->getTypeFromFunctionCall(
$functionReflection,
$node,
$this,
);
if ($resolvedType !== null) {
return $resolvedType;
}
}

return ParametersAcceptorSelector::selectFromArgs(
Expand Down Expand Up @@ -5659,7 +5666,16 @@ private function exactInstantiation(New_ $node, string $className): ?Type
continue;
}

$resolvedTypes[] = $dynamicStaticMethodReturnTypeExtension->getTypeFromStaticMethodCall($constructorMethod, $methodCall, $this);
$resolvedType = $dynamicStaticMethodReturnTypeExtension->getTypeFromStaticMethodCall(
$constructorMethod,
$methodCall,
$this,
);
if ($resolvedType === null) {
continue;
}

$resolvedTypes[] = $resolvedType;
}

if (count($resolvedTypes) > 0) {
Expand Down Expand Up @@ -5835,15 +5851,29 @@ private function methodCallReturnType(Type $typeWithMethod, string $methodName,
continue;
}

$resolvedTypes[] = $dynamicMethodReturnTypeExtension->getTypeFromMethodCall($methodReflection, $methodCall, $this);
$resolvedType = $dynamicMethodReturnTypeExtension->getTypeFromMethodCall($methodReflection, $methodCall, $this);
if ($resolvedType === null) {
continue;
}

$resolvedTypes[] = $resolvedType;
}
} else {
foreach ($this->dynamicReturnTypeExtensionRegistry->getDynamicStaticMethodReturnTypeExtensionsForClass($className) as $dynamicStaticMethodReturnTypeExtension) {
if (!$dynamicStaticMethodReturnTypeExtension->isStaticMethodSupported($methodReflection)) {
continue;
}

$resolvedTypes[] = $dynamicStaticMethodReturnTypeExtension->getTypeFromStaticMethodCall($methodReflection, $methodCall, $this);
$resolvedType = $dynamicStaticMethodReturnTypeExtension->getTypeFromStaticMethodCall(
$methodReflection,
$methodCall,
$this,
);
if ($resolvedType === null) {
continue;
}

$resolvedTypes[] = $resolvedType;
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3325,7 +3325,11 @@ static function (): void {
if ($propertyReflection->canChangeTypeAfterAssignment()) {
$scope = $scope->assignExpression($var, $assignedExprType);
}
if (!$propertyReflection->getWritableType()->isSuperTypeOf($assignedExprType)->yes()) {
$declaringClass = $propertyReflection->getDeclaringClass();
if (
$declaringClass->hasNativeProperty($propertyName)
&& !$declaringClass->getNativeProperty($propertyName)->getNativeType()->accepts($assignedExprType, true)->yes()
) {
$throwPoints[] = ThrowPoint::createExplicit($scope, new ObjectType(TypeError::class), $assignedExpr, false);
}
} else {
Expand Down
Loading