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

Internal annotation is propagated to non internal child class #10913

Open
Braxilior opened this issue Apr 18, 2024 · 1 comment
Open

Internal annotation is propagated to non internal child class #10913

Braxilior opened this issue Apr 18, 2024 · 1 comment

Comments

@Braxilior
Copy link

Hello,

https://psalm.dev/r/fb3777b99c

MyClass uses ExternalCompatibilityClass but it triggers an InternalMethod error.

In my example, both methods calls the internal implementation but only example() triggers the error.

I'm not sure of the expected behaviour but I feel like both methods shouldn't trigger an error.

My example is a minimal reproduction of what's happening with the DoctrineBundle.

The documentations says :

     class YourEntityRepository extends ServiceEntityRepository
     {
         public function __construct(ManagerRegistry $registry)
         {
             parent::__construct($registry, YourEntity::class);
         }
     }

but ServiceEntityRepository extends ServiceEntityRepositoryProxy which is internal.

Copy link

I found these snippets:

https://psalm.dev/r/fb3777b99c
<?php

namespace B {
    /**
     * @internal Extend {@see ExternalCompatibilityClass} instead.
     */
    class InternalClass
    {
        public function example(): string
        {
            return 'example';
        }

        public function example2(): string
        {
            return 'example2';
        }
    }

    class ExternalCompatibilityClass extends InternalClass
    {
        public function example2(): string
        {
            return parent::example2();
        }
    }
}

namespace A {
    class MyClass extends \B\ExternalCompatibilityClass
    {   
        public function myExample(): void {
            $this->example();
            $this->example2();
        }
    }
}
Psalm output (using commit 08afc45):

ERROR: InternalMethod - 33:20 - The method B\InternalClass::example is internal to B but called from A\MyClass::myExample

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

No branches or pull requests

1 participant