-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix #61: Add support callable middlewares like [$instance, 'method']
and $invokeable
#69
Conversation
rustamwin
commented
Dec 21, 2022
Q | A |
---|---|
Is bugfix? | ❌ |
New feature? | ✔️ |
Breaks BC? | ✔️/❌ |
Fixed issues | #61 |
…and $invokeable
Codecov ReportBase: 100.00% // Head: 100.00% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #69 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 80 80
===========================================
Files 6 6
Lines 212 213 +1
===========================================
+ Hits 212 213 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
# Conflicts: # src/MiddlewareFactory.php
src/MiddlewareFactory.php
Outdated
return true; | ||
} | ||
|
||
return is_array($definition) | ||
&& array_keys($definition) === [0, 1] | ||
&& is_string($definition[0]) | ||
&& (is_string($definition[0]) || is_object($definition[0])) |
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's not need, because is_callable
above cover this case.
src/MiddlewareFactory.php
Outdated
&& is_string($definition[1]) | ||
&& in_array( | ||
$definition[1], | ||
class_exists($definition[0]) ? get_class_methods($definition[0]) : [], | ||
is_object($definition[0]) || class_exists($definition[0]) ? get_class_methods($definition[0]) : [], |
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's not need, because is_callable
above cover this case.
src/MiddlewareFactory.php
Outdated
@@ -125,9 +126,9 @@ private function isArrayDefinition(array|callable|string $definition): bool | |||
} | |||
|
|||
/** | |||
* @param array{0:class-string, 1:non-empty-string}|Closure $callable | |||
* @param array{0:class-string|object, 1:non-empty-string}|callable-object|callable-string|Closure $callable |
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.
* @param array{0:class-string|object, 1:non-empty-string}|callable-object|callable-string|Closure $callable | |
* @param array{0:class-string, 1:non-empty-string}|callable|Closure $callable |
src/MiddlewareFactory.php
Outdated
@@ -184,17 +185,17 @@ private function getCallableParameters(): array | |||
} | |||
|
|||
/** | |||
* @param class-string $class | |||
* @param class-string|object $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.
It's not need, because is_callable
above cover this case.
src/MiddlewareFactory.php
Outdated
* @param non-empty-string $method | ||
*/ | ||
private function createActionWrapper(string $class, string $method): MiddlewareInterface | ||
private function createActionWrapper(string|object $class, string $method): MiddlewareInterface |
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's not need, because is_callable
above cover this case.
src/MiddlewareFactory.php
Outdated
/** @var class-string|object */ | ||
private string|object $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.
It's not need, because is_callable
above cover this case.
src/MiddlewareFactory.php
Outdated
if (is_string($this->class)) { | ||
/** @var mixed $controller */ | ||
$controller = $this->container->get($this->class); | ||
} else { | ||
$controller = $this->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.
It's not need, because is_callable
above cover this case.
Co-authored-by: Sergei Predvoditelev <[email protected]>