-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Implement PSR-11 #13060
Implement PSR-11 #13060
Conversation
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #13060 +/- ##
==========================================
+ Coverage 54.31% 54.36% +0.05%
==========================================
Files 466 466
Lines 69642 69618 -24
==========================================
+ Hits 37826 37851 +25
+ Misses 31816 31767 -49 Continue to review full report at Codecov.
|
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
I've never written tests before, so I do not know if the ones I've written are correct. |
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
libraries/di/Container.php
Outdated
} catch (NotFoundException $e) { | ||
echo $e->getMessage(); | ||
return null; | ||
} |
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 really don't get the code here:
- Why is there
try { throw } catch {}
block at all? - The echo is there for something else than debugging purposes?
@@ -46,19 +47,58 @@ public function __construct(Container $base = null) | |||
* @param string $name Name | |||
* @param array $params Parameters | |||
* | |||
* @throws NotFoundException No entry was found for **this** identifier. | |||
* @throws ContainerException Error while retrieving the entry. |
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.
It doesn't seem to throw these as they are always handled inside...
libraries/di/Container.php
Outdated
} | ||
|
||
return null; | ||
return false; |
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.
Probably better to write whole method as:
return isset($this->content[$name]) || isset($GLOBALS[$name]);
test/classes/di/ContainerTest.php
Outdated
*/ | ||
public function testGetWithInvalidEntry() | ||
{ | ||
$this->assertSame(null, $this->container->get('invalid')); |
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.
IMHO it should throw NotFoundExceptionInterface according to PSR-11.
Remove try-catch blocks Refactor has method Refactor testGetWithInvalidEntry method Add tests for ContainerException and NotFoundException Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
And now the code code which uses container needs to be adjusted to understand new behavior, see at least the test failures: https://travis-ci.org/phpmyadmin/phpmyadmin/jobs/210553712#L457 |
I will do this @nijel And about the |
Why should it check for null value? I think it's perfectly okay to return null if it has been set... |
Oh, of course. I was not thinking straight. |
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
I left |
Merged, thanks for your contribution! |
Fixes #13052
Signed-off-by: Maurício Meneghini Fauth mauriciofauth@gmail.com
Before submitting pull request, please check that every commit: