[go: nahoru, domu]

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

Implement PSR-11 #13060

Merged
merged 6 commits into from
Mar 22, 2017
Merged

Implement PSR-11 #13060

merged 6 commits into from
Mar 22, 2017

Conversation

MauricioFauth
Copy link
Member
@MauricioFauth MauricioFauth commented Mar 8, 2017

Fixes #13052

Signed-off-by: Maurício Meneghini Fauth mauriciofauth@gmail.com

Before submitting pull request, please check that every commit:

  • Has proper Signed-Off-By
  • Has commit message which describes it
  • Is needed on it's own, if you have just minor fixes to previous commits, you can squash them
  • Any new functionality is covered by tests

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
@codecov-io
Copy link
codecov-io commented Mar 8, 2017

Codecov Report

Merging #13060 into master will increase coverage by 0.05%.
The diff coverage is 81.25%.

@@            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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7835f72...48897b3. Read the comment docs.

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
@MauricioFauth
Copy link
Member Author

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>
@nijel nijel self-assigned this Mar 13, 2017
} catch (NotFoundException $e) {
echo $e->getMessage();
return null;
}
Copy link
Contributor

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.
Copy link
Contributor

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...

}

return null;
return false;
Copy link
Contributor

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]);

*/
public function testGetWithInvalidEntry()
{
$this->assertSame(null, $this->container->get('invalid'));
Copy link
Contributor

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>
@nijel
Copy link
Contributor
nijel commented Mar 14, 2017

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

@MauricioFauth
Copy link
Member Author

I will do this @nijel

And about the get method, I think it would not be appropriate to use isset since this already happens in the has method. I think it should check whether the value is valid or not. Maybe !is_null?

@nijel
Copy link
Contributor
nijel commented Mar 14, 2017

Why should it check for null value? I think it's perfectly okay to return null if it has been set...

@MauricioFauth
Copy link
Member Author
MauricioFauth commented Mar 14, 2017

Oh, of course. I was not thinking straight.
I'm wanting to check for something other than isset, otherwise ContainerException will never be thrown.

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
@MauricioFauth
Copy link
Member Author

I left get method the way it was and corrected the tests that were failing.
Is everything all right now, @nijel?

@nijel nijel merged commit 29a773e into phpmyadmin:master Mar 22, 2017
@nijel
Copy link
Contributor
nijel commented Mar 22, 2017

Merged, thanks for your contribution!

@nijel nijel added this to the 4.8.0 milestone Mar 22, 2017
@MauricioFauth MauricioFauth deleted the psr-container branch March 22, 2017 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DIC] Implement PSR-11
4 participants