Skip to content

Instantly share code, notes, and snippets.

@mglinski
Last active January 10, 2017 16:30
Show Gist options
  • Save mglinski/b5ddab6e162d0f96c6d28a78af4f715b to your computer and use it in GitHub Desktop.
Save mglinski/b5ddab6e162d0f96c6d28a78af4f715b to your computer and use it in GitHub Desktop.
<?php
function returnsInt() : int {
return 2;
}
function returnsFloat() : float {
return 1;
}
function returnsBool() : bool {
return 1;
}
function returnsString() : string {
return 1;
}
<?php
declare(strict_types=1);
function returnsInt() : int {
return 2;
}
function returnsFloat() : float {
return 1;
}
function returnsBool() : bool {
return 1;
}
function returnsString() : string {
return 1;
}
<?php
if (rand(0,1)) {
echo "Return Types With Strict Types DISABLED in include file\n";
include 'include.php';
} else {
echo "Return Types With Strict Types ENABLED in include file\n";
include 'includeStrict.php';
}
var_dump([
'returnsInt' => returnsInt(),
'returnsFloat' => returnsFloat(),
'returnsBool' => returnsBool(),
'returnsString' => returnsString(),
]);
<?php
declare(strict_types=1);
if (rand(0,1)) {
echo "Return Types With Strict Types DISABLED in include file\n";
include 'include.php';
} else {
echo "Return Types With Strict Types ENABLED in include file\n";
include 'includeStrict.php';
}
var_dump([
'returnsInt' => returnsInt(),
'returnsFloat' => returnsFloat(),
'returnsBool' => returnsBool(),
'returnsString' => returnsString(),
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment