New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Psalm could not infer this type being passed inside the php8 attribute #7685
Comments
Hey @taras-pinchuk-uinno, can you reproduce the issue on https://psalm.dev ? |
|
I found these snippets: https://psalm.dev/r/344b174fa6<?php
#[Attribute]
class B{
public function __construct(
?array $listOfB = null
){
}
}
#[Attribute(Attribute::TARGET_CLASS)]
class A {
/**
* @param B[] $listOfB
**/
public function __construct(
?array $listOfB = null
){
}
}
//That doesnt works
#[A([new B])]
class C{
}
//This Work
new A([new B]);
|
Two issues here, first, we probably shouldn't be using |
facing same problem, while trying to build api documentation with "zircote/swagger-php": use OpenApi\Attributes as OA;
class GetProductController
{
#[OA\PathParameter(
parameter: "productId",
name: "productId",
description: "Product Id, to get information about",
schema: new OA\Schema(
format: "uuid"
)
)]
public function __invoke(Request $request): Response
{
}
} I get |
This bug introduced in 4.20.0 use OpenApi\Attributes as OA;
#[OA\Parameter(
schema: new OA\Schema(),
)]
public function __invoke(Request $request): Response {} Problem occured at if ($type->isMixed()) {
return;
}
$type_expr = StubsGenerator::getExpressionFromType(
$type
); On version 4.19.0:
On version 4.20.0
But \Psalm\Internal\Stubs\Generator\StubsGenerator::getExpressionFromType does not know about TNamedObject. So, downgrate to 4.19.0 may fix the problem temporary |
Psalm version: 4.20.0
Php version: 8.1
Error ouptput:
The text was updated successfully, but these errors were encountered: