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
2 changes: 1 addition & 1 deletion src/IRI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ public function get_iri()
}
if ($this->ipath !== '') {
$iri .= $this->ipath;
} elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '') {
} elseif ($this->scheme !== null && !empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '') {
$iri .= $this->normalization[$this->scheme]['ipath'];
}
if ($this->iquery !== null) {
Expand Down
26 changes: 16 additions & 10 deletions utils/PHPStan/RegistryCallMethodReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
use PHPStan\Type\Type;
use PHPStan\Reflection\ReflectionProvider;
use PhpParser\Node\Expr\MethodCall;
use PHPStan\Type\Constant\ConstantStringType;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\ArrayType;
use PHPStan\Type\MixedType;

/**
Expand Down Expand Up @@ -58,19 +55,21 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method

$classType = $scope->getType($classNameArg);
$methodType = $scope->getType($methodNameArg);
$classStrings = $classType->getConstantStrings();
$methodStrings = $methodType->getConstantStrings();

if (!$classType instanceof ConstantStringType || !$methodType instanceof ConstantStringType) {
if (count($classStrings) !== 1 || count($methodStrings) !== 1) {
return new MixedType();
}

$className = $classType->getValue();
$className = $classStrings[0]->getValue();
if (!$this->reflectionProvider->hasClass($className)) {
return new MixedType();
}

$classReflection = $this->reflectionProvider->getClass($className);

$methodName = $methodType->getValue();
$methodName = $methodStrings[0]->getValue();
if (!$classReflection->hasMethod($methodName)) {
return new MixedType();
}
Expand All @@ -81,10 +80,17 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
if ($argumentsArg !== null) {
$argumentsType = $scope->getType($argumentsArg);

if ($argumentsType instanceof ConstantArrayType) {
$argumentTypes = $argumentsType->getValueTypes();
} elseif ($argumentsType instanceof ArrayType) {
$argumentTypes = [$argumentsType->getItemType()];
if ($argumentsType->isArray()->yes()) {
$constantArrays = $argumentsType->getConstantArrays();

if (count($constantArrays) === 0) {
$argumentTypes = [$argumentsType->getIterableValueType()];
} elseif (count($constantArrays) === 1) {
$constantArray = $constantArrays[0];
$argumentTypes = $constantArray->getValueTypes();
} else {
return new MixedType();
}
} else {
return new MixedType();
}
Expand Down
Loading