Kernel.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel;
  11. use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
  12. use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
  13. use Symfony\Component\DependencyInjection\ContainerInterface;
  14. use Symfony\Component\DependencyInjection\ContainerBuilder;
  15. use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
  16. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
  17. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  18. use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
  19. use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
  20. use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
  21. use Symfony\Component\DependencyInjection\Loader\DirectoryLoader;
  22. use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
  23. use Symfony\Component\HttpFoundation\Request;
  24. use Symfony\Component\HttpFoundation\Response;
  25. use Symfony\Component\HttpKernel\Bundle\BundleInterface;
  26. use Symfony\Component\HttpKernel\Config\EnvParametersResource;
  27. use Symfony\Component\HttpKernel\Config\FileLocator;
  28. use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
  29. use Symfony\Component\HttpKernel\DependencyInjection\AddClassesToCachePass;
  30. use Symfony\Component\Config\Loader\LoaderResolver;
  31. use Symfony\Component\Config\Loader\DelegatingLoader;
  32. use Symfony\Component\Config\ConfigCache;
  33. use Symfony\Component\ClassLoader\ClassCollectionLoader;
  34. /**
  35. * The Kernel is the heart of the Symfony system.
  36. *
  37. * It manages an environment made of bundles.
  38. *
  39. * @author Fabien Potencier <fabien@symfony.com>
  40. */
  41. abstract class Kernel implements KernelInterface, TerminableInterface
  42. {
  43. /**
  44. * @var BundleInterface[]
  45. */
  46. protected $bundles = array();
  47. protected $bundleMap;
  48. protected $container;
  49. protected $rootDir;
  50. protected $environment;
  51. protected $debug;
  52. protected $booted = false;
  53. protected $name;
  54. protected $startTime;
  55. protected $loadClassCache;
  56. const VERSION = '3.0.9';
  57. const VERSION_ID = 30009;
  58. const MAJOR_VERSION = 3;
  59. const MINOR_VERSION = 0;
  60. const RELEASE_VERSION = 9;
  61. const EXTRA_VERSION = '';
  62. const END_OF_MAINTENANCE = '07/2016';
  63. const END_OF_LIFE = '01/2017';
  64. /**
  65. * Constructor.
  66. *
  67. * @param string $environment The environment
  68. * @param bool $debug Whether to enable debugging or not
  69. */
  70. public function __construct($environment, $debug)
  71. {
  72. $this->environment = $environment;
  73. $this->debug = (bool) $debug;
  74. $this->rootDir = $this->getRootDir();
  75. $this->name = $this->getName();
  76. if ($this->debug) {
  77. $this->startTime = microtime(true);
  78. }
  79. }
  80. public function __clone()
  81. {
  82. if ($this->debug) {
  83. $this->startTime = microtime(true);
  84. }
  85. $this->booted = false;
  86. $this->container = null;
  87. }
  88. /**
  89. * Boots the current kernel.
  90. */
  91. public function boot()
  92. {
  93. if (true === $this->booted) {
  94. return;
  95. }
  96. if ($this->loadClassCache) {
  97. $this->doLoadClassCache($this->loadClassCache[0], $this->loadClassCache[1]);
  98. }
  99. // init bundles
  100. $this->initializeBundles();
  101. // init container
  102. $this->initializeContainer();
  103. foreach ($this->getBundles() as $bundle) {
  104. $bundle->setContainer($this->container);
  105. $bundle->boot();
  106. }
  107. $this->booted = true;
  108. }
  109. /**
  110. * {@inheritdoc}
  111. */
  112. public function terminate(Request $request, Response $response)
  113. {
  114. if (false === $this->booted) {
  115. return;
  116. }
  117. if ($this->getHttpKernel() instanceof TerminableInterface) {
  118. $this->getHttpKernel()->terminate($request, $response);
  119. }
  120. }
  121. /**
  122. * {@inheritdoc}
  123. */
  124. public function shutdown()
  125. {
  126. if (false === $this->booted) {
  127. return;
  128. }
  129. $this->booted = false;
  130. foreach ($this->getBundles() as $bundle) {
  131. $bundle->shutdown();
  132. $bundle->setContainer(null);
  133. }
  134. $this->container = null;
  135. }
  136. /**
  137. * {@inheritdoc}
  138. */
  139. public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
  140. {
  141. if (false === $this->booted) {
  142. $this->boot();
  143. }
  144. return $this->getHttpKernel()->handle($request, $type, $catch);
  145. }
  146. /**
  147. * Gets a HTTP kernel from the container.
  148. *
  149. * @return HttpKernel
  150. */
  151. protected function getHttpKernel()
  152. {
  153. return $this->container->get('http_kernel');
  154. }
  155. /**
  156. * {@inheritdoc}
  157. */
  158. public function getBundles()
  159. {
  160. return $this->bundles;
  161. }
  162. /**
  163. * {@inheritdoc}
  164. */
  165. public function getBundle($name, $first = true)
  166. {
  167. if (!isset($this->bundleMap[$name])) {
  168. throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, get_class($this)));
  169. }
  170. if (true === $first) {
  171. return $this->bundleMap[$name][0];
  172. }
  173. return $this->bundleMap[$name];
  174. }
  175. /**
  176. * {@inheritdoc}
  177. *
  178. * @throws \RuntimeException if a custom resource is hidden by a resource in a derived bundle
  179. */
  180. public function locateResource($name, $dir = null, $first = true)
  181. {
  182. if ('@' !== $name[0]) {
  183. throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name));
  184. }
  185. if (false !== strpos($name, '..')) {
  186. throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name));
  187. }
  188. $bundleName = substr($name, 1);
  189. $path = '';
  190. if (false !== strpos($bundleName, '/')) {
  191. list($bundleName, $path) = explode('/', $bundleName, 2);
  192. }
  193. $isResource = 0 === strpos($path, 'Resources') && null !== $dir;
  194. $overridePath = substr($path, 9);
  195. $resourceBundle = null;
  196. $bundles = $this->getBundle($bundleName, false);
  197. $files = array();
  198. foreach ($bundles as $bundle) {
  199. if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) {
  200. if (null !== $resourceBundle) {
  201. throw new \RuntimeException(sprintf('"%s" resource is hidden by a resource from the "%s" derived bundle. Create a "%s" file to override the bundle resource.',
  202. $file,
  203. $resourceBundle,
  204. $dir.'/'.$bundles[0]->getName().$overridePath
  205. ));
  206. }
  207. if ($first) {
  208. return $file;
  209. }
  210. $files[] = $file;
  211. }
  212. if (file_exists($file = $bundle->getPath().'/'.$path)) {
  213. if ($first && !$isResource) {
  214. return $file;
  215. }
  216. $files[] = $file;
  217. $resourceBundle = $bundle->getName();
  218. }
  219. }
  220. if (count($files) > 0) {
  221. return $first && $isResource ? $files[0] : $files;
  222. }
  223. throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name));
  224. }
  225. /**
  226. * {@inheritdoc}
  227. */
  228. public function getName()
  229. {
  230. if (null === $this->name) {
  231. $this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir));
  232. }
  233. return $this->name;
  234. }
  235. /**
  236. * {@inheritdoc}
  237. */
  238. public function getEnvironment()
  239. {
  240. return $this->environment;
  241. }
  242. /**
  243. * {@inheritdoc}
  244. */
  245. public function isDebug()
  246. {
  247. return $this->debug;
  248. }
  249. /**
  250. * {@inheritdoc}
  251. */
  252. public function getRootDir()
  253. {
  254. if (null === $this->rootDir) {
  255. $r = new \ReflectionObject($this);
  256. $this->rootDir = dirname($r->getFileName());
  257. }
  258. return $this->rootDir;
  259. }
  260. /**
  261. * {@inheritdoc}
  262. */
  263. public function getContainer()
  264. {
  265. return $this->container;
  266. }
  267. /**
  268. * Loads the PHP class cache.
  269. *
  270. * This methods only registers the fact that you want to load the cache classes.
  271. * The cache will actually only be loaded when the Kernel is booted.
  272. *
  273. * That optimization is mainly useful when using the HttpCache class in which
  274. * case the class cache is not loaded if the Response is in the cache.
  275. *
  276. * @param string $name The cache name prefix
  277. * @param string $extension File extension of the resulting file
  278. */
  279. public function loadClassCache($name = 'classes', $extension = '.php')
  280. {
  281. $this->loadClassCache = array($name, $extension);
  282. }
  283. /**
  284. * Used internally.
  285. */
  286. public function setClassCache(array $classes)
  287. {
  288. file_put_contents($this->getCacheDir().'/classes.map', sprintf('<?php return %s;', var_export($classes, true)));
  289. }
  290. /**
  291. * {@inheritdoc}
  292. */
  293. public function getStartTime()
  294. {
  295. return $this->debug ? $this->startTime : -INF;
  296. }
  297. /**
  298. * {@inheritdoc}
  299. */
  300. public function getCacheDir()
  301. {
  302. return $this->rootDir.'/cache/'.$this->environment;
  303. }
  304. /**
  305. * {@inheritdoc}
  306. */
  307. public function getLogDir()
  308. {
  309. return $this->rootDir.'/logs';
  310. }
  311. /**
  312. * {@inheritdoc}
  313. */
  314. public function getCharset()
  315. {
  316. return 'UTF-8';
  317. }
  318. protected function doLoadClassCache($name, $extension)
  319. {
  320. if (!$this->booted && is_file($this->getCacheDir().'/classes.map')) {
  321. ClassCollectionLoader::load(include($this->getCacheDir().'/classes.map'), $this->getCacheDir(), $name, $this->debug, false, $extension);
  322. }
  323. }
  324. /**
  325. * Initializes the data structures related to the bundle management.
  326. *
  327. * - the bundles property maps a bundle name to the bundle instance,
  328. * - the bundleMap property maps a bundle name to the bundle inheritance hierarchy (most derived bundle first).
  329. *
  330. * @throws \LogicException if two bundles share a common name
  331. * @throws \LogicException if a bundle tries to extend a non-registered bundle
  332. * @throws \LogicException if a bundle tries to extend itself
  333. * @throws \LogicException if two bundles extend the same ancestor
  334. */
  335. protected function initializeBundles()
  336. {
  337. // init bundles
  338. $this->bundles = array();
  339. $topMostBundles = array();
  340. $directChildren = array();
  341. foreach ($this->registerBundles() as $bundle) {
  342. $name = $bundle->getName();
  343. if (isset($this->bundles[$name])) {
  344. throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s"', $name));
  345. }
  346. $this->bundles[$name] = $bundle;
  347. if ($parentName = $bundle->getParent()) {
  348. if (isset($directChildren[$parentName])) {
  349. throw new \LogicException(sprintf('Bundle "%s" is directly extended by two bundles "%s" and "%s".', $parentName, $name, $directChildren[$parentName]));
  350. }
  351. if ($parentName == $name) {
  352. throw new \LogicException(sprintf('Bundle "%s" can not extend itself.', $name));
  353. }
  354. $directChildren[$parentName] = $name;
  355. } else {
  356. $topMostBundles[$name] = $bundle;
  357. }
  358. }
  359. // look for orphans
  360. if (!empty($directChildren) && count($diff = array_diff_key($directChildren, $this->bundles))) {
  361. $diff = array_keys($diff);
  362. throw new \LogicException(sprintf('Bundle "%s" extends bundle "%s", which is not registered.', $directChildren[$diff[0]], $diff[0]));
  363. }
  364. // inheritance
  365. $this->bundleMap = array();
  366. foreach ($topMostBundles as $name => $bundle) {
  367. $bundleMap = array($bundle);
  368. $hierarchy = array($name);
  369. while (isset($directChildren[$name])) {
  370. $name = $directChildren[$name];
  371. array_unshift($bundleMap, $this->bundles[$name]);
  372. $hierarchy[] = $name;
  373. }
  374. foreach ($hierarchy as $bundle) {
  375. $this->bundleMap[$bundle] = $bundleMap;
  376. array_pop($bundleMap);
  377. }
  378. }
  379. }
  380. /**
  381. * Gets the container class.
  382. *
  383. * @return string The container class
  384. */
  385. protected function getContainerClass()
  386. {
  387. return $this->name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer';
  388. }
  389. /**
  390. * Gets the container's base class.
  391. *
  392. * All names except Container must be fully qualified.
  393. *
  394. * @return string
  395. */
  396. protected function getContainerBaseClass()
  397. {
  398. return 'Container';
  399. }
  400. /**
  401. * Initializes the service container.
  402. *
  403. * The cached version of the service container is used when fresh, otherwise the
  404. * container is built.
  405. */
  406. protected function initializeContainer()
  407. {
  408. $class = $this->getContainerClass();
  409. $cache = new ConfigCache($this->getCacheDir().'/'.$class.'.php', $this->debug);
  410. $fresh = true;
  411. if (!$cache->isFresh()) {
  412. $container = $this->buildContainer();
  413. $container->compile();
  414. $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
  415. $fresh = false;
  416. }
  417. require_once $cache->getPath();
  418. $this->container = new $class();
  419. $this->container->set('kernel', $this);
  420. if (!$fresh && $this->container->has('cache_warmer')) {
  421. $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir'));
  422. }
  423. }
  424. /**
  425. * Returns the kernel parameters.
  426. *
  427. * @return array An array of kernel parameters
  428. */
  429. protected function getKernelParameters()
  430. {
  431. $bundles = array();
  432. foreach ($this->bundles as $name => $bundle) {
  433. $bundles[$name] = get_class($bundle);
  434. }
  435. return array_merge(
  436. array(
  437. 'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
  438. 'kernel.environment' => $this->environment,
  439. 'kernel.debug' => $this->debug,
  440. 'kernel.name' => $this->name,
  441. 'kernel.cache_dir' => realpath($this->getCacheDir()) ?: $this->getCacheDir(),
  442. 'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(),
  443. 'kernel.bundles' => $bundles,
  444. 'kernel.charset' => $this->getCharset(),
  445. 'kernel.container_class' => $this->getContainerClass(),
  446. ),
  447. $this->getEnvParameters()
  448. );
  449. }
  450. /**
  451. * Gets the environment parameters.
  452. *
  453. * Only the parameters starting with "SYMFONY__" are considered.
  454. *
  455. * @return array An array of parameters
  456. */
  457. protected function getEnvParameters()
  458. {
  459. $parameters = array();
  460. foreach ($_SERVER as $key => $value) {
  461. if (0 === strpos($key, 'SYMFONY__')) {
  462. $parameters[strtolower(str_replace('__', '.', substr($key, 9)))] = $value;
  463. }
  464. }
  465. return $parameters;
  466. }
  467. /**
  468. * Builds the service container.
  469. *
  470. * @return ContainerBuilder The compiled service container
  471. *
  472. * @throws \RuntimeException
  473. */
  474. protected function buildContainer()
  475. {
  476. foreach (array('cache' => $this->getCacheDir(), 'logs' => $this->getLogDir()) as $name => $dir) {
  477. if (!is_dir($dir)) {
  478. if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
  479. throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, $dir));
  480. }
  481. } elseif (!is_writable($dir)) {
  482. throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir));
  483. }
  484. }
  485. $container = $this->getContainerBuilder();
  486. $container->addObjectResource($this);
  487. $this->prepareContainer($container);
  488. if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) {
  489. $container->merge($cont);
  490. }
  491. $container->addCompilerPass(new AddClassesToCachePass($this));
  492. $container->addResource(new EnvParametersResource('SYMFONY__'));
  493. return $container;
  494. }
  495. /**
  496. * Prepares the ContainerBuilder before it is compiled.
  497. *
  498. * @param ContainerBuilder $container A ContainerBuilder instance
  499. */
  500. protected function prepareContainer(ContainerBuilder $container)
  501. {
  502. $extensions = array();
  503. foreach ($this->bundles as $bundle) {
  504. if ($extension = $bundle->getContainerExtension()) {
  505. $container->registerExtension($extension);
  506. $extensions[] = $extension->getAlias();
  507. }
  508. if ($this->debug) {
  509. $container->addObjectResource($bundle);
  510. }
  511. }
  512. foreach ($this->bundles as $bundle) {
  513. $bundle->build($container);
  514. }
  515. // ensure these extensions are implicitly loaded
  516. $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions));
  517. }
  518. /**
  519. * Gets a new ContainerBuilder instance used to build the service container.
  520. *
  521. * @return ContainerBuilder
  522. */
  523. protected function getContainerBuilder()
  524. {
  525. $container = new ContainerBuilder(new ParameterBag($this->getKernelParameters()));
  526. if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator')) {
  527. $container->setProxyInstantiator(new RuntimeInstantiator());
  528. }
  529. return $container;
  530. }
  531. /**
  532. * Dumps the service container to PHP code in the cache.
  533. *
  534. * @param ConfigCache $cache The config cache
  535. * @param ContainerBuilder $container The service container
  536. * @param string $class The name of the class to generate
  537. * @param string $baseClass The name of the container's base class
  538. */
  539. protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
  540. {
  541. // cache the container
  542. $dumper = new PhpDumper($container);
  543. if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper')) {
  544. $dumper->setProxyDumper(new ProxyDumper(md5($cache->getPath())));
  545. }
  546. $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath(), 'debug' => $this->debug));
  547. $cache->write($content, $container->getResources());
  548. }
  549. /**
  550. * Returns a loader for the container.
  551. *
  552. * @param ContainerInterface $container The service container
  553. *
  554. * @return DelegatingLoader The loader
  555. */
  556. protected function getContainerLoader(ContainerInterface $container)
  557. {
  558. $locator = new FileLocator($this);
  559. $resolver = new LoaderResolver(array(
  560. new XmlFileLoader($container, $locator),
  561. new YamlFileLoader($container, $locator),
  562. new IniFileLoader($container, $locator),
  563. new PhpFileLoader($container, $locator),
  564. new DirectoryLoader($container, $locator),
  565. new ClosureLoader($container),
  566. ));
  567. return new DelegatingLoader($resolver);
  568. }
  569. /**
  570. * Removes comments from a PHP source string.
  571. *
  572. * We don't use the PHP php_strip_whitespace() function
  573. * as we want the content to be readable and well-formatted.
  574. *
  575. * @param string $source A PHP string
  576. *
  577. * @return string The PHP string with the comments removed
  578. */
  579. public static function stripComments($source)
  580. {
  581. if (!function_exists('token_get_all')) {
  582. return $source;
  583. }
  584. $rawChunk = '';
  585. $output = '';
  586. $tokens = token_get_all($source);
  587. $ignoreSpace = false;
  588. for ($i = 0; isset($tokens[$i]); ++$i) {
  589. $token = $tokens[$i];
  590. if (!isset($token[1]) || 'b"' === $token) {
  591. $rawChunk .= $token;
  592. } elseif (T_START_HEREDOC === $token[0]) {
  593. $output .= $rawChunk.$token[1];
  594. do {
  595. $token = $tokens[++$i];
  596. $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token;
  597. } while ($token[0] !== T_END_HEREDOC);
  598. $rawChunk = '';
  599. } elseif (T_WHITESPACE === $token[0]) {
  600. if ($ignoreSpace) {
  601. $ignoreSpace = false;
  602. continue;
  603. }
  604. // replace multiple new lines with a single newline
  605. $rawChunk .= preg_replace(array('/\n{2,}/S'), "\n", $token[1]);
  606. } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
  607. $ignoreSpace = true;
  608. } else {
  609. $rawChunk .= $token[1];
  610. // The PHP-open tag already has a new-line
  611. if (T_OPEN_TAG === $token[0]) {
  612. $ignoreSpace = true;
  613. }
  614. }
  615. }
  616. $output .= $rawChunk;
  617. if (PHP_VERSION_ID >= 70000) {
  618. // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
  619. unset($tokens, $rawChunk);
  620. gc_mem_caches();
  621. }
  622. return $output;
  623. }
  624. public function serialize()
  625. {
  626. return serialize(array($this->environment, $this->debug));
  627. }
  628. public function unserialize($data)
  629. {
  630. list($environment, $debug) = unserialize($data);
  631. $this->__construct($environment, $debug);
  632. }
  633. }