title: Correct type hint error thrown by PHPStan on UserInterface in Symfony project
body: <p>I've recently started using <strong>PHPStan</strong> (version 0.12.19) on a <strong>Symfony 3.4</strong> project but I'm getting an error which seems like it should have been simple to resolve but I'm struggling to figure out.</p>
  
  <p>Currently running at level 7. Here's the error I get when I run:</p>
  
  <p><code>vendor/bin/phpstan analyse</code></p>
  
  <pre><code>------ --------------------------------------------------------------------------------------------------------------
    Line   src/AppBundle/Controller/MapController.php
   ------ --------------------------------------------------------------------------------------------------------------
    94     Parameter #1 $user of static method AppBundle\Entity\MapMarker::createMapMarker() expects
           Symfony\Component\Security\Core\User\UserInterface, object given.
  </code></pre>
  
  <p>This is the important parts of <strong>MapController.php</strong>:</p>
  
  <pre><code>    $user = $this-&gt;getUser();
  
       $mapMarker = MapMarker::createMapMarker(
              $user,
              $latitude,
              $longitude
          );
  </code></pre>
  
  <p>The getUser method is the Symfony one so I can't change this part: <a href="https://github.com/symfony/symfony/blob/3.4/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php#L444" rel="nofollow noreferrer">https://github.com/symfony/symfony/blob/3.4/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php#L444</a>:</p>
  
  <pre><code>/**
       * Get a user from the Security Token Storage.
       *
       * @return UserInterface|object|null
       *
       * @throws \LogicException If SecurityBundle is not available
       *
       * @see TokenInterface::getUser()
       *
       * @final since version 3.4
       */
      protected function getUser()
      {
          if (!$this-&gt;container-&gt;has('security.token_storage')) {
              throw new \LogicException('The SecurityBundle is not registered in your application. Try running "composer require symfony/security-bundle".');
          }
  
          if (null === $token = $this-&gt;container-&gt;get('security.token_storage')-&gt;getToken()) {
              return null;
          }
  
          if (!\is_object($user = $token-&gt;getUser())) {
              // e.g. anonymous authentication
              return null;
          }
  
          return $user;
      }
  </code></pre>
  
  <p>And the important parts of <strong>MapMarker.php</strong>:</p>
  
  <pre><code>/**
       * @param UserInterface $user
       * @param double $latitude
       * @param double $longitude
       */
      private function __construct(UserInterface $user, $latitude, $longitude) {
          $this-&gt;createdBy = $user;
          $this-&gt;latitude = $latitude;
          $this-&gt;longitude = $longitude;
      }
  
      /**
       * @param UserInterface $user
       * @param double $latitude
       * @param double $longitude
       * @return MapMarker
       */
      public static function createMapMarker(UserInterface $user, $latitude, $longitude): MapMarker
      {
          return new self($user, $latitude, $longitude);
      }
  </code></pre>
  
  <p>When I dump out <code>$user instanceof UserInterface</code> it returns true - so as far as I can tell it IS passing a UserInterface object, not just an "object" as PHPStan is indicating.</p>
  
  <p>And finally, here's my phpstan.neon config file:</p>
  
  <pre><code>parameters:
      level: 7
      paths:
          - src
          - tests
      checkGenericClassInNonGenericObjectType: false
      checkMissingIterableValueType: false
  </code></pre>
  
  <p>What am I missing?</p>