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

Fix #61: Add support callable middlewares like [$instance, 'method'] and $invokeable #69

Merged
merged 8 commits into from
Dec 23, 2022

Conversation

rustamwin
Copy link
Member

Q A
Is bugfix?
New feature? ✔️
Breaks BC? ✔️/❌
Fixed issues #61

@rustamwin rustamwin added the status:code review The pull request needs review. label Dec 21, 2022
@rustamwin rustamwin requested a review from a team December 21, 2022 19:47
@codecov
Copy link

codecov bot commented Dec 21, 2022

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (2278473) compared to base (6915ff1).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 2278473 differs from pull request most recent head 62a2e65. Consider uploading reports for the commit 62a2e65 to get more accurate results

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     
Impacted Files Coverage Δ
src/MiddlewareFactory.php 100.00% <100.00%> (ø)

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@samdark samdark requested a review from vjik December 22, 2022 19:33
return true;
}

return is_array($definition)
&& array_keys($definition) === [0, 1]
&& is_string($definition[0])
&& (is_string($definition[0]) || is_object($definition[0]))
Copy link
Member

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.

&& 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]) : [],
Copy link
Member

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.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @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

@@ -184,17 +185,17 @@ private function getCallableParameters(): array
}

/**
* @param class-string $class
* @param class-string|object $class
Copy link
Member

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.

* @param non-empty-string $method
*/
private function createActionWrapper(string $class, string $method): MiddlewareInterface
private function createActionWrapper(string|object $class, string $method): MiddlewareInterface
Copy link
Member

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.

Comment on lines 197 to 198
/** @var class-string|object */
private string|object $class,
Copy link
Member

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.

Comment on lines 208 to 213
if (is_string($this->class)) {
/** @var mixed $controller */
$controller = $this->container->get($this->class);
} else {
$controller = $this->class;
}
Copy link
Member

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]>
@rustamwin rustamwin merged commit aa5379f into master Dec 23, 2022
@rustamwin rustamwin deleted the fix-61 branch December 23, 2022 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:code review The pull request needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants