Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
--TEST-- ReflectionNamedType::getName() and ReflectionNamedType::__toString() --FILE-- <?p..
Decoded Output download
--TEST--
ReflectionNamedType::getName() and ReflectionNamedType::__toString()
--FILE--
<?php
function testInternalTypes(?Traversable $traversable): ?string {
return 'test';
}
function testUserDefinedTypes(?Test $traversable): ?Test {
return new Test;
}
$function = new ReflectionFunction('testInternalTypes');
$type = $function->getParameters()[0]->getType();
$return = $function->getReturnType();
var_dump($type->getName());
var_dump((string) $type);
var_dump($return->getName());
var_dump((string) $return);
$function = new ReflectionFunction('testUserDefinedTypes');
$type = $function->getParameters()[0]->getType();
$return = $function->getReturnType();
var_dump($type->getName());
var_dump((string) $type);
var_dump($return->getName());
var_dump((string) $return);
?>
--EXPECT--
string(11) "Traversable"
string(12) "?Traversable"
string(6) "string"
string(7) "?string"
string(4) "Test"
string(5) "?Test"
string(4) "Test"
string(5) "?Test"
Did this file decode correctly?
Original Code
--TEST--
ReflectionNamedType::getName() and ReflectionNamedType::__toString()
--FILE--
<?php
function testInternalTypes(?Traversable $traversable): ?string {
return 'test';
}
function testUserDefinedTypes(?Test $traversable): ?Test {
return new Test;
}
$function = new ReflectionFunction('testInternalTypes');
$type = $function->getParameters()[0]->getType();
$return = $function->getReturnType();
var_dump($type->getName());
var_dump((string) $type);
var_dump($return->getName());
var_dump((string) $return);
$function = new ReflectionFunction('testUserDefinedTypes');
$type = $function->getParameters()[0]->getType();
$return = $function->getReturnType();
var_dump($type->getName());
var_dump((string) $type);
var_dump($return->getName());
var_dump((string) $return);
?>
--EXPECT--
string(11) "Traversable"
string(12) "?Traversable"
string(6) "string"
string(7) "?string"
string(4) "Test"
string(5) "?Test"
string(4) "Test"
string(5) "?Test"
Function Calls
None |
Stats
MD5 | 0bf76c611be5ba69bf354831f4648901 |
Eval Count | 0 |
Decode Time | 79 ms |