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-- Mock static method --FILE-- <?php declare(strict_types=1); class Foo { public..
Decoded Output download
--TEST--
Mock static method
--FILE--
<?php declare(strict_types=1);
class Foo
{
public static function bar(): bool{}
}
require_once __DIR__ . '/../../../bootstrap.php';
$class = new ReflectionClass('Foo');
$mockMethod = \PHPUnit\Framework\MockObject\Generator\MockMethod::fromReflection(
$class->getMethod('bar'),
false,
false
);
$code = $mockMethod->generateCode();
print $code;
--EXPECT--
public static function bar(): bool
{
throw new \PHPUnit\Framework\MockObject\BadMethodCallException('Static method "bar" cannot be invoked on mock object');
}
?>
Did this file decode correctly?
Original Code
--TEST--
Mock static method
--FILE--
<?php declare(strict_types=1);
class Foo
{
public static function bar(): bool{}
}
require_once __DIR__ . '/../../../bootstrap.php';
$class = new ReflectionClass('Foo');
$mockMethod = \PHPUnit\Framework\MockObject\Generator\MockMethod::fromReflection(
$class->getMethod('bar'),
false,
false
);
$code = $mockMethod->generateCode();
print $code;
--EXPECT--
public static function bar(): bool
{
throw new \PHPUnit\Framework\MockObject\BadMethodCallException('Static method "bar" cannot be invoked on mock object');
}
Function Calls
None |
Stats
MD5 | 6147be632a189b3ff82082e2c55f4a05 |
Eval Count | 0 |
Decode Time | 127 ms |