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
container entries debug #505
Conversation
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.
Thanks! I have written a few comments inline, also could you add a changelog entry in the 6.0
section?
tests/UnitTest/ContainerGetTest.php
Outdated
$this->assertEquals('foo', $container->debugEntry('string')); | ||
$this->assertEquals('string', $container->debugEntry('entry')); | ||
$this->assertEquals('stdClass', $container->debugEntry('object')); | ||
} |
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.
This test is ContainerGetTest.php
and it's supposed to test the get()
method.
I think it would make more sense to move those 2 new tests into a new test class in IntegrationTest
(instead of UnitTest) that would test the debug features, i.e. DebugTest
?
src/Container.php
Outdated
* | ||
* @return array | ||
*/ | ||
public function getKnownEntryNames() |
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.
You can add the array
return type here and remove the same line that is in the phpdoc (PHP 7 FTW ^^)
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 think code base must be reviewed on missing type hinting hunt, for example on Container::has
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 cannot add it for has()
and get()
because those are defined in PSR-11 unfortunately.
src/Container.php
Outdated
* | ||
* @return string | ||
*/ | ||
public function debugEntry($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.
Could you add the strict types here too? (parameter + return type)
src/Container.php
Outdated
return is_object($entry) ? get_class($entry) : gettype($entry); | ||
} | ||
|
||
throw new InvalidArgumentException("No entry or class found for '$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.
You could throw a NotFound
exception? (it wouldn't be a huge difference but since the exception exists let's use it)
Thanks! |
covers container entries debug dumper as per comment on #152