Skip to content

Cannot assign null to property Backpack\Basset\Helpers\CacheMap::$map of type array #146

Open
@jefffairson

Description

@jefffairson

Hello,

This is related to issue #107, I sitll have this error message randomly when testing with pest and --parallel option.

I applied the constant BASSET_DEV_MODE=true in my env file and it is correctly applied.
When using the parallel option, the constant is still present and applied but the error is still occuring randomly.

Cannot assign null to property Backpack\Basset\Helpers\CacheMap::$map of type array

  at vendor/backpack/basset/src/Helpers/CacheMap.php:31
     27▕         $this->filePath = $this->disk->path($this->basePath.'.basset');
     28▕ 
     29▕         // Load map
     30▕         if (File::exists($this->filePath)) {
  ➜  31▕             $this->map = json_decode(File::get($this->filePath), true);
     32▕         }
     33▕     }
     34▕ 
     35▕     /**

Juste for a quick test, I tried to do this on line 31 :
$this->map = json_decode(File::get($this->filePath), true) ?? [];

And the error did not occured anymore, but I don't know if it's the cleanest way.
This is pretty annoying as my tests execution took 5s with parallel instead of 30s without it.

Can you help with this ?

Thanks,
JF

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions