-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Add a PSR-6 adapter #17440
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
Conversation
dunglas
commented
Jan 19, 2016
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | n/a |
License | MIT |
Doc PR | todo |
Ok I did not see your PR before I started working on mine ;P Closing mine as this looks very similar 👍 |
*/ | ||
public function has($class) | ||
{ | ||
$item = $this->cacheItemPool->getItem($this->escapeClassName($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.
simply use return $this->cacheItemPool->hasItem($this->escapeClassName($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.
According to the PSR-6, hasItem
can in be unreliable:
* Note: This method MAY avoid retrieving the cached value for performance reasons.
* This could result in a race condition with CacheItemInterface::get(). To avoid
* such situation use CacheItemInterface::isHit() instead.
It looks better to me to keep it as is.
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.
Performance doesn't matter here, the metadata caching occurs at "compile" time.
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.
@dunglas Can you finish this one? |
Should be ok now. |
Thank you @dunglas. |
*/ | ||
private function escapeClassName($class) | ||
{ | ||
return strtr($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.
we normalized this sort of operations to str_replace before
This PR was merged into the 3.1-dev branch. Discussion ---------- [Validator] Minor fixes for the PSR-6 adapter | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | todo Follows #17440. Take into account comments of @Tobion. Commits ------- aa60d5b [Validator] Minor fixes for the PSR-6 adapter