Skip to content

Commit

Permalink
Merge pull request #9 from teamones-open/master
Browse files Browse the repository at this point in the history
fixed: is_callable support PHP8
  • Loading branch information
walkor authored May 5, 2021
2 parents f2ab860 + 3b7fe84 commit 0a9e5b2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public static function convertToCallable($path, $callback)
if (\is_array($callback)) {
$callback = \array_values($callback);
}
if (\is_callable($callback)) {
if (\is_callable($callback, true)) {
if (\is_array($callback) && \is_string($callback[0])) {
return [App::container()->get($callback[0]), $callback[1]];
}
Expand Down

7 comments on commit 0a9e5b2

@latypoff
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, but it breaks current applications running on php 7.x
Routes just have been stopped being recognized

@latypoff
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe, correct fix would be

\is_callable($callback, \is_array($callback))

@walkor
Copy link
Owner Author

@walkor walkor commented on 0a9e5b2 May 7, 2021

Choose a reason for hiding this comment

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

Sorry, but it breaks current applications running on php 7.x
Routes just have been stopped being recognized

Sorry, I didn't encounter the problem you mentioned under php7. X.
Can you give me an example of reproducing the problem?

@latypoff
Copy link
Contributor

Choose a reason for hiding this comment

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

Default webman installation:

curl http://127.0.0.1:8787/route-test
Error: Call to undefined function app\controller\Index@index() in /root/1/webman/vendor/workerman/webman-framework/src/App.php:313<br />
Stack trace:

@walkor
Copy link
Owner Author

@walkor walkor commented on 0a9e5b2 May 7, 2021

Choose a reason for hiding this comment

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

@latypoff
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

@weijer
Copy link
Contributor

@weijer weijer commented on 0a9e5b2 May 7, 2021

Choose a reason for hiding this comment

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

Maybe we should need unit testing. @walkor

Please sign in to comment.