The call to NativeLoader::__construct() has too many arguments starting with $providers->all().
This check compares calls to functions or methods with their respective definitions.
If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the
check may pick up the wrong definition and report false positives. One codebase
where this has been known to happen is Wordpress.
In this case you can add the @ignorePhpDoc
annotation to the duplicate definition and it will be ignored.
Loading history...
15
}
16
17
public function getCache()
18
{
19
return $this->cache;
20
}
21
22
public function clearCache()
23
{
24
$this->cache = [];
25
}
26
27
public function load($filename)
28
{
29
return $this->loadFile($filename);
30
}
31
32
/**
33
* {@inheritdoc}
34
*/
35
protected function instantiateFixtures(array $fixtures)
It seems like you code against a specific sub-type and not the parent class Nelmio\Alice\Loader\NativeLoader as the method instantiateFixtures() does only exist in the following sub-classes of Nelmio\Alice\Loader\NativeLoader: Knp\FriendlyContexts\Alice\Fixtures\Loader. Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example:
abstractclassUser{/** @return string */abstractpublicfunctiongetPassword();}classMyUserextendsUser{publicfunctiongetPassword(){// return something}publicfunctiongetDisplayName(){// return some name.}}classAuthSystem{publicfunctionauthenticate(User$user){$this->logger->info(sprintf('Authenticating %s.',$user->getDisplayName()));// do something.}}
In the above example, the authenticate() method works fine as long as you just pass
instances of MyUser. However, if you now also want to pass a different sub-classes
of User which does not have a getDisplayName() method, the code will break.
classAuthSystem{publicfunctionauthenticate(User$user){if($userinstanceofMyUser){$this->logger->info(/** ... */);}// or alternativelyif(!$userinstanceofMyUser){thrownew\LogicException('$user must be an instance of MyUser, '.'other instances are not supported.');}}}
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.