-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
template-use
only works if trait and the class using the trait, has same name for generic type
#4423
Comments
template-use
only works if trait and the class using the trait have the same name for generic typetemplate-use
only works if trait and the class using the trait, has same name for generic type
One of your examples works to pure coincidence just because there's the same type variable |
Oh, what a coincidence then 😅 I'd love this to be in PHPStan. It'd solve a very large use case in Larastan/Laravel without writing bunch of extra extension code. Looks like this coincidental way is working for now though. |
I would also like to see this feature. I just never asked because I assumed it was coming sooner or later anyway (also my use case is small enough to be a minor irritation anyways). |
I added basic support for generic traits, but making it work for magic properties and methods defined via annotations is some extra complicated work, I'm not sure if it's even gonna be possible, but we'll see. phpstan/phpstan-src@8766923 |
@canvural After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
+PHP 8.2 (2 errors)
+==========
+
+35: Access to an undefined property Child<int>::$bar.
+35: Dumped type: *ERROR*
+
+PHP 7.1 – 8.1 (1 error)
+==========
+
35: Dumped type: Bar<K (class Foo, parameter)> Full reportPHP 8.2 (2 errors)
PHP 7.1 – 8.1 (1 error)
|
@canvural After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
+PHP 8.2 (2 errors)
+==========
+
+35: Access to an undefined property Child<int>::$bar.
+35: Dumped type: *ERROR*
+
+PHP 7.1 – 8.1 (1 error)
+==========
+
35: Dumped type: Bar<int> Full reportPHP 8.2 (2 errors)
PHP 7.1 – 8.1 (1 error)
|
@ondrejmirtes After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
+PHP 8.2 (2 errors)
+==========
+
+35: Access to an undefined property Child<int>::$bar.
+35: Dumped type: *ERROR*
+
+PHP 7.1 – 8.1 (1 error)
+==========
+
35: Dumped type: Bar<TT (class Foo, parameter)> Full reportPHP 8.2 (2 errors)
PHP 7.1 – 8.1 (1 error)
|
@canvural After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
+PHP 8.2 – 8.3 (2 errors)
+==========
+
+35: Access to an undefined property Child<int>::$bar.
+35: Dumped type: *ERROR*
+
+PHP 7.1 – 8.1 (1 error)
+==========
+
35: Dumped type: Bar<K (class Foo, parameter)> Full reportPHP 8.2 – 8.3 (2 errors)
PHP 7.1 – 8.1 (1 error)
|
@canvural After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
+PHP 8.2 – 8.3 (2 errors)
+==========
+
+35: Access to an undefined property Child<int>::$bar.
+35: Dumped type: *ERROR*
+
+PHP 7.1 – 8.1 (1 error)
+==========
+
35: Dumped type: Bar<int> Full reportPHP 8.2 – 8.3 (2 errors)
PHP 7.1 – 8.1 (1 error)
|
@ondrejmirtes After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
+PHP 8.2 – 8.3 (2 errors)
+==========
+
+35: Access to an undefined property Child<int>::$bar.
+35: Dumped type: *ERROR*
+
+PHP 7.1 – 8.1 (1 error)
+==========
+
35: Dumped type: Bar<TT (class Foo, parameter)> Full reportPHP 8.2 – 8.3 (2 errors)
PHP 7.1 – 8.1 (1 error)
|
Bug report
Not working: https://phpstan.org/r/7ae5f72d-9a22-4faf-a171-8c93994a5f1a
Working: https://phpstan.org/r/c2027941-0e2e-4ad7-a464-8a63c40d7ec5
Expected Output
Dumped type: Bar<int>
in both casesThe text was updated successfully, but these errors were encountered: