Skip to content
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

generic errors #59

Open
staabm opened this issue Jan 15, 2025 · 3 comments · May be fixed by #61
Open

generic errors #59

staabm opened this issue Jan 15, 2025 · 3 comments · May be fixed by #61

Comments

@staabm
Copy link
Contributor

staabm commented Jan 15, 2025

I wonder why we get a error here:

grafik

the type the error is suggesting, is already in place?

@TomasVotruba
Copy link
Member

That would be false positive.

@staabm
Copy link
Contributor Author

staabm commented Jan 15, 2025

reproducer:

<?php

/**
 * @template T
 */
class GenericA {
}

class User {
    /** @param GenericA<string> $g */
    public function doFoo(GenericA $g):void {

    }
}

/** @param GenericA<string> $g */
function doFoo($g):void {
    $user = new User();
    $user->doFoo($g);
}

leads

 ------ ----------------------------------------------------------------------------------------- 
  11     Parameters should have "GenericA<string>" types as the only types passed to this method  
         🪪  typePerfect.narrowPublicClassMethodParamType                                         
 ------ ----------------------------------------------------------------------------------------- 

@staabm staabm linked a pull request Jan 16, 2025 that will close this issue
@staabm
Copy link
Contributor Author

staabm commented Jan 16, 2025

another interessting repro simliar but different:

<?php

/**
 * @template T
 */
class GenericA {
}

/**
 * @template T of string
 */
class User {
    /**
     * @param GenericA<T> $g
     */
    public function doFoo(GenericA $g):void {

    }
}

/** @param GenericA<string> $g */
function doFoo($g):void {
    $user = new User();
    $user->doFoo($g);
}

leads

 ------ ----------------------------------------------------------------------------------------- 
  16     Parameters should have "GenericA<string>" types as the only types passed to this method  
         🪪  typePerfect.narrowPublicClassMethodParamType                                         
 ------ ----------------------------------------------------------------------------------------- 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants