-
Notifications
You must be signed in to change notification settings - Fork 5
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
Not working with type hints of "Union Types" and "Intersection Types" #481
Comments
thanks for reporting @bluedasher13 |
@bluedasher13 does it happens if you use the option next version? Here goes an example of the setting:
|
@marabesi Furthermore, I have also discovered that "named arguments" can also cause errors. <?php
namespace App\Services\Project;
use App\Models\Bar1;
use App\Models\Bar2;
use App\Models\Bar3;
class Foo
{
public function __construct(?Bar2 $bar = null)
{
return json_encode(value: '', flags: 0);
}
} php-import-checker/package.json Line 58 in 4e3669a
https://github.com/nikic/PHP-Parser#php-parser |
Just a small hint on the php-parser version, this library is in typescript so there is no direct connection with the parser from nikita. This is the correct library: glayzzle/php-parser#486. The PHP version is still under development though. From the samples you shared it seems that the library is working as expected (see the pipeline with the new test cases added here. Nevertheless, the example you shared with json_encode seems to be working as expected as well, this is the version I have: I found an issue when trying to combine the type of parameters though: But this one will require an update from the library this project is using (I am not sure at the moment). I am not sure if it is possible to have a union type of array and an optional Bar2. Is it possible? For the time being what is exactly the outcome you expect from the examples you shared? For me here goes the output: Example 1: should highlight 2 unused imports - this seems to break in your example |
@bluedasher13 can you paste there the code you are using instead of printing it? It helps me to adds those as test cases in the pipeline. |
"Using type hints of "Union Types" or "Intersection Types" such as
array|Bar1
orBar1&Bar2
can cause the highlighting of the entire PHP file to malfunction."The text was updated successfully, but these errors were encountered: