1. Error in PHP 7.4.6: try to access array offset on value of type bool, as shown in Figure 1
Figure 1
2. Check the code and print $result, its value is bool(true). as shown in Figure 2
Figure 2
$result = $planService->reportUpCreate($model, $planAttendedUserRelations, $materialAssets, $identity);
var_dump($result);
exit;
if ($result['status'] === false) {
throw new ServerErrorHttpException($result['message'], $result['code']);
}
3. Try to access an array subscript of a value of type BOOL, so an error is reported. Although it was working normally in PHP 7.2.14 before. From this analysis, it is concluded that the PHP language itself has more rigorous requirements for grammar. Refer to the official documentation: backward incompatibility changes for version 7.4, array-style access for non-arrays, and now, try to use values of null, bool, int, float or resource as an array (e.g. $null[“key”]) will generate a notification. https://www.php.net/manual/en/migration74.incompatible.php . as shown in Figure 3
Figure 3
4. Edit the code, and the condition judgment is adjusted to: !$result. Normal operation, no errors are reported again
$result = $planService->reportUpCreate($model, $planAttendedUserRelations, $materialAssets, $identity);
if (!$result) {
throw new ServerErrorHttpException($result['message'], $result['code']);
}
Leave a Reply