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

Trying to access array offset on value of type null #30737

Closed
houseme opened this issue Dec 3, 2019 · 18 comments
Closed

Trying to access array offset on value of type null #30737

houseme opened this issue Dec 3, 2019 · 18 comments

Comments

@houseme
Copy link

houseme commented Dec 3, 2019

  • Laravel Version: 5.7.7
  • PHP Version: 7.4.0
  • Database Driver & Version:

Description:

Trying to access array offset on value of type null

Steps To Reproduce:

Perform any access or execute the 'php artisan' command

@GrahamCampbell
Copy link
Member

We'll need more information than this. Is this a fresh Laravel app. What's the stack trace?

@driesvints
Copy link
Member

Please provide some code

@houseme
Copy link
Author

houseme commented Dec 3, 2019

Please provide some code

The current situation is due to access to the default home page after the PHP version has been upgraded to version 7.4.

@zecipriano
Copy link

zecipriano commented Dec 3, 2019

Having the same issue. I have a model with a jsonb field that is casted to an array, like this.

protected $casts = [
     'data' => 'array',
];

In PHP 7.3, when I dump the model, 'data' is an array (as expected). In PHP 7.4, 'data' is null.

Edit: Didn't notice the Laravel version on first post. I'm on Laravel 6.5.1

@mfn
Copy link
Contributor

mfn commented Dec 3, 2019

Laravel Version: 5.7.7

It Laravel 5.7 supposed to work with PHP 7.4?

@driesvints
Copy link
Member

I didn't catch the version here. 5.7 indeed doesn't supports PHP 7.4 and isn't maintained anymore.

Please check out our support policy on which versions we are currently supporting.

@zecipriano
Copy link

zecipriano commented Dec 3, 2019

@driesvints The issue is present on 6.5.1

Edit: Please disregard this. I'm not being able to reproduce the issue on a fresh install on Laravel. The issue might be somewhere else.

@3alampro
Copy link

3alampro commented Dec 4, 2019

I'm having the same issue when using laravel 6 with php 7.4

Step to reproduce

in your controller create new instance of any model and pass it to view something like

$banner = new Banner();

return view('back.banners.create', compact('banner'));

and in your view try to use old helper something like

old('title.en', $banner->title['en'])

Workaround to use the optional helper to ignore the error produced by php 7.4

old('title.ar', optional($banner->title)['en'])

in php 7.3 this was not an issue and the code worked fine I think the old helper need adjustment for php 7.4 to work like the old behaviour

@Chrissi2812
Copy link

According to PHP-Doc this is a Backwards Incompatible Change

Array-style access of non-arrays

Trying to use values of type null, bool, int, float or resource as an array (such as $null["key"]) will now generate a notice.

@sun4sun
Copy link

sun4sun commented Jan 6, 2020

some note
... /vendor/illuminate/support/ServiceProvider.php

95:    protected function loadViewsFrom($path, $namespace)
96:    {
97:    --    if (is_array($this->app->config['view']['paths'])) {
97:   ++    if (isset($this->app->config['view']) && is_array($this->app->config['view']['paths'])) {

@MuhammadTaha
Copy link

Had following configurations:

  • laravel/lumen-framework 5.7
  • php 7.4.2

downgrading to php 7.2 worked for me

@Yigaue
Copy link

Yigaue commented Feb 2, 2020

Maybe in some case you try composer update first.

@ryancwalsh
Copy link

I didn't catch the version here. 5.7 indeed doesn't supports PHP 7.4 and isn't maintained anymore.

Please check out our support policy on which versions we are currently supporting.

I was having this same "Trying to access array offset on value of type null." problem, and it referenced /vendor/egulias/email-validator/EmailValidator/Parser/Parser.php(147): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError().

This start happening for me after I upgraded my server to PHP 7.4.

And it was for a Laravel 5.8 (not 5.7) app. Upgrading to Laravel 6.x seemed to fix it.

@agharium
Copy link

this issue happened for me on laravel 5.8 on php 7.4. Downgrading the php to 7.3 fixed it.

@driesvints
Copy link
Member

@agharium 5.8 doesn't supports 7.4

@agharium
Copy link

@driesvints learned it the hard way.

@jafarabbas110
Copy link

same issue
Trying to access array offset on value of type null in F:\xampp\htdocs\mlmproject\admin\join.php on line 116

@driesvints
Copy link
Member

Hey everyone,

I'm locking this issue because it either has gone off-topic, become a dumping ground for things which shouldn't be in an issue tracker or is just too old. Please try to discuss things further on one of the below channels:

@laravel laravel locked and limited conversation to collaborators Feb 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests