simple-php-router icon indicating copy to clipboard operation
simple-php-router copied to clipboard

Breaking in php 8.1

Open AlexanderSchaller opened this issue 4 years ago • 4 comments

Using this in php 8.1 throws an error when attempting to use the Router::router->getUrl() function.

string 'strtolower(): Passing null to parameter #1 ($string) of type string is deprecated'

If you need any additional information let me know.

AlexanderSchaller avatar Jan 27 '22 21:01 AlexanderSchaller

Hello, could you provide me with the lines of code where you are using this function and the full error including the Trace (File names and lines)?

~ Marius

DeveloperMarius avatar Feb 01 '22 23:02 DeveloperMarius

Sorry for the delay, I am using the helper url function unmodified. Here is the stack trace

handleError(8192, 'strtolower(): P...', '/Users/schaller...', 198)
#1 /Users/schaller/Sites/thefinaloutpost/vendor/pecee/simple-router/src/Pecee/SimpleRouter/Route/LoadableRoute.php(198): strtolower(NULL)
#2 /Users/schaller/Sites/thefinaloutpost/vendor/pecee/simple-router/src/Pecee/SimpleRouter/Router.php(585): Pecee\SimpleRouter\Route\LoadableRoute->hasName('login')
#3 /Users/schaller/Sites/thefinaloutpost/core/vendorPatches/Router.php(39): Pecee\SimpleRouter\Router->findRoute('login')
#4 /Users/schaller/Sites/thefinaloutpost/vendor/pecee/simple-router/src/Pecee/SimpleRouter/SimpleRouter.php(448): app\core\vendorPatches\Router->getUrl('login', NULL, NULL)
#5 /Users/schaller/Sites/thefinaloutpost/core/View.php(140): Pecee\SimpleRouter\SimpleRouter::getUrl('login', NULL)
#6 /Users/schaller/Sites/thefinaloutpost/views/index/logged_out.php(29): app\core\View->escapeUrl('login')
#7 /Users/schaller/Sites/thefinaloutpost/core/View.php(185): include('/Users/schaller...')
#8 /Users/schaller/Sites/thefinaloutpost/core/Controller.php(36): app\core\View->renderView('index/logged_ou...', Array)
#9 /Users/schaller/Sites/thefinaloutpost/controllers/IndexController.php(44): app\core\Controller->render('index/logged_ou...', Array)
#10 [internal function]: app\controllers\IndexController->index()
#11 /Users/schaller/Sites/thefinaloutpost/vendor/pecee/simple-router/src/Pecee/SimpleRouter/ClassLoader/ClassLoader.php(34): call_user_func_array(Array, Array)
#12 /Users/schaller/Sites/thefinaloutpost/vendor/pecee/simple-router/src/Pecee/SimpleRouter/Route/Route.php(111): Pecee\SimpleRouter\ClassLoader\ClassLoader->loadClassMethod(Object(app\controllers\IndexController), 'index', Array)
#13 /Users/schaller/Sites/thefinaloutpost/vendor/pecee/simple-router/src/Pecee/SimpleRouter/Router.php(414): Pecee\SimpleRouter\Route\Route->renderRoute(Object(Pecee\Http\Request), Object(app\core\vendorPatches\Router))
#14 /Users/schaller/Sites/thefinaloutpost/vendor/pecee/simple-router/src/Pecee/SimpleRouter/Router.php(343): Pecee\SimpleRouter\Router->routeRequest()
#15 /Users/schaller/Sites/thefinaloutpost/vendor/pecee/simple-router/src/Pecee/SimpleRouter/SimpleRouter.php(69): Pecee\SimpleRouter\Router->start()
#16 /Users/schaller/Sites/thefinaloutpost/core/Application.php(39): Pecee\SimpleRouter\SimpleRouter::start()
#17 /Users/schaller/Sites/thefinaloutpost/public/index.php(46): app\core\Application->start()
#18 /Users/schaller/.composer/vendor/laravel/valet/server.php(234): require('/Users/schaller...')
#19 {main}"

AlexanderSchaller avatar Feb 07 '22 08:02 AlexanderSchaller

Hello @AlexanderSchaller,

thank you for reporting this issue. I didn't test the router with PHP 8.1, because my environment doesn't support it jet. I created the PR #610 that is hopefully fixing your issue. Let me know if you run into any other issues using PHP 8.1 in the comments of the PR.

Until @skipperbent is merging the PR into master, you can change the two lines I changed in #610 your local router code. Please let me know if this fix resolves your issue.

~ Marius

DeveloperMarius avatar Feb 07 '22 13:02 DeveloperMarius

Yes that fixes the issue - thanks!

AlexanderSchaller avatar Feb 08 '22 09:02 AlexanderSchaller