GitHub

NOT IN MENU DEBUG

Ver: 4.0.3 - Build: 77a32b0

 

Examples of using DECLARE(STRICT_TYPES=1);

Points to note:
  1. this "parent" file includes a file with either:
    • strict not set - (fn-strict-0.php)
      function parameter type declarations NOT SET
    • strict set - (fn-strict-1.php)
      function parameter type declarations SET
  2. selecting Test calls the relevant file and the function test(...)
  3. Results are shown in the table
 
Tests:
Test(...) Parent included Result Type
test(2, 3) not declared not declared
test(2, 3) not declared Strict=1
test(2, 3) Strict=1 not declared
test(2, 3) Strict=1 Strict=1
 
test("2","3") not declared not declared
test("2","3") Strict=1 not declared
 
test("2","3") not declared Strict=1
test("2","3") Strict=1 Strict=1 ERROR
 
#1 - Fatal error:
Uncaught TypeError: 
  Argument 1 passed to test() must be of the type integer, string given...
Included file: fn-strict-1.php   

<?php DECLARE(STRICT_TYPES=1);  

function 
test (int $aint $b)
int
{
  return 
$a $b;
}