Skip to content

Commit

Permalink
chore(deps): update minimum php version required to 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alekitto committed Jun 9, 2024
1 parent adbee01 commit 8e74a36
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 46 deletions.
15 changes: 10 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"kcs/class-finder": "^0.3 || ^1.0"
"php": "^8.1",
"kcs/class-finder": ">=0.3,<1.0"
},
"require-dev": {
"friendsofphp/proxy-manager-lts": "*",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.23",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^10 || ^11",
"solido/dto-management": "*",
"solido/php-coding-standards": "dev-master",
"roave/security-advisories": "dev-master"
Expand Down Expand Up @@ -45,6 +46,10 @@
"exclude": [ ".github", "tests", ".gitignore" ]
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
}
}
10 changes: 5 additions & 5 deletions lib/DTOClassMapFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

class DTOClassMapFactory
{
/** @var string[] */
private array $dtoNamespaces;
/** @var string[] */
private array $excludedInterfaces;
/** @var string[] */
Expand All @@ -40,9 +38,11 @@ class DTOClassMapFactory
* @param string[] $dtoNamespaces
* @param string[] $excludedInterfaces
*/
public function __construct(array $dtoNamespaces, array $excludedInterfaces)
{
$this->dtoNamespaces = $dtoNamespaces;
public function __construct(
/** @var string[] */
private readonly array $dtoNamespaces,
array $excludedInterfaces,
) {
$this->excludedInterfaces = array_combine($excludedInterfaces, array_fill(0, count($excludedInterfaces), true));

$this->buildMap();
Expand Down
11 changes: 4 additions & 7 deletions lib/Rule/Construction/DisallowConstructionOfDTOObjects.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@

class DisallowConstructionOfDTOObjects implements Rule
{
private DTOClassMapFactory $dtoClassMapFactory;
private ReflectionProvider $reflectionProvider;

public function __construct(DTOClassMapFactory $dtoClassMapFactory, ReflectionProvider $reflectionProvider)
{
$this->dtoClassMapFactory = $dtoClassMapFactory;
$this->reflectionProvider = $reflectionProvider;
public function __construct(
private readonly DTOClassMapFactory $dtoClassMapFactory,
private readonly ReflectionProvider $reflectionProvider,
) {
}

public function getNodeType(): string
Expand Down
35 changes: 14 additions & 21 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<coverage>
<include>
<directory>lib</directory>
</include>
</coverage>

<php>
<ini name="error_reporting" value="-1"/>
</php>

<testsuites>
<testsuite name="Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php">
<php>
<ini name="error_reporting" value="-1"/>
</php>
<testsuites>
<testsuite name="Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>lib</directory>
</include>
</source>
</phpunit>
16 changes: 8 additions & 8 deletions tests/data/dto_resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
use function PHPStan\Testing\assertType;

function (ResolverInterface $resolver) {
assertType('mixed', $resolver->resolve('stdClass'));
assertType('mixed', $resolver->resolve(stdClass::class));
assertType('mixed', $resolver->resolve('unknown'));
assertType('mixed', $resolver->resolve(UnknownClass::class));
assertType('mixed', $resolver->resolve(NonDTO::class));
assertType('mixed', $resolver->resolve('Tests\DTO\v1\v1_0\NonDTO'));
assertType('mixed', $resolver->resolve(ExampleDTO::class));
assertType('mixed', $resolver->resolve('Tests\DTO\v1\v1_0\ExampleDTO'));
assertType('T of object (method Solido\DtoManagement\InterfaceResolver\ResolverInterface::resolve(), parameter)', $resolver->resolve('stdClass'));
assertType('T of object (method Solido\DtoManagement\InterfaceResolver\ResolverInterface::resolve(), parameter)', $resolver->resolve(stdClass::class));
assertType('T of object (method Solido\DtoManagement\InterfaceResolver\ResolverInterface::resolve(), parameter)', $resolver->resolve('unknown'));
assertType('T of object (method Solido\DtoManagement\InterfaceResolver\ResolverInterface::resolve(), parameter)', $resolver->resolve(UnknownClass::class));
assertType('T of object (method Solido\DtoManagement\InterfaceResolver\ResolverInterface::resolve(), parameter)', $resolver->resolve(NonDTO::class));
assertType('T of object (method Solido\DtoManagement\InterfaceResolver\ResolverInterface::resolve(), parameter)', $resolver->resolve('Tests\DTO\v1\v1_0\NonDTO'));
assertType('T of object (method Solido\DtoManagement\InterfaceResolver\ResolverInterface::resolve(), parameter)', $resolver->resolve(ExampleDTO::class));
assertType('T of object (method Solido\DtoManagement\InterfaceResolver\ResolverInterface::resolve(), parameter)', $resolver->resolve('Tests\DTO\v1\v1_0\ExampleDTO'));

assertType('Tests\Fixtures\DTO\Contracts\ExampleDTOInterface', $resolver->resolve(ExampleDTOInterface::class));
assertType('Tests\Fixtures\DTO\Contracts\ExampleDTOInterface', $resolver->resolve('Tests\Fixtures\DTO\Contracts\ExampleDTOInterface'));
Expand Down

0 comments on commit 8e74a36

Please sign in to comment.