We decided to update php to version 5.6 (from 5.3) on the server - errors fell:

Catchable fatal error: Argument X passed ... must be integer, object given in ...

There were no such errors on the local Windows machine. Test way it was revealed that the problem is in the class name. If it starts with "Int ...", for example, Inter, the interpreter expected the type of Int in the function parameter. In general, the following code:

<?php class Inter { } function foo(Inter $p) { } $a = new Inter(); foo($a); echo 1; ?> 

Generates an error

mod_fcgid: stderr: PHP Catchable fatal error: Argument 1 passed to foo must be integer, object given in /.../test.php on line 6

If the class is called Stringer, we get

Argument 1 passed to foo must be string, object given

If the name is different, then there is no error, but renaming the class names in the project is not a solution.

  • mod_fcgid - this refers to the Apache ......... what kind of apache do you have? it is necessary 2.4 ...... pkhp is nothing to do with absolutely ........ as proof you can go to phpfiddle.org and drive class Inter { } function foo(Inter $p) { } $a = new Inter(); foo($a); echo 1; phpinfo(); class Inter { } function foo(Inter $p) { } $a = new Inter(); foo($a); echo 1; phpinfo(); ...... everything works - Alexey Shimansky
  • I locally have about 30 versions of PHP from 5.0 to 7.1RC1 - in all the above code works correctly. Moreover, PHP5 does not know how to type hinting scalar types, it was done only in PHP7. And if you intentionally specify an erroneous foo (int $ p), then the error will be slightly different "Argument 1 passed to foo ()). It is "instance of type". And in PHP7, Uncaught TypeError is quite remarkable, i.e. also not that. Maybe you have some kind of non-standard static type checking module installed? - Fine
  • @ Small do not fool your head .. Objects (class names) can be given as a type and in version 5 ..... in php7 some more values ​​have been added that can be set - Alexey Shimansky

0