<?php
namespace Foo;
class Bar
{
public function hello()
{
echo "Hello";
}
}
namespace Bar;
class Baz
{
public function hello()
{
echo \Foo\Bar::hello();
}
}
$baz = new Baz();
$baz->hello();
Fatal error: Uncaught Error: Non-static method Foo\Bar::hello() cannot be called statically in /in/Zcl16:19
Stack trace:
#0 /in/Zcl16(24): Bar\Baz->hello()
#1 {main}
thrown in /in/Zcl16 on line 19
Process exited with code 255.
Output for 8.3.5
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
Fatal error: Uncaught Error: Non-static method Foo\Bar::hello() cannot be called statically in /in/Zcl16:19
Stack trace:
#0 /in/Zcl16(24): Bar\Baz->hello()
#1 {main}
thrown in /in/Zcl16 on line 19
Process exited with code 255.
Strict Standards: Non-static method Foo\Bar::hello() should not be called statically, assuming $this from incompatible context in /in/Zcl16 on line 19
Hello