I'm using a library via composer that has code like this:
$data['video_id'] = @$data['video_id'] ?: $player['videoId'];
This line is causing a 500
error because $data['video_id']
is not defined. If I remove the @
symbol, I get the exception Notice: Undefined index: video_id
. If I put back the @
symbol, the script simply dies immediately, and nginx returns a 500 status.
PHP's documentation says:
Warning: Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why.
It's possible this is happening here, but the error is not critical: it is a "notice", and according to that documentation, is a valid use for @
.
I can always fork this library and fix the error myself, but I'd like to know why the suppression variable isn't working as intended.