<?php
class Test {
public function test(string $test, int $test2)
{
print_r($test);
print_r($test2);
}
}
$test = new Test();
$test->test(1, 'test');
$test->test(1, 'test');
Fatal error: Uncaught TypeError: Test::test(): Argument #2 ($test2) must be of type int, string given, called in /in/HldsG on line 12 and defined in /in/HldsG:3
Stack trace:
#0 /in/HldsG(12): Test->test('1', 'test')
#1 {main}
thrown in /in/HldsG on line 3
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 TypeError: Test::test(): Argument #2 ($test2) must be of type int, string given, called in /in/HldsG on line 12 and defined in /in/HldsG:3
Stack trace:
#0 /in/HldsG(12): Test->test('1', 'test')
#1 {main}
thrown in /in/HldsG on line 3
Process exited with code 255.
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Test has a deprecated constructor in /in/HldsG on line 2
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Test::test(), 0 passed in /in/HldsG on line 11 and exactly 2 expected in /in/HldsG:3
Stack trace:
#0 /in/HldsG(11): Test->test()
#1 {main}
thrown in /in/HldsG on line 3
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Test::test(), 0 passed in /in/HldsG on line 11 and exactly 2 expected in /in/HldsG:3
Stack trace:
#0 /in/HldsG(11): Test->test()
#1 {main}
thrown in /in/HldsG on line 3
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Test has a deprecated constructor in /in/HldsG on line 2
Fatal error: Uncaught TypeError: Argument 1 passed to Test::test() must be of the type string, none given, called in /in/HldsG on line 11 and defined in /in/HldsG:3
Stack trace:
#0 /in/HldsG(11): Test->test()
#1 {main}
thrown in /in/HldsG on line 3
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Catchable fatal error: Argument 1 passed to Test::test() must be an instance of string, none given, called in /in/HldsG on line 11 and defined in /in/HldsG on line 3
Process exited with code 255.