Skip to content

Commit

Permalink
Merge pull request #42 from acelaya-forks/feature/phpstan-2
Browse files Browse the repository at this point in the history
Update to PHPStan 2.0
  • Loading branch information
acelaya authored Nov 12, 2024
2 parents 6ebb0e5 + bba2b8d commit 5b57679
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this

### Changed
* Update shlinkio coding standard to v2.4
* Update to PHPStan 2.0

### Deprecated
* *Nothing*
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"require-dev": {
"cuyz/valinor": "^1.12",
"devster/ubench": "^2.1",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^11.4",
"psr/simple-cache": "^2.0",
"roave/security-advisories": "dev-master",
Expand Down
1 change: 1 addition & 0 deletions functions/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function putNotYetDefinedEnv(string $key, mixed $value): void
return;
}

// @phpstan-ignore argument.type
$formattedValue = formatEnvVarValueOrNull($value);
if ($formattedValue === null) {
return;
Expand Down
6 changes: 5 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
parameters:
level: 8
level: 9
paths:
- functions
- src
- test
ignoreErrors:
- identifier: missingType.iterableValue
2 changes: 2 additions & 0 deletions src/Factory/ValinorConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static function __callStatic(string $name, array $arguments): mixed
$mapper = self::getMapper($container);
$options = $container->get($name);

// @phpstan-ignore argument.type
return $mapper->map($serviceName, Source::array($options)->camelCaseKeys());
}

Expand All @@ -33,6 +34,7 @@ private static function getMapper(ContainerInterface $container): TreeMapper

$mapper = (new MapperBuilder())->allowSuperfluousKeys();
if ($container->has(CacheInterface::class)) {
// @phpstan-ignore argument.type
return $mapper = $mapper->withCache($container->get(CacheInterface::class))->mapper();
}

Expand Down
18 changes: 9 additions & 9 deletions test/Factory/DottedAccessConfigAbstractFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public function setUp(): void
}

#[Test]
#[TestWith(data: ['foo.bar', true], name: 'valid service')]
#[TestWith(data: ['config.something', true], name: 'another valid service')]
#[TestWith(data: ['config_something', false], name: 'invalid service')]
#[TestWith(data: ['foo', false], name: 'another invalid service')]
#[TestWith(['foo.bar', true], 'valid service')]
#[TestWith(['config.something', true], 'another valid service')]
#[TestWith(['config_something', false], 'invalid service')]
#[TestWith(['foo', false], 'another invalid service')]
public function canCreateOnlyServicesWithDot(string $serviceName, bool $canCreate): void
{
self::assertEquals($canCreate, $this->factory->canCreate(new ServiceManager(), $serviceName));
Expand All @@ -44,11 +44,11 @@ public function throwsExceptionWhenFirstPartOfTheServiceIsNotRegistered(): void
}

#[Test]
#[TestWith(data: ['string'], name: 'string')]
#[TestWith(data: [new stdClass()], name: 'object')]
#[TestWith(data: [true], name: 'true')]
#[TestWith(data: [false], name: 'false')]
#[TestWith(data: [100], name: 'number')]
#[TestWith(['string'], 'string')]
#[TestWith([new stdClass()], 'object')]
#[TestWith([true], 'true')]
#[TestWith([false], 'false')]
#[TestWith([100], 'number')]
public function throwsExceptionWhenFirstPartOfTheServiceDoesNotResultInAnArray(mixed $value): void
{
$this->expectException(ServiceNotCreatedException::class);
Expand Down
1 change: 1 addition & 0 deletions test/Factory/ValinorConfigFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function throwsExceptionWhenTryingToMapInvalidData(array $config): void
]]);

$this->expectException(MappingError::class);
// @phpstan-ignore staticMethod.notFound
ValinorConfigFactory::config($serviceManager, FooModel::class);
}

Expand Down

0 comments on commit 5b57679

Please sign in to comment.