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 namespace Deployer\Component\Pimple; use Deployer\Component\Pimple\Exception\Froze..

Decoded Output download

<?php
  namespace Deployer\Component\Pimple; use Deployer\Component\Pimple\Exception\FrozenServiceException; use Deployer\Component\Pimple\Exception\InvalidServiceIdentifierException; use Deployer\Component\Pimple\Exception\UnknownIdentifierException; use InvalidArgumentException; use PHPUnit\Framework\TestCase; use ReflectionProperty; use RuntimeException; use function extension_loaded; class PimpleTest extends TestCase { public function testWithString() { $pimple = new Container(); $pimple["param"] = "value"; $this->assertEquals("value", $pimple["param"]); } public function testWithClosure() { $pimple = new Container(); $pimple["service"] = function () { return new Service(); }; $this->assertInstanceOf(Service::class, $pimple["service"]); } public function testServicesShouldBeDifferent() { $pimple = new Container(); $pimple["service"] = $pimple->factory(function () { return new Service(); }); $serviceOne = $pimple["service"]; $this->assertInstanceOf(Service::class, $serviceOne); $serviceTwo = $pimple["service"]; $this->assertInstanceOf(Service::class, $serviceTwo); $this->assertNotSame($serviceOne, $serviceTwo); } public function testShouldPassContainerAsParameter() { $pimple = new Container(); $pimple["service"] = function () { return new Service(); }; $pimple["container"] = function ($container) { return $container; }; $this->assertNotSame($pimple, $pimple["service"]); $this->assertSame($pimple, $pimple["container"]); } public function testIsset() { $pimple = new Container(); $pimple["param"] = "value"; $pimple["service"] = function () { return new Service(); }; $pimple["null"] = null; $this->assertTrue(isset($pimple["param"])); $this->assertTrue(isset($pimple["service"])); $this->assertTrue(isset($pimple["null"])); $this->assertFalse(isset($pimple["non_existent"])); } public function testConstructorInjection() { $params = array("param" => "value"); $pimple = new Container($params); $this->assertSame($params["param"], $pimple["param"]); } public function testOffsetGetValidatesKeyIsPresent() { $this->expectException(UnknownIdentifierException::class); $this->expectExceptionMessage("Identifier "foo" is not defined."); $pimple = new Container(); echo $pimple["foo"]; } public function testLegacyOffsetGetValidatesKeyIsPresent() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Identifier "foo" is not defined."); $pimple = new Container(); echo $pimple["foo"]; } public function testOffsetGetHonorsNullValues() { $pimple = new Container(); $pimple["foo"] = null; $this->assertNull($pimple["foo"]); } public function testUnset() { $pimple = new Container(); $pimple["param"] = "value"; $pimple["service"] = function () { return new Service(); }; unset($pimple["param"], $pimple["service"]); $this->assertFalse(isset($pimple["param"])); $this->assertFalse(isset($pimple["service"])); } public function testShare($service) { $pimple = new Container(); $pimple["shared_service"] = $service; $serviceOne = $pimple["shared_service"]; $this->assertInstanceOf(Service::class, $serviceOne); $serviceTwo = $pimple["shared_service"]; $this->assertInstanceOf(Service::class, $serviceTwo); $this->assertSame($serviceOne, $serviceTwo); } public function testProtect($service) { $pimple = new Container(); $pimple["protected"] = $pimple->protect($service); $this->assertSame($service, $pimple["protected"]); } public function testGlobalFunctionNameAsParameterValue() { $pimple = new Container(); $pimple["global_function"] = "strlen"; $this->assertSame("strlen", $pimple["global_function"]); } public function testRaw() { $pimple = new Container(); $pimple["service"] = $definition = $pimple->factory(function () { return "foo"; }); $this->assertSame($definition, $pimple->raw("service")); } public function testRawHonorsNullValues() { $pimple = new Container(); $pimple["foo"] = null; $this->assertNull($pimple->raw("foo")); } public function testRawValidatesKeyIsPresent() { $this->expectException(UnknownIdentifierException::class); $this->expectExceptionMessage("Identifier "foo" is not defined."); $pimple = new Container(); $pimple->raw("foo"); } public function testLegacyRawValidatesKeyIsPresent() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Identifier "foo" is not defined."); $pimple = new Container(); $pimple->raw("foo"); } public function testExtend($service) { $pimple = new Container(); $pimple["shared_service"] = function () { return new Service(); }; $pimple["factory_service"] = $pimple->factory(function () { return new Service(); }); $pimple->extend("shared_service", $service); $serviceOne = $pimple["shared_service"]; $this->assertInstanceOf(Service::class, $serviceOne); $serviceTwo = $pimple["shared_service"]; $this->assertInstanceOf(Service::class, $serviceTwo); $this->assertSame($serviceOne, $serviceTwo); $this->assertSame($serviceOne->value, $serviceTwo->value); $pimple->extend("factory_service", $service); $serviceOne = $pimple["factory_service"]; $this->assertInstanceOf(Service::class, $serviceOne); $serviceTwo = $pimple["factory_service"]; $this->assertInstanceOf(Service::class, $serviceTwo); $this->assertNotSame($serviceOne, $serviceTwo); $this->assertNotSame($serviceOne->value, $serviceTwo->value); } public function testExtendDoesNotLeakWithFactories() { if (extension_loaded("pimple")) { $this->markTestSkipped("Pimple extension does not support this test"); } $pimple = new Container(); $pimple["foo"] = $pimple->factory(function () { return; }); $pimple["foo"] = $pimple->extend("foo", function ($foo, $pimple) { return; }); unset($pimple["foo"]); $p = new ReflectionProperty($pimple, "values"); $p->setAccessible(true); $this->assertEmpty($p->getValue($pimple)); $p = new ReflectionProperty($pimple, "factories"); $p->setAccessible(true); $this->assertCount(0, $p->getValue($pimple)); } public function testExtendValidatesKeyIsPresent() { $this->expectException(UnknownIdentifierException::class); $this->expectExceptionMessage("Identifier "foo" is not defined."); $pimple = new Container(); $pimple->extend("foo", function () { }); } public function testLegacyExtendValidatesKeyIsPresent() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Identifier "foo" is not defined."); $pimple = new Container(); $pimple->extend("foo", function () { }); } public function testKeys() { $pimple = new Container(); $pimple["foo"] = 123; $pimple["bar"] = 123; $this->assertEquals(array("foo", "bar"), $pimple->keys()); } public function settingAnInvokableObjectShouldTreatItAsFactory() { $pimple = new Container(); $pimple["invokable"] = new Invokable(); $this->assertInstanceOf(Service::class, $pimple["invokable"]); } public function settingNonInvokableObjectShouldTreatItAsParameter() { $pimple = new Container(); $pimple["non_invokable"] = new NonInvokable(); $this->assertInstanceOf(NonInvokable::class, $pimple["non_invokable"]); } public function testFactoryFailsForInvalidServiceDefinitions($service) { $this->expectException(\TypeError::class); $pimple = new Container(); $pimple->factory($service); } public function testLegacyFactoryFailsForInvalidServiceDefinitions($service) { $this->expectException(\TypeError::class); $pimple = new Container(); $pimple->factory($service); } public function testProtectFailsForInvalidServiceDefinitions($service) { $this->expectException(\TypeError::class); $pimple = new Container(); $pimple->protect($service); } public function testLegacyProtectFailsForInvalidServiceDefinitions($service) { $this->expectException(\TypeError::class); $pimple = new Container(); $pimple->protect($service); } public function testExtendFailsForKeysNotContainingServiceDefinitions($service) { $this->expectException(InvalidServiceIdentifierException::class); $this->expectExceptionMessage("Identifier "foo" does not contain an object definition."); $pimple = new Container(); $pimple["foo"] = $service; $pimple->extend("foo", function () { }); } public function testLegacyExtendFailsForKeysNotContainingServiceDefinitions($service) { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Identifier "foo" does not contain an object definition."); $pimple = new Container(); $pimple["foo"] = $service; $pimple->extend("foo", function () { }); } public function testExtendingProtectedClosureDeprecation() { $pimple = new Container(); $pimple["foo"] = $pimple->protect(function () { return "bar"; }); $pimple->extend("foo", function ($value) { return $value . "-baz"; }); $this->assertSame("bar-baz", $pimple["foo"]); } public function testExtendFailsForInvalidServiceDefinitions($service) { $this->expectException(\TypeError::class); $pimple = new Container(); $pimple["foo"] = function () { }; $pimple->extend("foo", $service); } public function testLegacyExtendFailsForInvalidServiceDefinitions($service) { $this->expectException(\TypeError::class); $pimple = new Container(); $pimple["foo"] = function () { }; $pimple->extend("foo", $service); } public function testExtendFailsIfFrozenServiceIsNonInvokable() { $this->expectException(FrozenServiceException::class); $this->expectExceptionMessage("Cannot override frozen service "foo"."); $pimple = new Container(); $pimple["foo"] = function () { return new NonInvokable(); }; $foo = $pimple["foo"]; $pimple->extend("foo", function () { }); } public function testExtendFailsIfFrozenServiceIsInvokable() { $this->expectException(FrozenServiceException::class); $this->expectExceptionMessage("Cannot override frozen service "foo"."); $pimple = new Container(); $pimple["foo"] = function () { return new Invokable(); }; $foo = $pimple["foo"]; $pimple->extend("foo", function () { }); } public function badServiceDefinitionProvider() { return array(array(123), array(new NonInvokable())); } public function serviceDefinitionProvider() { return array(array(function ($value) { $service = new Service(); $service->value = $value; return $service; }), array(new Invokable())); } public function testDefiningNewServiceAfterFreeze() { $pimple = new Container(); $pimple["foo"] = function () { return "foo"; }; $foo = $pimple["foo"]; $pimple["bar"] = function () { return "bar"; }; $this->assertSame("bar", $pimple["bar"]); } public function testOverridingServiceAfterFreeze() { $this->expectException(FrozenServiceException::class); $this->expectExceptionMessage("Cannot override frozen service "foo"."); $pimple = new Container(); $pimple["foo"] = function () { return "foo"; }; $foo = $pimple["foo"]; $pimple["foo"] = function () { return "bar"; }; } public function testLegacyOverridingServiceAfterFreeze() { $this->expectException(RuntimeException::class); $this->expectExceptionMessage("Cannot override frozen service "foo"."); $pimple = new Container(); $pimple["foo"] = function () { return "foo"; }; $foo = $pimple["foo"]; $pimple["foo"] = function () { return "bar"; }; } public function testRemovingServiceAfterFreeze() { $pimple = new Container(); $pimple["foo"] = function () { return "foo"; }; $foo = $pimple["foo"]; unset($pimple["foo"]); $pimple["foo"] = function () { return "bar"; }; $this->assertSame("bar", $pimple["foo"]); } public function testExtendingService() { $pimple = new Container(); $pimple["foo"] = function () { return "foo"; }; $pimple["foo"] = $pimple->extend("foo", function ($foo, $app) { return "{$foo}.bar"; }); $pimple["foo"] = $pimple->extend("foo", function ($foo, $app) { return "{$foo}.baz"; }); $this->assertSame("foo.bar.baz", $pimple["foo"]); } public function testExtendingServiceAfterOtherServiceFreeze() { $pimple = new Container(); $pimple["foo"] = function () { return "foo"; }; $pimple["bar"] = function () { return "bar"; }; $foo = $pimple["foo"]; $pimple["bar"] = $pimple->extend("bar", function ($bar, $app) { return "{$bar}.baz"; }); $this->assertSame("bar.baz", $pimple["bar"]); } } class Invokable { public function __invoke($value = null) { $service = new Service(); $service->value = $value; return $service; } } class NonInvokable { public function __call($a, $b) { } } class Service { public $value; } ?>

Did this file decode correctly?

Original Code

<?php
  namespace Deployer\Component\Pimple; use Deployer\Component\Pimple\Exception\FrozenServiceException; use Deployer\Component\Pimple\Exception\InvalidServiceIdentifierException; use Deployer\Component\Pimple\Exception\UnknownIdentifierException; use InvalidArgumentException; use PHPUnit\Framework\TestCase; use ReflectionProperty; use RuntimeException; use function extension_loaded; class PimpleTest extends TestCase { public function testWithString() { $pimple = new Container(); $pimple["\x70\141\162\x61\155"] = "\166\141\154\x75\x65"; $this->assertEquals("\x76\x61\x6c\165\145", $pimple["\160\x61\x72\x61\x6d"]); } public function testWithClosure() { $pimple = new Container(); $pimple["\163\145\162\166\151\143\145"] = function () { return new Service(); }; $this->assertInstanceOf(Service::class, $pimple["\x73\145\x72\166\151\x63\145"]); } public function testServicesShouldBeDifferent() { $pimple = new Container(); $pimple["\163\x65\162\x76\x69\x63\x65"] = $pimple->factory(function () { return new Service(); }); $serviceOne = $pimple["\163\x65\x72\x76\x69\x63\145"]; $this->assertInstanceOf(Service::class, $serviceOne); $serviceTwo = $pimple["\x73\x65\x72\x76\151\143\145"]; $this->assertInstanceOf(Service::class, $serviceTwo); $this->assertNotSame($serviceOne, $serviceTwo); } public function testShouldPassContainerAsParameter() { $pimple = new Container(); $pimple["\x73\x65\162\166\x69\x63\x65"] = function () { return new Service(); }; $pimple["\143\157\x6e\164\x61\151\x6e\145\162"] = function ($container) { return $container; }; $this->assertNotSame($pimple, $pimple["\x73\x65\x72\166\x69\x63\x65"]); $this->assertSame($pimple, $pimple["\143\157\x6e\x74\x61\x69\x6e\x65\162"]); } public function testIsset() { $pimple = new Container(); $pimple["\x70\141\x72\141\155"] = "\166\x61\x6c\x75\145"; $pimple["\163\x65\162\x76\151\143\145"] = function () { return new Service(); }; $pimple["\x6e\165\x6c\154"] = null; $this->assertTrue(isset($pimple["\160\141\x72\x61\155"])); $this->assertTrue(isset($pimple["\163\x65\x72\166\151\143\x65"])); $this->assertTrue(isset($pimple["\x6e\165\154\154"])); $this->assertFalse(isset($pimple["\156\x6f\x6e\x5f\x65\x78\151\163\x74\x65\156\164"])); } public function testConstructorInjection() { $params = array("\160\141\x72\x61\x6d" => "\166\x61\154\165\145"); $pimple = new Container($params); $this->assertSame($params["\160\141\162\x61\155"], $pimple["\x70\141\162\141\155"]); } public function testOffsetGetValidatesKeyIsPresent() { $this->expectException(UnknownIdentifierException::class); $this->expectExceptionMessage("\111\144\145\x6e\x74\151\146\x69\x65\x72\x20\42\146\157\157\x22\40\151\x73\x20\x6e\x6f\x74\40\144\x65\x66\151\x6e\145\144\x2e"); $pimple = new Container(); echo $pimple["\x66\x6f\x6f"]; } public function testLegacyOffsetGetValidatesKeyIsPresent() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("\x49\144\145\x6e\164\151\146\151\x65\x72\x20\x22\x66\x6f\157\x22\x20\151\x73\40\x6e\x6f\164\40\x64\x65\146\x69\x6e\145\144\56"); $pimple = new Container(); echo $pimple["\146\157\x6f"]; } public function testOffsetGetHonorsNullValues() { $pimple = new Container(); $pimple["\x66\x6f\157"] = null; $this->assertNull($pimple["\146\157\x6f"]); } public function testUnset() { $pimple = new Container(); $pimple["\x70\141\x72\x61\155"] = "\166\x61\154\165\145"; $pimple["\163\x65\x72\x76\151\143\x65"] = function () { return new Service(); }; unset($pimple["\x70\x61\x72\x61\155"], $pimple["\x73\145\x72\x76\151\x63\x65"]); $this->assertFalse(isset($pimple["\160\x61\162\141\155"])); $this->assertFalse(isset($pimple["\163\145\162\166\151\x63\145"])); } public function testShare($service) { $pimple = new Container(); $pimple["\x73\x68\x61\x72\145\144\x5f\163\145\x72\x76\x69\143\x65"] = $service; $serviceOne = $pimple["\x73\150\141\162\145\144\x5f\x73\x65\162\x76\x69\143\x65"]; $this->assertInstanceOf(Service::class, $serviceOne); $serviceTwo = $pimple["\163\x68\141\162\x65\x64\137\x73\x65\162\166\x69\143\145"]; $this->assertInstanceOf(Service::class, $serviceTwo); $this->assertSame($serviceOne, $serviceTwo); } public function testProtect($service) { $pimple = new Container(); $pimple["\160\x72\x6f\x74\145\143\x74\145\144"] = $pimple->protect($service); $this->assertSame($service, $pimple["\x70\162\157\x74\145\x63\x74\145\144"]); } public function testGlobalFunctionNameAsParameterValue() { $pimple = new Container(); $pimple["\x67\x6c\x6f\x62\141\154\x5f\146\x75\x6e\143\164\x69\157\x6e"] = "\163\164\162\x6c\x65\x6e"; $this->assertSame("\163\164\162\x6c\x65\156", $pimple["\147\154\x6f\142\141\154\137\x66\165\156\143\164\151\x6f\156"]); } public function testRaw() { $pimple = new Container(); $pimple["\163\x65\162\x76\151\143\x65"] = $definition = $pimple->factory(function () { return "\x66\x6f\157"; }); $this->assertSame($definition, $pimple->raw("\x73\145\x72\166\151\x63\x65")); } public function testRawHonorsNullValues() { $pimple = new Container(); $pimple["\146\x6f\157"] = null; $this->assertNull($pimple->raw("\x66\157\x6f")); } public function testRawValidatesKeyIsPresent() { $this->expectException(UnknownIdentifierException::class); $this->expectExceptionMessage("\x49\x64\x65\156\x74\x69\146\151\x65\x72\40\x22\146\x6f\157\42\40\151\x73\x20\x6e\157\164\x20\144\x65\146\x69\156\x65\x64\x2e"); $pimple = new Container(); $pimple->raw("\146\157\x6f"); } public function testLegacyRawValidatesKeyIsPresent() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("\111\144\x65\156\164\x69\146\151\145\x72\x20\42\x66\x6f\157\x22\40\x69\x73\x20\x6e\157\164\x20\x64\145\146\151\156\x65\x64\x2e"); $pimple = new Container(); $pimple->raw("\146\157\157"); } public function testExtend($service) { $pimple = new Container(); $pimple["\163\150\141\162\145\x64\137\163\145\x72\x76\151\x63\x65"] = function () { return new Service(); }; $pimple["\146\141\143\x74\x6f\x72\x79\x5f\x73\x65\x72\x76\x69\x63\145"] = $pimple->factory(function () { return new Service(); }); $pimple->extend("\163\x68\141\162\x65\144\137\163\145\162\166\x69\143\145", $service); $serviceOne = $pimple["\x73\150\141\x72\x65\144\x5f\163\145\162\x76\x69\x63\x65"]; $this->assertInstanceOf(Service::class, $serviceOne); $serviceTwo = $pimple["\163\150\x61\162\x65\x64\137\x73\x65\x72\x76\x69\143\145"]; $this->assertInstanceOf(Service::class, $serviceTwo); $this->assertSame($serviceOne, $serviceTwo); $this->assertSame($serviceOne->value, $serviceTwo->value); $pimple->extend("\x66\x61\143\x74\x6f\x72\171\137\163\145\x72\x76\x69\143\145", $service); $serviceOne = $pimple["\x66\x61\143\x74\157\x72\x79\x5f\163\145\162\x76\151\143\145"]; $this->assertInstanceOf(Service::class, $serviceOne); $serviceTwo = $pimple["\146\141\143\164\157\162\171\x5f\x73\x65\162\x76\x69\x63\x65"]; $this->assertInstanceOf(Service::class, $serviceTwo); $this->assertNotSame($serviceOne, $serviceTwo); $this->assertNotSame($serviceOne->value, $serviceTwo->value); } public function testExtendDoesNotLeakWithFactories() { if (extension_loaded("\x70\151\155\160\x6c\145")) { $this->markTestSkipped("\120\151\x6d\160\x6c\145\x20\145\170\x74\x65\x6e\x73\x69\157\156\40\x64\157\x65\x73\40\156\157\164\40\x73\x75\160\x70\157\162\x74\x20\x74\x68\151\x73\x20\164\145\x73\164"); } $pimple = new Container(); $pimple["\x66\157\x6f"] = $pimple->factory(function () { return; }); $pimple["\x66\x6f\157"] = $pimple->extend("\146\157\157", function ($foo, $pimple) { return; }); unset($pimple["\x66\x6f\x6f"]); $p = new ReflectionProperty($pimple, "\166\x61\x6c\165\x65\163"); $p->setAccessible(true); $this->assertEmpty($p->getValue($pimple)); $p = new ReflectionProperty($pimple, "\146\x61\x63\164\157\x72\151\145\x73"); $p->setAccessible(true); $this->assertCount(0, $p->getValue($pimple)); } public function testExtendValidatesKeyIsPresent() { $this->expectException(UnknownIdentifierException::class); $this->expectExceptionMessage("\111\x64\x65\x6e\164\x69\146\x69\x65\x72\40\x22\146\157\x6f\x22\x20\x69\x73\40\156\157\x74\40\144\145\x66\x69\156\145\x64\56"); $pimple = new Container(); $pimple->extend("\x66\157\157", function () { }); } public function testLegacyExtendValidatesKeyIsPresent() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("\111\144\145\156\x74\151\146\151\145\162\40\42\x66\157\157\42\40\151\x73\40\x6e\157\x74\x20\144\x65\x66\x69\x6e\x65\x64\x2e"); $pimple = new Container(); $pimple->extend("\146\157\x6f", function () { }); } public function testKeys() { $pimple = new Container(); $pimple["\x66\157\x6f"] = 123; $pimple["\x62\141\162"] = 123; $this->assertEquals(array("\x66\157\x6f", "\x62\141\162"), $pimple->keys()); } public function settingAnInvokableObjectShouldTreatItAsFactory() { $pimple = new Container(); $pimple["\151\x6e\166\x6f\153\141\142\154\x65"] = new Invokable(); $this->assertInstanceOf(Service::class, $pimple["\151\x6e\166\x6f\153\x61\142\x6c\x65"]); } public function settingNonInvokableObjectShouldTreatItAsParameter() { $pimple = new Container(); $pimple["\x6e\x6f\x6e\x5f\x69\156\x76\x6f\x6b\x61\142\154\145"] = new NonInvokable(); $this->assertInstanceOf(NonInvokable::class, $pimple["\x6e\157\x6e\137\151\156\166\157\x6b\x61\x62\x6c\145"]); } public function testFactoryFailsForInvalidServiceDefinitions($service) { $this->expectException(\TypeError::class); $pimple = new Container(); $pimple->factory($service); } public function testLegacyFactoryFailsForInvalidServiceDefinitions($service) { $this->expectException(\TypeError::class); $pimple = new Container(); $pimple->factory($service); } public function testProtectFailsForInvalidServiceDefinitions($service) { $this->expectException(\TypeError::class); $pimple = new Container(); $pimple->protect($service); } public function testLegacyProtectFailsForInvalidServiceDefinitions($service) { $this->expectException(\TypeError::class); $pimple = new Container(); $pimple->protect($service); } public function testExtendFailsForKeysNotContainingServiceDefinitions($service) { $this->expectException(InvalidServiceIdentifierException::class); $this->expectExceptionMessage("\x49\x64\x65\x6e\x74\x69\x66\x69\x65\162\40\x22\146\x6f\x6f\42\40\144\157\145\x73\x20\156\157\164\40\143\157\x6e\x74\141\151\156\x20\141\x6e\40\x6f\142\x6a\145\x63\164\40\x64\x65\146\151\156\x69\x74\x69\x6f\x6e\56"); $pimple = new Container(); $pimple["\146\x6f\157"] = $service; $pimple->extend("\x66\x6f\157", function () { }); } public function testLegacyExtendFailsForKeysNotContainingServiceDefinitions($service) { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("\x49\144\145\156\164\x69\146\151\x65\162\40\x22\x66\x6f\x6f\x22\x20\144\x6f\145\163\x20\156\157\x74\x20\x63\157\156\x74\141\151\156\40\141\x6e\x20\x6f\142\152\145\x63\x74\40\x64\x65\x66\151\156\151\x74\151\157\x6e\56"); $pimple = new Container(); $pimple["\146\157\x6f"] = $service; $pimple->extend("\x66\x6f\x6f", function () { }); } public function testExtendingProtectedClosureDeprecation() { $pimple = new Container(); $pimple["\146\157\157"] = $pimple->protect(function () { return "\142\x61\x72"; }); $pimple->extend("\x66\x6f\157", function ($value) { return $value . "\x2d\x62\141\172"; }); $this->assertSame("\x62\141\162\55\x62\x61\x7a", $pimple["\146\157\x6f"]); } public function testExtendFailsForInvalidServiceDefinitions($service) { $this->expectException(\TypeError::class); $pimple = new Container(); $pimple["\x66\157\x6f"] = function () { }; $pimple->extend("\x66\x6f\157", $service); } public function testLegacyExtendFailsForInvalidServiceDefinitions($service) { $this->expectException(\TypeError::class); $pimple = new Container(); $pimple["\146\x6f\157"] = function () { }; $pimple->extend("\146\x6f\x6f", $service); } public function testExtendFailsIfFrozenServiceIsNonInvokable() { $this->expectException(FrozenServiceException::class); $this->expectExceptionMessage("\x43\x61\x6e\x6e\157\164\40\157\x76\x65\162\x72\151\144\145\40\x66\x72\x6f\172\x65\x6e\x20\163\x65\162\x76\151\x63\x65\x20\42\x66\157\x6f\x22\56"); $pimple = new Container(); $pimple["\146\x6f\157"] = function () { return new NonInvokable(); }; $foo = $pimple["\x66\157\x6f"]; $pimple->extend("\x66\157\157", function () { }); } public function testExtendFailsIfFrozenServiceIsInvokable() { $this->expectException(FrozenServiceException::class); $this->expectExceptionMessage("\103\141\156\156\x6f\x74\40\157\166\145\x72\x72\x69\x64\145\x20\x66\x72\157\172\x65\x6e\40\x73\145\x72\x76\x69\x63\145\x20\42\146\x6f\x6f\x22\56"); $pimple = new Container(); $pimple["\146\157\x6f"] = function () { return new Invokable(); }; $foo = $pimple["\146\x6f\x6f"]; $pimple->extend("\146\157\x6f", function () { }); } public function badServiceDefinitionProvider() { return array(array(123), array(new NonInvokable())); } public function serviceDefinitionProvider() { return array(array(function ($value) { $service = new Service(); $service->value = $value; return $service; }), array(new Invokable())); } public function testDefiningNewServiceAfterFreeze() { $pimple = new Container(); $pimple["\x66\x6f\x6f"] = function () { return "\146\x6f\x6f"; }; $foo = $pimple["\146\157\x6f"]; $pimple["\142\141\x72"] = function () { return "\x62\x61\162"; }; $this->assertSame("\142\141\162", $pimple["\x62\x61\x72"]); } public function testOverridingServiceAfterFreeze() { $this->expectException(FrozenServiceException::class); $this->expectExceptionMessage("\103\x61\x6e\156\x6f\164\40\x6f\166\145\162\x72\x69\144\x65\x20\146\162\157\172\145\156\x20\x73\x65\162\x76\151\x63\x65\x20\x22\146\x6f\157\42\x2e"); $pimple = new Container(); $pimple["\x66\157\157"] = function () { return "\x66\x6f\157"; }; $foo = $pimple["\x66\157\x6f"]; $pimple["\146\157\x6f"] = function () { return "\142\141\162"; }; } public function testLegacyOverridingServiceAfterFreeze() { $this->expectException(RuntimeException::class); $this->expectExceptionMessage("\103\141\156\156\x6f\x74\x20\x6f\166\145\162\162\x69\x64\x65\40\x66\x72\x6f\x7a\x65\x6e\40\163\145\x72\166\151\x63\x65\x20\x22\146\x6f\157\42\x2e"); $pimple = new Container(); $pimple["\x66\157\x6f"] = function () { return "\x66\x6f\157"; }; $foo = $pimple["\146\x6f\x6f"]; $pimple["\146\157\x6f"] = function () { return "\142\141\x72"; }; } public function testRemovingServiceAfterFreeze() { $pimple = new Container(); $pimple["\x66\x6f\157"] = function () { return "\x66\x6f\157"; }; $foo = $pimple["\x66\157\157"]; unset($pimple["\146\x6f\157"]); $pimple["\x66\157\157"] = function () { return "\142\141\x72"; }; $this->assertSame("\x62\141\x72", $pimple["\146\x6f\x6f"]); } public function testExtendingService() { $pimple = new Container(); $pimple["\x66\157\x6f"] = function () { return "\x66\157\157"; }; $pimple["\x66\157\157"] = $pimple->extend("\146\157\x6f", function ($foo, $app) { return "{$foo}\56\142\141\x72"; }); $pimple["\146\x6f\x6f"] = $pimple->extend("\146\157\x6f", function ($foo, $app) { return "{$foo}\56\142\141\172"; }); $this->assertSame("\146\x6f\157\56\x62\141\x72\x2e\142\x61\172", $pimple["\146\x6f\157"]); } public function testExtendingServiceAfterOtherServiceFreeze() { $pimple = new Container(); $pimple["\146\157\157"] = function () { return "\146\x6f\x6f"; }; $pimple["\142\141\x72"] = function () { return "\x62\141\x72"; }; $foo = $pimple["\x66\157\x6f"]; $pimple["\142\x61\162"] = $pimple->extend("\142\141\x72", function ($bar, $app) { return "{$bar}\x2e\x62\x61\172"; }); $this->assertSame("\x62\x61\162\x2e\x62\141\172", $pimple["\x62\141\x72"]); } } class Invokable { public function __invoke($value = null) { $service = new Service(); $service->value = $value; return $service; } } class NonInvokable { public function __call($a, $b) { } } class Service { public $value; }

Function Calls

None

Variables

None

Stats

MD5 197ad269a29969848c2c725da0aa7e78
Eval Count 0
Decode Time 90 ms