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
Assertion::isInstanceOf is not working as expected #3
Comments
Hi, you’re using webmozart/assert but you have installed extension for
beberlei/assert. Please install the right extension.
On Sun, 17 Feb 2019 at 10:29, Robert Freigang ***@***.***> wrote:
Given controller:
# src/Controller/EventController.php<?phpdeclare(strict_types=1);namespace App\Controller;use App\Entity\User;use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;use Symfony\Component\Routing\Annotation\Route;use Symfony\Component\Security\Core\User\UserInterface;use Webmozart\Assert\Assert;class EventController{ /** * @param UserInterface|User $user * * @return array * @route("/events", name="event_list") * @template(template="event/list.html.twig") * */ public function __invoke(UserInterface $user): array { Assert::isInstanceOf($user, User::class); $team = $user->getTeams(); ...
Given User class:
<?phpdeclare(strict_types=1);namespace App\Entity;...use FOS\UserBundle\Model\User as BaseUser; # this one implements \Symfony\Component\Security\Core\User\UserInterface...class User extends BaseUser{ /** * @return Collection|Team[] */ public function getTeams() { ... }
Given phpstan.neon
parameters:
level: 3
paths:
- %currentWorkingDirectory%/src
includes:
- vendor/phpstan/phpstan-beberlei-assert/extension.neon
excludes_analyse:
- %currentWorkingDirectory%/src/Migrations/Version*.php
parameters:
symfony:
container_xml_path: %rootDir%/../../../var/cache/dev/srcDevDebugProjectContainer.xml
Given phpstan-output:
------ -----------------------------------------------------------------
Line Controller/EventController.php
------ -----------------------------------------------------------------
25 Call to an undefined method
Symfony\Component\Security\Core\User\UserInterface::getTeams().
------ -----------------------------------------------------------------
Expected phpstan-output:
[OK] No errors
Am I missing something?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAGZuPl13gdD8HXbCI8nMUx3mnuObD5Uks5vOSDtgaJpZM4a_dUW>
.
--
Ondřej Mirtes
|
Oh, I'm sorry. I tried both in my project and this was just a ticket creation issue. I have corrected the original post (and also tested it locally again - it's not working). |
Can you please create a repository that reproduces this problem?
On Sun, 17 Feb 2019 at 15:57, Robert Freigang ***@***.***> wrote:
Hi, you’re using webmozart/assert but you have installed extension for
beberlei/assert. Please install the right extension.
...
-- Ondřej Mirtes
Oh, I'm sorry. I tried both in my project and this was just a ticket
creation issue. I have corrected the original post (and also tested it
locally again - it's not working).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGZuBPKc58TRhhivOxbl21mgPWgVn61ks5vOW2_gaJpZM4a_dUW>
.
--
Ondřej Mirtes
|
I sent you a pull request that fixes your problem (robertfausk/phpstan-assert-instance-of#1). There were two issues (that I fixed in separate commits)
|
Alright thanks. 😀 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Given controller:
Given User class:
Given phpstan.neon
Given phpstan-output:
Expected phpstan-output:
Am I missing something?
PS: I have the same issue with https://github.com/phpstan/phpstan-webmozart-assert. I will open an issue there if this one gets confirmed and if it's not a misconfiguration or misuse on my side.
The text was updated successfully, but these errors were encountered: