Skip to content

Commit

Permalink
Fix to ensure inflection is not applied to non object types
Browse files Browse the repository at this point in the history
  • Loading branch information
philipobenito committed Jul 26, 2021
1 parent 22c11b2 commit 4899973
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Inflector/InflectorAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function add(string $type, callable $callback = null): Inflector
return $inflector;
}

public function inflect(object $object): object
public function inflect($object)
{
foreach ($this->getIterator() as $inflector) {
$type = $inflector->getType();
Expand Down
7 changes: 6 additions & 1 deletion tests/Inflector/InflectorAggregateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,17 @@ public function testNoInflectionIsAttemptedOnNonObjects(): void
'my-generated-array' => [\DateTimeZone::class, 'listIdentifiers'],
'my-generated-number' => 'time',
'my-generated-string' => function (): string {
return bin2hex(random_bytes(8));
return 'blahblahblah';
},
];

foreach ($types as $alias => $concrete) {
$container->add($alias, $concrete);

if (is_callable($concrete)) {
$concrete = $concrete();
}

self::assertSame($container->get($alias), $concrete);
}
}
Expand Down

0 comments on commit 4899973

Please sign in to comment.