Skip to content
Open
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
7 changes: 6 additions & 1 deletion src/Injector.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* Enable memoization of class reflections for improved performance when resolving the same objects multiple times.
* Note: Enabling this feature may increase memory usage.
*/
public function withCacheReflections(bool $cacheReflections = true): self

Check warning on line 45 in src/Injector.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "TrueValue": --- Original +++ New @@ @@ * Enable memoization of class reflections for improved performance when resolving the same objects multiple times. * Note: Enabling this feature may increase memory usage. */ - public function withCacheReflections(bool $cacheReflections = true) : self + public function withCacheReflections(bool $cacheReflections = false) : self { $new = clone $this; $new->cacheReflections = $cacheReflections;
{
$new = clone $this;
$new->cacheReflections = $cacheReflections;
Expand All @@ -69,7 +69,9 @@
* This will pass the string `'Hello World!'` as the first argument, and a formatter instance created
* by the DI container as the second argument.
*
* @param callable $callable callable to be invoked.
* @template TReturn
*
* @param callable(): TReturn $callable callable to be invoked.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea. We are going to render phpdoc with phpdocumentor and alike tools for API docs, and it does not support Psalm annotations as far as I know. Same for non-PhpStorm editors/IDEs.

* @param array $arguments The array of the function arguments.
* This can be either a list of arguments, or an associative array where keys are argument names.
*
Expand All @@ -78,6 +80,9 @@
* @throws ReflectionException
*
* @return mixed The callable return value.
*
* @psalm-param callable(...): TReturn $callable
* @psalm-return TReturn
*/
public function invoke(callable $callable, array $arguments = [])
{
Expand Down Expand Up @@ -236,7 +241,7 @@
throw $error;
}

if ($isVariadic) {

Check warning on line 244 in src/Injector.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "IfNegation": --- Original +++ New @@ @@ // Throw NotFoundExceptionInterface throw $error; } - if ($isVariadic) { + if (!$isVariadic) { return true; } return null;
return true;
}
return null;
Expand Down Expand Up @@ -336,7 +341,7 @@
private function getClassReflection(string $class): ReflectionClass
{
if ($this->cacheReflections) {
return $this->reflectionsCache[$class] ??= new ReflectionClass($class);

Check warning on line 344 in src/Injector.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "AssignCoalesce": --- Original +++ New @@ @@ private function getClassReflection(string $class) : ReflectionClass { if ($this->cacheReflections) { - return $this->reflectionsCache[$class] ??= new ReflectionClass($class); + return $this->reflectionsCache[$class] = new ReflectionClass($class); } return new ReflectionClass($class); } }
}

return new ReflectionClass($class);
Expand Down
2 changes: 1 addition & 1 deletion src/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
final class InvalidArgumentException extends ArgumentException
{
protected const EXCEPTION_MESSAGE = 'Invalid argument "%s" when calling "%s"%s. Non-interface argument should be'
. ' named explicitly when passed.';
. ' named explicitly when passed.';
}
2 changes: 1 addition & 1 deletion src/MissingInternalArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
final class MissingInternalArgumentException extends ArgumentException
{
protected const EXCEPTION_MESSAGE = 'Can not determine default value of parameter "%s" when calling "%s"%s because'
. ' it is PHP internal. Please specify argument explicitly.';
. ' it is PHP internal. Please specify argument explicitly.';
}
Loading