Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest PHP 8.1 syntax #247

Merged
merged 1 commit into from
Nov 3, 2024
Merged
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
3 changes: 1 addition & 2 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.22.2@d768d914152dbbf3486c36398802f74e80cfde48">
<files psalm-version="5.23.1@8471a896ccea3526b26d082f4461eeea467f10a4">
<file src="src/AbstractFactory/ConfigAbstractFactory.php">
<InvalidStringClass>
<code><![CDATA[new $requestedName(...$arguments)]]></code>
</InvalidStringClass>
<MixedArgument>
<code><![CDATA[$serviceDependencies]]></code>
<code><![CDATA[$serviceDependencies]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$config[self::class]]]></code>
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractFactory/ConfigAbstractFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __invoke(ContainerInterface $container, string $requestedName, ?
);
}

$arguments = array_map([$container, 'get'], $serviceDependencies);
$arguments = array_map($container->get(...), $serviceDependencies);

return new $requestedName(...$arguments);
}
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractFactory/ReflectionBasedAbstractFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
*/
final class ReflectionBasedAbstractFactory implements AbstractFactoryInterface
{
private ConstructorParameterResolverInterface $constructorParameterResolver;
private readonly ConstructorParameterResolverInterface $constructorParameterResolver;

/**
* Allows overriding the internal list of aliases. These should be of the
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ abstract class AbstractPluginManager implements PluginManagerInterface
*/
protected array $shared = [];

private ServiceManager $plugins;
private readonly ServiceManager $plugins;

/**
* @param ServiceManagerConfiguration $config
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/CyclicAliasException.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private static function printReferencesMap(array $aliases): string
*/
private static function printCycles(array $detectedCycles): string
{
return "[\n" . implode("\n", array_map([self::class, 'printCycle'], $detectedCycles)) . "\n]";
return "[\n" . implode("\n", array_map(self::printCycle(...), $detectedCycles)) . "\n]";
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
use InvalidArgumentException as SplInvalidArgumentException;
use Laminas\ServiceManager\Initializer\InitializerInterface;

use function gettype;
use function is_object;
use function get_debug_type;
use function sprintf;

/**
Expand All @@ -22,7 +21,7 @@ public static function fromInvalidInitializer(mixed $initializer): self
'An invalid initializer was registered. Expected a callable or an'
. ' instance of "%s"; received "%s"',
InitializerInterface::class,
is_object($initializer) ? $initializer::class : gettype($initializer)
get_debug_type($initializer)
));
}
}
2 changes: 1 addition & 1 deletion test/Proxy/LazyServiceFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static function ($className, $initializer) use ($expectedService, $proxy): MockO
}
);

$result = $this->factory->__invoke($this->container, 'fooService', [$callback, 'callback']);
$result = $this->factory->__invoke($this->container, 'fooService', $callback->callback(...));

self::assertSame($expectedService, $result, 'service created not match the expected');
}
Expand Down
6 changes: 1 addition & 5 deletions test/TestAsset/FactoryObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@

final class FactoryObject
{
/** @var mixed */
public $dependency;

/**
* @param mixed $dependency
*/
public function __construct($dependency)
public function __construct(public $dependency)
{
$this->dependency = $dependency;
}
}
5 changes: 1 addition & 4 deletions test/TestAsset/InvokableObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@

class InvokableObject
{
public array $options;

public function __construct(array $options = [])
public function __construct(public array $options = [])
{
$this->options = $options;
}

public function getOptions(): array
Expand Down