<?php
class A {
public function y() {
$GLOBALS['x'] = null;
}
public function z() {
echo "Hello World\n";
}
}
function nullthrows($x) {
if ($x === null) {
throw new Exception('Unexpected null');
}
return $x;
}
function foo($x) {
if ($x && $x->y()) {
nullthrows($x)->z();
}
}
$GLOBALS['x'] = new A();
$x = &$GLOBALS['x'];
foo($x);
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0