Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php declare(strict_types=1); /* * This file is part of Composer. * * (c) Nils Aderma..
Decoded Output download
<?php declare(strict_types=1);
/*
* This file is part of Composer.
*
* (c) Nils Adermann <[email protected]>
* Jordi Boggiano <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Test\Util;
use Composer\Util\Silencer;
use Composer\Test\TestCase;
/**
* SilencerTest
*
* @author Niels Keurentjes <[email protected]>
*/
class SilencerTest extends TestCase
{
/**
* Test succeeds when no warnings are emitted externally, and original level is restored.
*/
public function testSilencer(): void
{
$before = error_reporting();
// Check warnings are suppressed correctly
Silencer::suppress();
@trigger_error('Test', E_USER_WARNING);
Silencer::restore();
// Check all parameters and return values are passed correctly in a silenced call.
$result = Silencer::call(static function ($a, $b, $c) {
@trigger_error('Test', E_USER_WARNING);
return $a * $b * $c;
}, 2, 3, 4);
self::assertEquals(24, $result);
// Check the error reporting setting was restored correctly
self::assertEquals($before, error_reporting());
}
/**
* Test whether exception from silent callbacks are correctly forwarded.
*/
public function testSilencedException(): void
{
$verification = microtime();
self::expectException('RuntimeException');
self::expectExceptionMessage($verification);
Silencer::call(static function () use ($verification): void {
throw new \RuntimeException($verification);
});
}
}
?>
Did this file decode correctly?
Original Code
<?php declare(strict_types=1);
/*
* This file is part of Composer.
*
* (c) Nils Adermann <[email protected]>
* Jordi Boggiano <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Test\Util;
use Composer\Util\Silencer;
use Composer\Test\TestCase;
/**
* SilencerTest
*
* @author Niels Keurentjes <[email protected]>
*/
class SilencerTest extends TestCase
{
/**
* Test succeeds when no warnings are emitted externally, and original level is restored.
*/
public function testSilencer(): void
{
$before = error_reporting();
// Check warnings are suppressed correctly
Silencer::suppress();
@trigger_error('Test', E_USER_WARNING);
Silencer::restore();
// Check all parameters and return values are passed correctly in a silenced call.
$result = Silencer::call(static function ($a, $b, $c) {
@trigger_error('Test', E_USER_WARNING);
return $a * $b * $c;
}, 2, 3, 4);
self::assertEquals(24, $result);
// Check the error reporting setting was restored correctly
self::assertEquals($before, error_reporting());
}
/**
* Test whether exception from silent callbacks are correctly forwarded.
*/
public function testSilencedException(): void
{
$verification = microtime();
self::expectException('RuntimeException');
self::expectExceptionMessage($verification);
Silencer::call(static function () use ($verification): void {
throw new \RuntimeException($verification);
});
}
}
Function Calls
None |
Stats
MD5 | 694c34e613caf5a4d7514c8f453ff8a5 |
Eval Count | 0 |
Decode Time | 111 ms |