Skip to content

Commit 79450df

Browse files
committed
fix(phpstan): fix phpstan issues
1 parent 6966e44 commit 79450df

3 files changed

Lines changed: 22 additions & 11 deletions

File tree

config/routes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
return static function (Application $application, MiddlewareFactory $middlewareFactory): void {
1414
$specPath = getenv('OPENAPI_SPEC') ?: null;
15-
$packageRoot = realpath(__DIR__ . '/..') ?: '/app';
15+
$packageRoot = dirname(__DIR__) ?: '/app';
1616

17-
if (null === $specPath || false === $specPath) {
17+
if (null === $specPath) {
1818
$specPath = $packageRoot . '/data/openapi.yaml';
1919
} elseif (!str_starts_with((string) $specPath, '/') && !str_starts_with((string) $specPath, 'http')) {
2020
$resolveBase = str_contains($packageRoot, DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR)

phpstan.neon

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
parameters:
22
level: 8
33
treatPhpDocTypesAsCertain: false
4+
5+
46
paths:
7+
- bin
8+
- config
59
- src
610
- public
711
- tests
8-
bootstrapFiles:
9-
- vendor/autoload.php
1012
excludePaths:
1113
analyse:
1214
- tests/Support/_generated/*

src/Container/SimpleContainer.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
/**
2424
* Lightweight PSR-11 container that supports the Mezzio ConfigProvider format
2525
* (factories, aliases, invokables, delegators) without requiring laminas-servicemanager.
26+
*
27+
* @phpstan-type MezzioDependencyConfig array{
28+
* services?: array<string, mixed>,
29+
* factories?: array<string, (callable(): mixed)|string>,
30+
* aliases?: array<string, string>,
31+
* invokables?: array<int|string, string>,
32+
* delegators?: array<string, array<int|string, (callable(): mixed)|string>>
33+
* }|array<string, string[]>
2634
*/
2735
final class SimpleContainer implements ContainerInterface
2836
{
@@ -35,7 +43,7 @@ final class SimpleContainer implements ContainerInterface
3543
/** @var array<string, string> */
3644
private array $aliases = [];
3745

38-
/** @var array<string, list<callable|string>> */
46+
/** @var array<string, array<int|string, callable|string>> */
3947
private array $delegators = [];
4048

4149
public function get(string $id): mixed
@@ -112,15 +120,16 @@ public function has(string $id): bool
112120
/**
113121
* Process a Mezzio-style dependency configuration array.
114122
*
115-
* @param array{
116-
* factories?: array<string, callable|string>,
117-
* aliases?: array<string, string>,
118-
* invokables?: array<int|string, string>,
119-
* delegators?: array<string, list<callable|string>>
120-
* } $config
123+
* @param MezzioDependencyConfig $config
121124
*/
122125
public function configure(array $config): void
123126
{
127+
if (isset($config['services']) && is_array($config['services'])) {
128+
foreach ($config['services'] as $name => $service) {
129+
$this->setService($name, $service);
130+
}
131+
}
132+
124133
if (isset($config['invokables']) && is_array($config['invokables'])) {
125134
foreach ($config['invokables'] as $name => $class) {
126135
$this->setInvokableClass(is_int($name) ? $class : $name, $class);

0 commit comments

Comments
 (0)