Skip to content

Commit

Permalink
Merge pull request #247 from samsonasik/update-to-php81-syntax
Browse files Browse the repository at this point in the history
Update to latest PHP 8.1 syntax
  • Loading branch information
gsteel authored Nov 3, 2024
2 parents 0bee163 + 5c30f98 commit bcc644d
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 19 deletions.
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

0 comments on commit bcc644d

Please sign in to comment.