-
Notifications
You must be signed in to change notification settings - Fork 0
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 PHP-DI/PHP-DI#616 #1
Improve PHP-DI/PHP-DI#616 #1
Conversation
} | ||
|
||
$this->setClassName($className); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the logic of replacing wildcards into this class, that allows for unit tests and a simpler code in DefinitionArray
. This is not directly related to your bugfix but it improves the code a bit I think.
$this->replaceWildcards($definition->getClassName(), $matches) | ||
); | ||
$definition = $this->normalizer->normalizeRootDefinition($definition, $name); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reworked this code so that $this->normalizer->normalizeRootDefinition($definition, $name)
isn't called twice. This is now the normalizer that takes care of replacing wildcards.
$this->assertInstanceOf(Implementation1::class, $object); | ||
|
||
self::assertEntryIsNotCompiled($container, Interface1::class); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this test just to be sure it works ^^ (not related to your bug)
self::assertEntryIsNotCompiled($container, 'DI\Test\IntegrationTest\*\Interface*'); | ||
self::assertEntryIsNotCompiled($container, Interface1::class); | ||
self::assertEntryIsNotCompiled($container, Interface2::class); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a simpler version of your test: this test passes on the current master. I think this is better to have a simple test (easy to grasp) which covers the base of the feature + your test that is more advanced and covers the bug you were facing.
$definition = new ObjectDefinition('Foo\Bar\Baz'); | ||
$definition->replaceWildcards(['1', '2', '3']); | ||
$this->assertEquals('Foo\Bar\Baz', $definition->getClassName()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With those unit tests I can sleep better now ;)
This pull request adds suggested improvements to PHP-DI#616
I'll detail inline.