Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit 12091e5

Browse files
committed
Fixed wrong use of array_key_exists with ArrayObject
1 parent fd9d19b commit 12091e5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

phpstan.neon.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ parameters:
1515
- "#Casting to [a-z]+ something that's already [a-z]+#"
1616
- '#PHPDoc tag @throws with type Interop\\Container\\Exception\\ContainerException is not subtype of Throwable#'
1717
- '#PHPDoc tag @throws with type ([\w\\\|]+\|)?Psr\\Container\\ContainerExceptionInterface(\|[\w\\\|]+)? is not subtype of Throwable#'
18-
- '#Parameter \#2 \$search of function array_key_exists expects array, (array\|)?ArrayObject given#'
1918
# AbstractPluginManager::__construct() accepts more types:
2019
- '#Result of && is always false#'

src/AbstractFactory/ConfigAbstractFactory.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ final class ConfigAbstractFactory implements AbstractFactoryInterface
2121
*/
2222
public function canCreate(\Interop\Container\ContainerInterface $container, $requestedName)
2323
{
24-
if (! $container->has('config') || ! array_key_exists(self::class, $container->get('config'))) {
24+
if (! $container->has('config')) {
2525
return false;
2626
}
27+
2728
$config = $container->get('config');
29+
30+
if (! isset($config[self::class])) {
31+
return false;
32+
}
33+
2834
$dependencies = $config[self::class];
2935

3036
return is_array($dependencies) && array_key_exists($requestedName, $dependencies);
@@ -45,7 +51,7 @@ public function __invoke(\Interop\Container\ContainerInterface $container, $requ
4551
throw new ServiceNotCreatedException('Config must be an array or an instance of ArrayObject');
4652
}
4753

48-
if (! array_key_exists(self::class, $config)) {
54+
if (! isset($config[self::class])) {
4955
throw new ServiceNotCreatedException('Cannot find a `' . self::class . '` key in the config array');
5056
}
5157

0 commit comments

Comments
 (0)