Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 0 additions & 156 deletions .phpstan/baseline.neon
Original file line number Diff line number Diff line change
@@ -1,173 +1,17 @@
parameters:
ignoreErrors:
-
message: '#^Method Bigcommerce\\Injector\\Adapter\\ArrayContainerAdapter\:\:__construct\(\) has parameter \$arrayContainer with generic interface ArrayAccess but does not specify its types\: TKey, TValue$#'
identifier: missingType.generics
count: 1
path: ../src/Adapter/ArrayContainerAdapter.php

-
message: '#^Method Bigcommerce\\Injector\\Adapter\\ArrayContainerAdapter\:\:__construct\(\) has parameter \$arrayContainer with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Adapter/ArrayContainerAdapter.php

-
message: '#^Property Bigcommerce\\Injector\\Adapter\\ArrayContainerAdapter\:\:\$arrayContainer type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Adapter/ArrayContainerAdapter.php

-
message: '#^Property Bigcommerce\\Injector\\Adapter\\ArrayContainerAdapter\:\:\$arrayContainer with generic interface ArrayAccess does not specify its types\: TKey, TValue$#'
identifier: missingType.generics
count: 1
path: ../src/Adapter/ArrayContainerAdapter.php

-
message: '#^Call to function is_object\(\) with object will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\Injector\:\:buildParameterArray\(\) has InvalidArgumentException in PHPDoc @throws tag but it''s not thrown\.$#'
identifier: throws.unusedType
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\Injector\:\:buildParameterArray\(\) has parameter \$methodSignature with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\Injector\:\:buildParameterArrayFromContainer\(\) has parameter \$methodSignature with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\Injector\:\:buildParameterArrayFromContainer\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\Injector\:\:buildParameterArray\(\) has parameter \$providedParameters with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\Injector\:\:buildParameterArray\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\Injector\:\:create\(\) has parameter \$parameters with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\Injector\:\:getAutoCreateWhiteList\(\) has invalid return type string\.$#'
identifier: class.notFound
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\Injector\:\:getAutoCreateWhiteList\(\) should return array\<string\> but returns array\<string\>\.$#'
identifier: return.type
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\Injector\:\:invoke\(\) has parameter \$parameters with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\Injector\:\:resolveParameter\(\) has parameter \$parameterData with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\Injector\:\:resolveParameter\(\) has parameter \$providedParameters with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Injector.php

-
message: '#^Method Bigcommerce\\Injector\\InjectorInterface\:\:create\(\) has parameter \$parameters with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/InjectorInterface.php

-
message: '#^Method Bigcommerce\\Injector\\InjectorInterface\:\:invoke\(\) has parameter \$parameters with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/InjectorInterface.php

-
message: '#^Method Bigcommerce\\Injector\\InjectorServiceProvider\:\:create\(\) has parameter \$parameters with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/InjectorServiceProvider.php

-
message: '#^Property Bigcommerce\\Injector\\Reflection\\CachingClassInspector\:\:\$constructorCache type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Reflection/CachingClassInspector.php

-
message: '#^Method Bigcommerce\\Injector\\Reflection\\CachingClassInspector\:\:getCallableConstructorSignature\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Reflection/CachingClassInspector.php

-
message: '#^Method Bigcommerce\\Injector\\Reflection\\ClassInspector\:\:getCallableConstructorSignature\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Reflection/ClassInspector.php

-
message: '#^Unable to resolve the template type T in call to method Bigcommerce\\Injector\\Reflection\\ClassInspector\:\:getReflectionClass\(\)$#'
identifier: argument.templateType
count: 1
path: ../src/Reflection/ClassInspector.php

-
message: '#^Method Bigcommerce\\Injector\\Reflection\\ClassInspectorInterface\:\:getCallableConstructorSignature\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: ../src/Reflection/ClassInspectorInterface.php

-
message: '#^Method Bigcommerce\\Injector\\Reflection\\ParameterInspector\:\:getMethodSignature\(\) has parameter \$refClass with generic class ReflectionClass but does not specify its types\: T$#'
identifier: missingType.generics
count: 1
path: ../src/Reflection/ParameterInspector.php

-
message: '#^Method Bigcommerce\\Injector\\Reflection\\ParameterInspector\:\:getSignatureByReflectionClass\(\) has parameter \$reflectionClass with generic class ReflectionClass but does not specify its types\: T$#'
identifier: missingType.generics
count: 1
path: ../src/Reflection/ParameterInspector.php

-
message: '#^Anonymous function has an unused use \$className\.$#'
identifier: closure.unusedUse
count: 1
path: ../src/ServiceProvider/BindingClosureFactory.php

-
message: '#^Parameter \#2 \$initializer of method ProxyManager\\Factory\\LazyLoadingValueHolderFactory\:\:createProxy\(\) expects Closure\(object\|null\=, ProxyManager\\Proxy\\VirtualProxyInterface\=, string\=, array\<string, mixed\>\=, Closure\|null\=\)\: bool, Closure\(mixed, mixed, mixed, mixed, mixed\)\: true given\.$#'
identifier: argument.type
Expand Down
4 changes: 2 additions & 2 deletions src/Adapter/ArrayContainerAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
class ArrayContainerAdapter implements ContainerInterface
{
/**
* @var array|\ArrayAccess
* @var array<string, mixed>|\ArrayAccess<string, mixed>
*/
private $arrayContainer;

/**
* ArrayContainerAdapter constructor.
* @param array|\ArrayAccess $arrayContainer
* @param array<string, mixed>|\ArrayAccess<string, mixed> $arrayContainer
*/
public function __construct($arrayContainer)
{
Expand Down
21 changes: 10 additions & 11 deletions src/Injector.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(private readonly ContainerInterface $container, priv
* - Index: [ 3 => new RedisCache()] will inject RedisCache to the 4th parameter (zero index)
*
* @param string $className The fully qualified class name for the object we're creating
* @param array $parameters An optional array of additional parameters to pass to the created objects constructor.
* @param array<int|string, mixed> $parameters An optional array of additional parameters to pass to the created objects constructor.
* @return object
* @throws InjectorInvocationException
* @throws InvalidArgumentException
Expand Down Expand Up @@ -110,7 +110,7 @@ public function create($className, $parameters = [])
*
* @param object $instance
* @param string $methodName
* @param array $parameters
* @param array<int|string, mixed> $parameters
* @return mixed
* @throws InjectorInvocationException
* @throws InvalidArgumentException
Expand Down Expand Up @@ -158,7 +158,7 @@ public function addAutoCreate($regex)
}

/**
* @return \string[]
* @return string[]
*/
public function getAutoCreateWhiteList()
{
Expand Down Expand Up @@ -193,12 +193,11 @@ public function canAutoCreate($className): bool
/**
* Construct the parameter array to be passed to a method call based on its parameter signature
*
* @param array $methodSignature
* @param array $providedParameters
* @return array
* @param array<int, array<string, mixed>> $methodSignature
* @param array<int|string, mixed> $providedParameters
* @return array<int, mixed>
* @throws InjectorInvocationException
* @throws MissingRequiredParameterException
* @throws InvalidArgumentException
* @throws ReflectionException
*/
private function buildParameterArray($methodSignature, $providedParameters)
Expand Down Expand Up @@ -229,8 +228,8 @@ private function buildParameterArray($methodSignature, $providedParameters)
* Fast path for the common case: resolve all parameters from the container, auto-create, or defaults
* Skips the 3 array_key_exists lookups per parameter that resolveParameter does against $providedParameters
*
* @param array $methodSignature
* @return array
* @param array<int, array<string, mixed>> $methodSignature
* @return array<int, mixed>
* @throws MissingRequiredParameterException
* @throws InjectorInvocationException
* @throws ReflectionException
Expand Down Expand Up @@ -277,8 +276,8 @@ private function buildParameterArrayFromContainer($methodSignature)
* - Default value against method signature
* - Auto create white list of classes to recursively create
* @param int $position
* @param array $parameterData
* @param array $providedParameters
* @param array<string, mixed> $parameterData
* @param array<int|string, mixed> $providedParameters
* @throws MissingRequiredParameterException
* @return mixed The resolved parameter value
*/
Expand Down
4 changes: 2 additions & 2 deletions src/InjectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface InjectorInterface
* - Index: [ 3 => new RedisCache()] will inject RedisCache to the 4th parameter (zero index)
*
* @param string $className The fully qualified class name for the object we're creating
* @param array $parameters An optional array of additional parameters to pass to the created objects constructor.
* @param array<int|string, mixed> $parameters An optional array of additional parameters to pass to the created objects constructor.
* @throws \Exception
* @return object
*/
Expand All @@ -50,7 +50,7 @@ public function create($className, $parameters = []);
*
* @param object $instance
* @param string $methodName
* @param array $parameters
* @param array<int|string, mixed> $parameters
* @return mixed
* @throws \Exception
*/
Expand Down
2 changes: 1 addition & 1 deletion src/InjectorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function getLazy(string $className, string $id = '')
/**
* Alias for Injector::create()
* @param string $className
* @param array $parameters
* @param array<int|string, mixed> $parameters
* @return object
* @throws \Exception
* @see InjectorInterface::create()
Expand Down
6 changes: 5 additions & 1 deletion src/Reflection/CachingClassInspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class CachingClassInspector implements ClassInspectorInterface
{
/**
* @var array<string, array{0: array|false|null}>
* @var array<string, array{0: array<string, mixed>[]|false|null}>
*/
private array $constructorCache = [];

Expand Down Expand Up @@ -104,6 +104,10 @@ public function getMethodSignature(string $class, string $method): array
return $value;
}

/**
* @param string $class
* @return array<string, mixed>[]|false|null
*/
public function getCallableConstructorSignature(string $class): array|false|null
{
if (isset($this->constructorCache[$class])) {
Expand Down
5 changes: 5 additions & 0 deletions src/Reflection/ClassInspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public function getMethodSignature(string $class, string $method): array
return $this->parameterInspector->getSignatureByReflectionClass($reflectionClass, $method);
}

/**
* @param string $class
* @return array<string, mixed>[]|false|null
* @throws ReflectionException
*/
public function getCallableConstructorSignature(string $class): array|false|null
{
$reflectionClass = $this->getReflectionClass($class);
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/ClassInspectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function getMethodSignature(string $class, string $method): array;
* Returns the constructor signature array if the constructor is public
*
* @param string $class
* @return array|false|null
* @return array<string, mixed>[]|false|null
* @throws ReflectionException
*/
public function getCallableConstructorSignature(string $class): array|false|null;
Expand Down
4 changes: 2 additions & 2 deletions src/Reflection/ParameterInspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ParameterInspector
{
/**
* Fetch the method signature of a method when we have already created a \ReflectionClass
* @param \ReflectionClass $reflectionClass
* @param \ReflectionClass<object> $reflectionClass
* @param string $methodName
* @return array{'name': string, 'type'?: string, 'default'?: mixed, 'variadic'?: bool}[]
* @throws \ReflectionException
Expand Down Expand Up @@ -58,7 +58,7 @@ public function getSignatureByReflectionMethod(ReflectionMethod $method): array
* - 'default' - If the parameter provides a default value, the default value.
* @param string $className Fully qualified class name
* @param string $methodName Name of the method we're inspecting
* @param \ReflectionClass $refClass Optional existing ReflectionClass for this class
* @param \ReflectionClass<object>|null $refClass Optional existing ReflectionClass for this class
* @return array{'name': string, 'type'?: string, 'default'?: mixed, 'variadic'?: bool}[] The signature
* of this methods parameters as an array.
* @throws \ReflectionException
Expand Down
1 change: 0 additions & 1 deletion src/ServiceProvider/BindingClosureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ private function createProxy($className, callable $serviceFactory, Container $ap
return $this->proxyFactory->createProxy(
$className,
function (&$wrappedObject, $proxy, $method, $parameters, &$initializer) use (
$className,
$serviceFactory,
$app
) {
Expand Down