Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove FOB/SymfonyExtension restriction #138

Merged
merged 1 commit into from May 16, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -32,7 +32,7 @@
"behat/mink-selenium2-driver": "^1.3",
"friends-of-behat/page-object-extension": "^0.3",
"friends-of-behat/suite-settings-extension": "^1.0",
"friends-of-behat/symfony-extension": ">=2.0 <=2.0.6",
"friends-of-behat/symfony-extension": "^2.0",
"friends-of-behat/variadic-extension": "^1.1",
"lakion/mink-debug-extension": "^1.2.3",
"leanphp/phpspec-code-coverage": "^4.2",
@@ -47,25 +47,6 @@ public function registerBundles(): iterable
}
}
public function shutdown(): void
{
if (!$this->isTestEnvironment()) {
parent::shutdown();
return;
}
if (false === $this->booted) {
return;
}
$container = $this->getContainer();
parent::shutdown();
$this->cleanupContainer($container);
}
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
$container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
@@ -100,45 +81,4 @@ private function isTestEnvironment(): bool
{
return 0 === strpos($this->getEnvironment(), 'test');
}
/**
* Remove all container references from all loaded services
*/
private function cleanupContainer(ContainerInterface $container): void
{
$containerReflection = new \ReflectionObject($container);
$containerServicesPropertyReflection = $containerReflection->getProperty('services');
$containerServicesPropertyReflection->setAccessible(true);
$services = $containerServicesPropertyReflection->getValue($container) ?: [];
foreach ($services as $serviceId => $service) {
if (null === $service) {
continue;
}
if (in_array($serviceId, self::IGNORED_SERVICES_DURING_CLEANUP, true)) {
continue;
}
$serviceReflection = new \ReflectionObject($service);
if ($serviceReflection->implementsInterface(VirtualProxyInterface::class)) {
continue;
}
$servicePropertiesReflections = $serviceReflection->getProperties();
$servicePropertiesDefaultValues = $serviceReflection->getDefaultProperties();
foreach ($servicePropertiesReflections as $servicePropertyReflection) {
$defaultPropertyValue = null;
if (isset($servicePropertiesDefaultValues[$servicePropertyReflection->getName()])) {
$defaultPropertyValue = $servicePropertiesDefaultValues[$servicePropertyReflection->getName()];
}
$servicePropertyReflection->setAccessible(true);
$servicePropertyReflection->setValue($service, $defaultPropertyValue);
}
}
$containerServicesPropertyReflection->setValue($container, null);
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.