Created
February 26, 2016 18:49
-
-
Save jaytaph/c491f5b5c4027c5dae24 to your computer and use it in GitHub Desktop.
Transpilation example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
function foobar(int $arg1, string $arg2) : int | |
{ | |
return 42; | |
} | |
foobar(1, "foo"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* This code has been transpiled via TransPHPile. For more information, visit https://github.com/jaytaph/transphpile | |
*/ | |
function foobar($arg1, $arg2) | |
{ | |
if (!is_int($arg1)) { | |
throw new \InvalidArgumentException('Argument $arg1 passed to foobar() must be of the type int, ' . (gettype($arg1) == 'object' ? get_class($arg1) : gettype($arg1)) . ' given'); | |
} | |
if (!is_string($arg2)) { | |
throw new \InvalidArgumentException('Argument $arg2 passed to foobar() must be of the type string, ' . (gettype($arg2) == 'object' ? get_class($arg2) : gettype($arg2)) . ' given'); | |
} | |
$ret156d09de17b1a5 = 42; | |
if (!is_int($ret156d09de17b1a5)) { | |
throw new \InvalidArgumentException('Argument returned must be of the type int, ' . gettype($ret156d09de17b1a5) . ' given'); | |
} | |
return $ret156d09de17b1a5; | |
} | |
foobar(1, 'foo'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment