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

Improve containers types to use iterable objects #299

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Merge branch 'master' into iterable
# Conflicts:
#	src/Container.php
#	tests/Unit/ContainerTest.php
  • Loading branch information
xepozz committed Dec 2, 2022
commit 21a7526d3ef533f44db7f8efc1fe93ca34150fcd
6 changes: 4 additions & 2 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Closure;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use Throwable;
use Traversable;
use Yiisoft\Definitions\ArrayDefinition;
use Yiisoft\Definitions\DefinitionStorage;
Expand Down Expand Up @@ -397,15 +399,15 @@ private function setTags(iterable $tags): void
throw new InvalidConfigException(
sprintf(
'Invalid tags configuration: tag should be string, %s given.',
$this->getVariableType($tag)
get_debug_type($services)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
get_debug_type($services)
get_debug_type($tag)

)
);
}
if (!is_iterable($services)) {
throw new InvalidConfigException(
sprintf(
'Invalid tags configuration: tag should be either iterable or array of service IDs, %s given.',
$this->getVariableType($services)
get_debug_type($services)
)
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ public function testNonArrayTags(): void

$this->expectException(InvalidConfigException::class);
$this->expectExceptionMessage(
'Invalid definition: tags should be either iterable or array of strings, integer given.'
'Invalid definition: tags should be either iterable or array of strings, string given.'
);
new Container($config);
}
Expand All @@ -1970,7 +1970,7 @@ public function dataInvalidTags(): array
{
return [
[
'Invalid tags configuration: tag should be string, integer given.',
'/^Invalid tags configuration: tag should be string, 42 given\.$/',
[42 => [EngineMarkTwo::class]],
],
[
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.