Does anyone know solution?
explode(): Passing null to parameter #2 ($string) of type string is deprecated
That error happening in two command php artisan route:list and php artisan test. Route list error is solved. When I run php artisan test most of my tests including built in authentication test are failing. I didn't update built in test function and all tests are passing when I last run test.
PHP version - 8.1.11, laravel version - 8.63
>pf AuthenticationTest
FAIL Tests\Feature\Auth\AuthenticationTest
⨯ login screen can be rendered
✓ users can authenticate using the login screen
✓ users can not authenticate with invalid password
---
• Tests\Feature\Auth\AuthenticationTest > login screen can be rendered
Expected response status code [200] but received 500.
The following exception occurred during the request:
ErrorException: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /Users/aunghtetpaing/code/Koob/vendor/inertiajs/inertia-laravel/src/Response.php:63
Stack trace:
>p
FAIL Tests\Feature\Auth\AuthenticationTest
⨯ login screen can be rendered
✓ users can authenticate using the login screen
✓ users can not authenticate with invalid password
FAIL Tests\Feature\Auth\EmailVerificationTest
⨯ email verification screen can be rendered
✓ email can be verified
✓ email is not verified with invalid hash
FAIL Tests\Feature\Auth\PasswordConfirmationTest
⨯ confirm password screen can be rendered
✓ password can be confirmed
✓ password is not confirmed with invalid password
FAIL Tests\Feature\Auth\PasswordResetTest
⨯ reset password link screen can be rendered
✓ reset password link can be requested
⨯ reset password screen can be rendered
✓ password can be reset with valid token
FAIL Tests\Feature\Auth\RegistrationTest
⨯ registration screen can be rendered
✓ new users can register
FAIL Tests\Feature\BookTest
⨯ user can view all books
⨯ user can view book detail
⨯ user can filter books by categories
⨯ user can search book by title
⨯ user can sort books by price
⨯ user can sort books by date
FAIL Tests\Feature\CartTest
⨯ user can view cart page
✓ user can view all shopping cart items
✓ user can add book to cart with single quantity
✓ user can add book to cart with multiple quantity
✓ user can remove book from cart
✓ user can update cart item quantity
✓ cart item quantity increase if already existed
✓ user cannot select more than stock quantity
✓ guest cannot save item for later
✓ authenticated user can save cart item for later
✓ authenticated user can move saved items to cart
⨯ over stock cart items quantity are updated when visit cart page
⨯ not available cart items are moved to save for later list
✓ cart session and database sync after login
Look at the stack trace to see where the error originates from. There should be a reference to one of your own files
@Sinnbeck there are many lines in stack trace. I am not sure where error originates from. Should I put all stack trace here?
@AungHtetPaing__ Look throught it and look for something like \App\ or /app or /routes
@Sinnbeck I searched with cmd+f
"\App"
#3 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Container/Container.php(694): Illuminate\Foundation\Application->resolve('Illuminate\Cont...', Array)
#4 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(826): Illuminate\Container\Container->make('Illuminate\Cont...', Array)
#5 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(164): Illuminate\Foundation\Application->make('Illuminate\Cont...')
"/app"
#2 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\Container\Container->resolve('Illuminate\Cont...', Array, true)
#3 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Container/Container.php(694): Illuminate\Foundation\Application->resolve('Illuminate\Cont...', Array)
#4 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(826): Illuminate\Container\Container->make('Illuminate\Cont...', Array)
no result with "routes"
Which version of inertia-laravel do you use currently?
This was fixed with this PR
Fixed on the 0.4.5 version.
@kallefrombosnia currently 0.4.3
"guzzlehttp/guzzle": "^7.0.1",
"inertiajs/inertia-laravel": "^0.4.3",
"laravel/cashier": "^13.5",
PHP changed the order of parameters for the explode function. There must be an explode function in one of its files, which remains in the old order. That's why you're getting this error.
https://www.php.net/manual/en/function.explode.php
As @kallefrombosnia said, if this update is missing from the package, it may cause a problem.
PHP changed the order of parameters for the explode function.
Yeah I see error with php 8.1 on google
if this update is missing from the package
so I need to update inertia-laravel version?
@AungHtetPaing__ If this error comes from the package, it will probably be fixed when you update it.
❯ composer update inertiajs/inertia-laravel
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- nette/schema v1.2.1 requires php >=7.1 <8.1 -> your php version (8.1.11) does not satisfy that requirement.
- league/commonmark 2.0.2 requires league/config ^1.1.1 -> satisfiable by league/config[v1.1.1].
- laravel/framework v8.63.0 requires league/commonmark ^1.3|^2.0.2 -> satisfiable by league/commonmark[2.0.2].
- league/config v1.1.1 requires nette/schema ^1.2 -> satisfiable by nette/schema[v1.2.1].
- laravel/framework is locked to version v8.63.0 and an update of this package was not requested.
ah requirement error on composer update. I am at php 8.1.11. Should I switch or something do with php version?
@AungHtetPaing__ Just try to run composer update
I searched about that error on google and found some results. But the problem is even built in test are failing and I didn't write explode in my code as I remember (not sure).
@AungHtetPaing__ Most likely it is due to some data being passed to laravel which triggers the error inside of the framework. Are you able to get the error if you visit a page in the browser (log in perhaps)
@Sinnbeck No there is no error in browser. So I didn't notice that error is happening (I last run test may be two months ago).
@AungHtetPaing__ Maybe just share the full stack trace?
@Sinnbeck of course I really want to share stack trace. :)
below are stack trace of "pf AuthenticateTest"
ErrorException: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /Users/aunghtetpaing/code/Koob/vendor/inertiajs/inertia-laravel/src/Response.php:63
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'explode(): Pass...', '/Users/aunghtet...', 63)
#1 /Users/aunghtetpaing/code/Koob/vendor/inertiajs/inertia-laravel/src/Response.php(63): explode(',', NULL)
#2 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Routing/Router.php(776): Inertia\Response->toResponse(Object(Illuminate\Http\Request))
#3 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Routing/Router.php(763): Illuminate\Routing\Router::toResponse(Object(Illuminate\Http\Request), Object(Inertia\Response))
#4 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Routing/Router.php(695): Illuminate\Routing\Router->prepareResponse(Object(Illuminate\Http\Request), Object(Inertia\Response))
#5 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#6 /Users/aunghtetpaing/code/Koob/app/Http/Middleware/RedirectIfAuthenticated.php(30): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#7 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\Http\Middleware\RedirectIfAuthenticated->handle(Object(Illuminate\Http\Request), Object(Closure))
#8 /Users/aunghtetpaing/code/Koob/vendor/inertiajs/inertia-laravel/src/Middleware.php(82): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#9 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Inertia\Middleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#10 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#11 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#12 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#13 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#14 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#15 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#16 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#17 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest(Object(Illuminate\Http\Request), Object(Illuminate\Session\Store), Object(Closure))
#18 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#19 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#20 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#21 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#22 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#23 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#24 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Routing/Router.php(697): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#25 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Routing/Router.php(672): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#26 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#27 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#28 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(166): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#29 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#30 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))
#33 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#34 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#35 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 /Users/aunghtetpaing/code/Koob/vendor/fruitcake/laravel-cors/src/HandleCors.php(38): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\Cors\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#42 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Http\Middleware\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#45 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(141): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#46 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#47 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(510): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#48 /Users/aunghtetpaing/code/Koob/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(294): Illuminate\Foundation\Testing\TestCase->call('GET', '/login', Array, Array, Array, Array)
#49 /Users/aunghtetpaing/code/Koob/tests/Feature/Auth/AuthenticationTest.php(16): Illuminate\Foundation\Testing\TestCase->get('/login')
#50 /Users/aunghtetpaing/code/Koob/vendor/phpunit/phpunit/src/Framework/TestCase.php(1527): Tests\Feature\Auth\AuthenticationTest->test_login_screen_can_be_rendered()
#51 /Users/aunghtetpaing/code/Koob/vendor/phpunit/phpunit/src/Framework/TestCase.php(1133): PHPUnit\Framework\TestCase->runTest()
#52 /Users/aunghtetpaing/code/Koob/vendor/phpunit/phpunit/src/Framework/TestResult.php(722): PHPUnit\Framework\TestCase->runBare()
#53 /Users/aunghtetpaing/code/Koob/vendor/phpunit/phpunit/src/Framework/TestCase.php(885): PHPUnit\Framework\TestResult->run(Object(Tests\Feature\Auth\AuthenticationTest))
#54 /Users/aunghtetpaing/code/Koob/vendor/phpunit/phpunit/src/Framework/TestSuite.php(678): PHPUnit\Framework\TestCase->run(Object(PHPUnit\Framework\TestResult))
#55 /Users/aunghtetpaing/code/Koob/vendor/phpunit/phpunit/src/Framework/TestSuite.php(678): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#56 /Users/aunghtetpaing/code/Koob/vendor/phpunit/phpunit/src/Framework/TestSuite.php(678): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#57 /Users/aunghtetpaing/code/Koob/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(670): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#58 /Users/aunghtetpaing/code/Koob/vendor/phpunit/phpunit/src/TextUI/Command.php(143): PHPUnit\TextUI\TestRunner->run(Object(PHPUnit\Framework\TestSuite), Array, Array, true)
#59 /Users/aunghtetpaing/code/Koob/vendor/phpunit/phpunit/src/TextUI/Command.php(96): PHPUnit\TextUI\Command->run(Array, true)
#60 /Users/aunghtetpaing/code/Koob/vendor/phpunit/phpunit/phpunit(92): PHPUnit\TextUI\Command::main()
#61 {main}
Failed asserting that 200 is identical to 500.
at tests/Feature/Auth/AuthenticationTest.php:18
14▕ public function test_login_screen_can_be_rendered()
15▕ {
16▕ $response = $this->get('/login');
17▕
➜ 18▕ $response->assertStatus(200);
19▕ }
20▕
21▕ public function test_users_can_authenticate_using_the_login_screen()
22▕ {
@AungHtetPaing__ run composer update to get a more recent version of inertia-laravel where the problem has been addressed
@tykus wow perfect. All tests are passing now.
❯ php artisan test
PASS Tests\Unit\ExampleTest
✓ example
PASS Tests\Feature\Auth\AuthenticationTest
✓ login screen can be rendered
✓ users can authenticate using the login screen
✓ users can not authenticate with invalid password
PASS Tests\Feature\Auth\EmailVerificationTest
✓ email verification screen can be rendered
✓ email can be verified
✓ email is not verified with invalid hash
PASS Tests\Feature\Auth\PasswordConfirmationTest
✓ confirm password screen can be rendered
✓ password can be confirmed
✓ password is not confirmed with invalid password
PASS Tests\Feature\Auth\PasswordResetTest
✓ reset password link screen can be rendered
✓ reset password link can be requested
✓ reset password screen can be rendered
✓ password can be reset with valid token
PASS Tests\Feature\Auth\RegistrationTest
✓ registration screen can be rendered
✓ new users can register
PASS Tests\Feature\BookTest
✓ user can view all books
✓ user can view book detail
✓ user can filter books by categories
✓ user can search book by title
✓ user can sort books by price
✓ user can sort books by date
PASS Tests\Feature\CartTest
✓ user can view cart page
✓ user can view all shopping cart items
✓ user can add book to cart with single quantity
✓ user can add book to cart with multiple quantity
✓ user can remove book from cart
✓ user can update cart item quantity
✓ cart item quantity increase if already existed
✓ user cannot select more than stock quantity
✓ guest cannot save item for later
✓ authenticated user can save cart item for later
✓ authenticated user can move saved items to cart
✓ over stock cart items quantity are updated when visit cart page
✓ not available cart items are moved to save for later list
✓ cart session and database sync after login
PASS Tests\Feature\CheckoutTest
✓ guest cannot view checkout page
✓ authenticated user cannot view checkout page without cart items
✓ authenticated user can view checkout page with cart items
✓ order requires contact name
✓ order requires contact email
✓ user can place order successfully
PASS Tests\Feature\CouponTest
✓ authenticated user can apply valid coupon code
✓ authenticated user cannot apply invalid coupon code
✓ authenticated user cannot apply expired coupon code
✓ authenticated user cannot apply same coupon code more than once
PASS Tests\Feature\NotificationsTest
✓ admin can see all notifications
✓ admin can read notification
✓ admin can filter unread notifications only
✓ unauthorized user cannot see admin notifications
PASS Tests\Feature\OrderManageTest
✓ example
PASS Tests\Feature\ProfileSettingTest
✓ authenticated user can view profile
✓ authenticated user can update profile information
✓ authenticated user can update profile photo image
✓ profile edit form require name and email
✓ profile edit form require valid email format and unique
✓ password edit form require all fields
✓ user can update password
Tests: 58 passed
Time: 7.03s
Thank everyone for helping.
Please or to participate in this conversation.