Framework: V7.16.1 - ErrorException: Illegal offset type in isset or empty

Created on 16 Jun 2020  路  11Comments  路  Source: laravel/framework


  • Laravel Version: 7.16.1
  • PHP Version: 7.4.4
  • Database Driver & Version:

Description:

Shortly after upgrading to Laravel V7.16.1 the applications unit tests start failing with ErrorException: Illegal offset type in isset or empty

This appears to be triggered by the report($e) function inside of the controller, when it tries to report on a caught exception.

Digging through the error logs reveals the following:

[2020-06-16 15:04:23] testing.ERROR: Illegal offset type in isset or empty {"exception":"[object] (ErrorException(code: 0): Illegal offset type in isset or empty at /vendor/laravel/framework/src/Illuminate/Container/Container.php:1159)
[stacktrace]
#0 /vendor/laravel/framework/src/Illuminate/Container/Container.php(1159): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'Illegal offset ...', '/Users/davidsiv...', 1159, Array)
#1 /vendor/laravel/framework/src/Illuminate/Foundation/Application.php(779): Illuminate\\Container\\Container->getAlias(Object(Facade\\Ignition\\LogRecorder\\LogRecorder))
#2 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(415): Illuminate\\Foundation\\Application->make(Object(Facade\\Ignition\\LogRecorder\\LogRecorder))

Which appears to be because when the container has initialised it can't find the LogRecorder in the Application Abstracts.

Deleting and reloading and the Vendor Directory and a composer dump-autoload doesn't resolve the problem. However reverting to V7.15 does resolve the issue.

Comparing the two releases shows that the reflector has changed src/Illuminate/Container/Util.php@getParameterClassName() to include:

if ($name === 'self') {
    return $parameter->getDeclaringClass()->getName();
}

and a similar change in src/Illuminate/Support/Reflector.php@getParameterClassName

As a guess, I believe this is where the issue is probably stemming from, as the LogRecorder in this case is a Facade and the question would be is "what does getDeclaringClass return" when you are dealing with a facade.

Full Log Output Below:
PHPUnit Output

ErrorException: Illegal offset type in isset or empty

/vendor/laravel/framework/src/Illuminate/Container/Container.php:1159
/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:779
/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:415
/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:396
/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:226
/vendor/laravel/framework/src/Illuminate/Database/Connection.php:835
/vendor/laravel/framework/src/Illuminate/Database/Connection.php:689
/vendor/laravel/framework/src/Illuminate/Database/Connection.php:642
/vendor/laravel/framework/src/Illuminate/Database/Connection.php:339
/vendor/laravel/framework/src/Illuminate/Database/Connection.php:309
/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:75
/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:169
/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:608
/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:93
/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:64
/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:541
/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:81
/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:33
/vendor/laravel/framework/src/Illuminate/Container/Util.php:37
/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:91
/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35
/vendor/laravel/framework/src/Illuminate/Container/Container.php:592
/vendor/laravel/framework/src/Illuminate/Console/Command.php:134
/vendor/symfony/console/Command/Command.php:258
/vendor/laravel/framework/src/Illuminate/Console/Command.php:121
/vendor/symfony/console/Application.php:911
/vendor/symfony/console/Application.php:264
/vendor/symfony/console/Application.php:140
/vendor/laravel/framework/src/Illuminate/Console/Application.php:93
/vendor/laravel/framework/src/Illuminate/Console/Application.php:185
/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:263
/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:171
/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:291
/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:52
/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:40
/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:17
/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:115
/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:84

Laravel Log Output

[2020-06-16 15:04:30] testing.ERROR: Illegal offset type in isset or empty {"exception":"[object] (ErrorException(code: 0): Illegal offset type in isset or empty at /vendor/laravel/framework/src/Illuminate/Container/Container.php:1159)
[stacktrace]
#0 /vendor/laravel/framework/src/Illuminate/Container/Container.php(1159): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'Illegal offset ...', '/Users/davidsiv...', 1159, Array)
#1 /vendor/laravel/framework/src/Illuminate/Foundation/Application.php(779): Illuminate\\Container\\Container->getAlias(Object(Facade\\Ignition\\LogRecorder\\LogRecorder))
#2 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(415): Illuminate\\Foundation\\Application->make(Object(Facade\\Ignition\\LogRecorder\\LogRecorder))
#3 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(396): Illuminate\\Events\\Dispatcher->createClassCallable(Array)
#4 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(226): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('Illuminate\\\\Log\\\\...', Array)
#5 /vendor/laravel/framework/src/Illuminate/Log/Logger.php(210): Illuminate\\Events\\Dispatcher->dispatch('Illuminate\\\\Log\\\\...')
#6 /vendor/laravel/framework/src/Illuminate/Log/Logger.php(176): Illuminate\\Log\\Logger->fireLogEvent('error', 'Illegal offset ...', Array)
#7 /vendor/laravel/framework/src/Illuminate/Log/Logger.php(87): Illuminate\\Log\\Logger->writeLog('error', 'Illegal offset ...', Array)
#8 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(547): Illuminate\\Log\\Logger->error('Illegal offset ...', Array)
#9 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(122): Illuminate\\Log\\LogManager->error('Illegal offset ...', Array)
#10 /app/Exceptions/Handler.php(39): Illuminate\\Foundation\\Exceptions\\Handler->report(Object(ErrorException))
#11 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(49): App\\Exceptions\\Handler->report(Object(ErrorException))
#12 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(172): Illuminate\\Routing\\Pipeline->handleException(Object(Illuminate\\Http\\Request), Object(ErrorException))
#13 /vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#14 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#15 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#16 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#17 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#19 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#20 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#21 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#22 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#23 /vendor/fruitcake/laravel-cors/src/HandleCors.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#25 /vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#26 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#27 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#28 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(140): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#29 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(109): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#30 /vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(480): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#31 /vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(452): Illuminate\\Foundation\\Testing\\TestCase->call('POST', '/api/pos/fetch-...', Array, Array, Array, Array, '{\"retailerId\":\"...')
#32 /vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(311): Illuminate\\Foundation\\Testing\\TestCase->json('POST', '/api/pos/fetch-...', Array, Array)
#33 /Modules/ExistingPortalApi/Tests/Feature/PhoneOrderSystem/StoreProductsControllerTest.php(191): Illuminate\\Foundation\\Testing\\TestCase->postJson('/api/pos/fetch-...', Array)
#34 /vendor/phpunit/phpunit/src/Framework/TestCase.php(1414): Modules\\ExistingPortalApi\\Tests\\Feature\\PhoneOrderSystem\\StoreProductsControllerTest->testShowFetchProductWith404()
#35 /vendor/phpunit/phpunit/src/Framework/TestCase.php(1031): PHPUnit\\Framework\\TestCase->runTest()
#36 /vendor/phpunit/phpunit/src/Framework/TestResult.php(688): PHPUnit\\Framework\\TestCase->runBare()
#37 /vendor/phpunit/phpunit/src/Framework/TestCase.php(772): PHPUnit\\Framework\\TestResult->run(Object(Modules\\ExistingPortalApi\\Tests\\Feature\\PhoneOrderSystem\\StoreProductsControllerTest))
#38 /vendor/phpunit/phpunit/src/Framework/TestSuite.php(639): PHPUnit\\Framework\\TestCase->run(Object(PHPUnit\\Framework\\TestResult))
#39 /vendor/phpunit/phpunit/src/Framework/TestSuite.php(639): PHPUnit\\Framework\\TestSuite->run(Object(PHPUnit\\Framework\\TestResult))
#40 /vendor/phpunit/phpunit/src/Framework/TestSuite.php(639): PHPUnit\\Framework\\TestSuite->run(Object(PHPUnit\\Framework\\TestResult))
#41 /vendor/phpunit/phpunit/src/TextUI/TestRunner.php(653): PHPUnit\\Framework\\TestSuite->run(Object(PHPUnit\\Framework\\TestResult))
#42 /vendor/phpunit/phpunit/src/TextUI/Command.php(108): PHPUnit\\TextUI\\TestRunner->run(Object(PHPUnit\\Framework\\TestSuite), Array, Array, true)
#43 /vendor/phpunit/phpunit/src/TextUI/Command.php(68): PHPUnit\\TextUI\\Command->run(Array, true)
#44 /vendor/phpunit/phpunit/phpunit(61): PHPUnit\\TextUI\\Command::main()
#45 {main}
"} 

Steps To Reproduce:

Unsure as to how to reproduce in this scenario.

needs more info

Most helpful comment

Run "php artisan --version"

All 11 comments

This is fixed in version 7.16.1

@davidsivocha are you sure you're running 7.16.1?

Run "php artisan --version"

Fresh install for laravel ( just executed a few hours ago ) installed 7.16 for me, where i can confirm this isse ( artisan --version shows 7.16.0 also ) will try to bump to 7.16.1 to see if this issue still persists there..

nope 7.16.1 works fine, just updated and the error went away, while i had exactly the same problem as OP but on 7.16.0.

Thanks for confirming.

Sorry, @davidsivocha can you confirm when you get the chance?

Sorry guys, Misreported as 7.16.1, it was on 7.16.0. Updating immediately to 7.16.1 resolved the issue. Going to mark this as closed.

I'm curious though, comparing the tags (7.16.0 > 7.16.1) shows no changes?
What was the root cause?

Not sure why you aren't seeing the changes: https://github.com/laravel/framework/compare/v7.16.0...v7.16.1

I'm curious though, comparing the tags (7.16.0 > 7.16.1) shows no changes?

Probably because you are comparing them the wrong way around. v7.16.1...v7.16.0 vs v7.16.0...v7.16.1.

I thought I was losing my mind here, thank you for fixing this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CupOfTea696 picture CupOfTea696  路  3Comments

RomainSauvaire picture RomainSauvaire  路  3Comments

JamborJan picture JamborJan  路  3Comments

jackmu95 picture jackmu95  路  3Comments

ghost picture ghost  路  3Comments