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

PHP 7.4 Trying to access array offset on value of type null #88

Closed
aun408 opened this issue Jan 14, 2020 · 3 comments
Closed

PHP 7.4 Trying to access array offset on value of type null #88

aun408 opened this issue Jan 14, 2020 · 3 comments

Comments

@aun408
Copy link

aun408 commented Jan 14, 2020

Affected File: Amenadiel\JpGraph\Plot\PiePlot.php
Line: 398
Reason: The value of $this->csimtargets might null, accessing array offset on value of type null will cause exception (E_WARINING) in PHP 7.4

I would like to help and create a pull request but I am not sure what is the expecting value from $graph->legend->Add() if value of $this->csimtargets is null.

My quick fix for now is check if $this->csimtargets is array, if it is not array then pass the null value to $graph->legend->Add() else using the original code ($this->csimtargets[$i]).

Example

if (!is_array($this->csimtargets)) {
    $csimtargetsTmp = null;
} else {
    $csimtargetsTmp = $this->csimtargets[$i];
}
$graph->legend->Add($l, $this->setslicecolors[$i % $numcolors], '', 0, $csimtargetsTmp, $alt, $wintarg);
@ffflabs
Copy link
Collaborator

ffflabs commented Mar 2, 2020

Hmm you could use the coalescing operator

$csimtargetsTmp = ($this->csimtargets ?? [ ])[$i];

I'm not sure either what was supposed to go in that place. Most of this community edition is reverse engineering

@formikaio
Copy link

formikaio commented Apr 14, 2021

Created a pull request for it #106

@ffflabs
Copy link
Collaborator

ffflabs commented Apr 27, 2021

Closed by #106

@ffflabs ffflabs closed this as completed Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants