Trying to access array offset on value of type null

Sounds like your variable isn't set.

Check with the following isset calls:

isset($this->config); 
isset($this->config['backend']);
isset($this->config['backend']['api_prefix']);

You can actually check multiple vars in one isset call (isset($x, $y, $z)), but this will let you see which var specifically is missing


use (??) (double question mark operator) ("null coalescing operator") to avoid unset arrays.

this unit test is giving me "success"

class PhpTest extends TestCase
{
    public function test_php_74()
    {
        //Trying to access array offset on value of type null

        $this->assertSame('7.4.9', phpversion());

        $a = null;
        $this->assertTrue($a ?? true);
        $this->assertTrue($a['a'] ?? true);
        $this->assertTrue($a['a']['a'] ?? true);

        $a = [];
        $this->assertSame([], $a);
        $this->assertTrue($a['a'] ?? true);
        $this->assertTrue($a['a']['a'] ?? true);
    }
}

Tags:

Php

Php 7.4