Definition.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931
  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\DependencyInjection;
  11. use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  12. use Symfony\Component\DependencyInjection\Exception\OutOfBoundsException;
  13. /**
  14. * Definition represents a service definition.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. */
  18. class Definition
  19. {
  20. private $class;
  21. private $file;
  22. private $factory;
  23. private $factoryClass;
  24. private $factoryMethod;
  25. private $factoryService;
  26. private $shared = true;
  27. private $deprecated = false;
  28. private $deprecationTemplate;
  29. private $scope = ContainerInterface::SCOPE_CONTAINER;
  30. private $properties = array();
  31. private $calls = array();
  32. private $configurator;
  33. private $tags = array();
  34. private $public = true;
  35. private $synthetic = false;
  36. private $abstract = false;
  37. private $synchronized = false;
  38. private $lazy = false;
  39. private $decoratedService;
  40. private $autowired = false;
  41. private $autowiringTypes = array();
  42. private static $defaultDeprecationTemplate = 'The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.';
  43. protected $arguments;
  44. /**
  45. * @param string|null $class The service class
  46. * @param array $arguments An array of arguments to pass to the service constructor
  47. */
  48. public function __construct($class = null, array $arguments = array())
  49. {
  50. $this->class = $class;
  51. $this->arguments = $arguments;
  52. }
  53. /**
  54. * Sets a factory.
  55. *
  56. * @param string|array $factory A PHP function or an array containing a class/Reference and a method to call
  57. *
  58. * @return $this
  59. */
  60. public function setFactory($factory)
  61. {
  62. if (\is_string($factory) && false !== strpos($factory, '::')) {
  63. $factory = explode('::', $factory, 2);
  64. }
  65. $this->factory = $factory;
  66. return $this;
  67. }
  68. /**
  69. * Gets the factory.
  70. *
  71. * @return string|array|null The PHP function or an array containing a class/Reference and a method to call
  72. */
  73. public function getFactory()
  74. {
  75. return $this->factory;
  76. }
  77. /**
  78. * Sets the name of the class that acts as a factory using the factory method,
  79. * which will be invoked statically.
  80. *
  81. * @param string $factoryClass The factory class name
  82. *
  83. * @return $this
  84. *
  85. * @deprecated since version 2.6, to be removed in 3.0.
  86. */
  87. public function setFactoryClass($factoryClass)
  88. {
  89. @trigger_error(sprintf('%s(%s) is deprecated since Symfony 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryClass), E_USER_DEPRECATED);
  90. $this->factoryClass = $factoryClass;
  91. return $this;
  92. }
  93. /**
  94. * Gets the factory class.
  95. *
  96. * @return string|null The factory class name
  97. *
  98. * @deprecated since version 2.6, to be removed in 3.0.
  99. */
  100. public function getFactoryClass($triggerDeprecationError = true)
  101. {
  102. if ($triggerDeprecationError) {
  103. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
  104. }
  105. return $this->factoryClass;
  106. }
  107. /**
  108. * Sets the factory method able to create an instance of this class.
  109. *
  110. * @param string $factoryMethod The factory method name
  111. *
  112. * @return $this
  113. *
  114. * @deprecated since version 2.6, to be removed in 3.0.
  115. */
  116. public function setFactoryMethod($factoryMethod)
  117. {
  118. @trigger_error(sprintf('%s(%s) is deprecated since Symfony 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryMethod), E_USER_DEPRECATED);
  119. $this->factoryMethod = $factoryMethod;
  120. return $this;
  121. }
  122. /**
  123. * Sets the service that this service is decorating.
  124. *
  125. * @param string|null $id The decorated service id, use null to remove decoration
  126. * @param string|null $renamedId The new decorated service id
  127. * @param int $priority The priority of decoration
  128. *
  129. * @return $this
  130. *
  131. * @throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals
  132. */
  133. public function setDecoratedService($id, $renamedId = null, $priority = 0)
  134. {
  135. if ($renamedId && $id === $renamedId) {
  136. throw new \InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id));
  137. }
  138. if (null === $id) {
  139. $this->decoratedService = null;
  140. } else {
  141. $this->decoratedService = array($id, $renamedId, (int) $priority);
  142. }
  143. return $this;
  144. }
  145. /**
  146. * Gets the service that this service is decorating.
  147. *
  148. * @return array|null An array composed of the decorated service id, the new id for it and the priority of decoration, null if no service is decorated
  149. */
  150. public function getDecoratedService()
  151. {
  152. return $this->decoratedService;
  153. }
  154. /**
  155. * Gets the factory method.
  156. *
  157. * @return string|null The factory method name
  158. *
  159. * @deprecated since version 2.6, to be removed in 3.0.
  160. */
  161. public function getFactoryMethod($triggerDeprecationError = true)
  162. {
  163. if ($triggerDeprecationError) {
  164. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
  165. }
  166. return $this->factoryMethod;
  167. }
  168. /**
  169. * Sets the name of the service that acts as a factory using the factory method.
  170. *
  171. * @param string $factoryService The factory service id
  172. *
  173. * @return $this
  174. *
  175. * @deprecated since version 2.6, to be removed in 3.0.
  176. */
  177. public function setFactoryService($factoryService, $triggerDeprecationError = true)
  178. {
  179. if ($triggerDeprecationError) {
  180. @trigger_error(sprintf('%s(%s) is deprecated since Symfony 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryService), E_USER_DEPRECATED);
  181. }
  182. $this->factoryService = $factoryService;
  183. return $this;
  184. }
  185. /**
  186. * Gets the factory service id.
  187. *
  188. * @return string|null The factory service id
  189. *
  190. * @deprecated since version 2.6, to be removed in 3.0.
  191. */
  192. public function getFactoryService($triggerDeprecationError = true)
  193. {
  194. if ($triggerDeprecationError) {
  195. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.6 and will be removed in 3.0.', E_USER_DEPRECATED);
  196. }
  197. return $this->factoryService;
  198. }
  199. /**
  200. * Sets the service class.
  201. *
  202. * @param string $class The service class
  203. *
  204. * @return $this
  205. */
  206. public function setClass($class)
  207. {
  208. $this->class = $class;
  209. return $this;
  210. }
  211. /**
  212. * Gets the service class.
  213. *
  214. * @return string|null The service class
  215. */
  216. public function getClass()
  217. {
  218. return $this->class;
  219. }
  220. /**
  221. * Sets the arguments to pass to the service constructor/factory method.
  222. *
  223. * @return $this
  224. */
  225. public function setArguments(array $arguments)
  226. {
  227. $this->arguments = $arguments;
  228. return $this;
  229. }
  230. /**
  231. * Sets the properties to define when creating the service.
  232. *
  233. * @return $this
  234. */
  235. public function setProperties(array $properties)
  236. {
  237. $this->properties = $properties;
  238. return $this;
  239. }
  240. /**
  241. * Gets the properties to define when creating the service.
  242. *
  243. * @return array
  244. */
  245. public function getProperties()
  246. {
  247. return $this->properties;
  248. }
  249. /**
  250. * Sets a specific property.
  251. *
  252. * @param string $name
  253. * @param mixed $value
  254. *
  255. * @return $this
  256. */
  257. public function setProperty($name, $value)
  258. {
  259. $this->properties[$name] = $value;
  260. return $this;
  261. }
  262. /**
  263. * Adds an argument to pass to the service constructor/factory method.
  264. *
  265. * @param mixed $argument An argument
  266. *
  267. * @return $this
  268. */
  269. public function addArgument($argument)
  270. {
  271. $this->arguments[] = $argument;
  272. return $this;
  273. }
  274. /**
  275. * Replaces a specific argument.
  276. *
  277. * @param int $index
  278. * @param mixed $argument
  279. *
  280. * @return $this
  281. *
  282. * @throws OutOfBoundsException When the replaced argument does not exist
  283. */
  284. public function replaceArgument($index, $argument)
  285. {
  286. if (0 === \count($this->arguments)) {
  287. throw new OutOfBoundsException('Cannot replace arguments if none have been configured yet.');
  288. }
  289. if ($index < 0 || $index > \count($this->arguments) - 1) {
  290. throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, \count($this->arguments) - 1));
  291. }
  292. $this->arguments[$index] = $argument;
  293. return $this;
  294. }
  295. /**
  296. * Gets the arguments to pass to the service constructor/factory method.
  297. *
  298. * @return array The array of arguments
  299. */
  300. public function getArguments()
  301. {
  302. return $this->arguments;
  303. }
  304. /**
  305. * Gets an argument to pass to the service constructor/factory method.
  306. *
  307. * @param int $index
  308. *
  309. * @return mixed The argument value
  310. *
  311. * @throws OutOfBoundsException When the argument does not exist
  312. */
  313. public function getArgument($index)
  314. {
  315. if ($index < 0 || $index > \count($this->arguments) - 1) {
  316. throw new OutOfBoundsException(sprintf('The index "%d" is not in the range [0, %d].', $index, \count($this->arguments) - 1));
  317. }
  318. return $this->arguments[$index];
  319. }
  320. /**
  321. * Sets the methods to call after service initialization.
  322. *
  323. * @return $this
  324. */
  325. public function setMethodCalls(array $calls = array())
  326. {
  327. $this->calls = array();
  328. foreach ($calls as $call) {
  329. $this->addMethodCall($call[0], $call[1]);
  330. }
  331. return $this;
  332. }
  333. /**
  334. * Adds a method to call after service initialization.
  335. *
  336. * @param string $method The method name to call
  337. * @param array $arguments An array of arguments to pass to the method call
  338. *
  339. * @return $this
  340. *
  341. * @throws InvalidArgumentException on empty $method param
  342. */
  343. public function addMethodCall($method, array $arguments = array())
  344. {
  345. if (empty($method)) {
  346. throw new InvalidArgumentException('Method name cannot be empty.');
  347. }
  348. $this->calls[] = array($method, $arguments);
  349. return $this;
  350. }
  351. /**
  352. * Removes a method to call after service initialization.
  353. *
  354. * @param string $method The method name to remove
  355. *
  356. * @return $this
  357. */
  358. public function removeMethodCall($method)
  359. {
  360. foreach ($this->calls as $i => $call) {
  361. if ($call[0] === $method) {
  362. unset($this->calls[$i]);
  363. break;
  364. }
  365. }
  366. return $this;
  367. }
  368. /**
  369. * Check if the current definition has a given method to call after service initialization.
  370. *
  371. * @param string $method The method name to search for
  372. *
  373. * @return bool
  374. */
  375. public function hasMethodCall($method)
  376. {
  377. foreach ($this->calls as $call) {
  378. if ($call[0] === $method) {
  379. return true;
  380. }
  381. }
  382. return false;
  383. }
  384. /**
  385. * Gets the methods to call after service initialization.
  386. *
  387. * @return array An array of method calls
  388. */
  389. public function getMethodCalls()
  390. {
  391. return $this->calls;
  392. }
  393. /**
  394. * Sets tags for this definition.
  395. *
  396. * @return $this
  397. */
  398. public function setTags(array $tags)
  399. {
  400. $this->tags = $tags;
  401. return $this;
  402. }
  403. /**
  404. * Returns all tags.
  405. *
  406. * @return array An array of tags
  407. */
  408. public function getTags()
  409. {
  410. return $this->tags;
  411. }
  412. /**
  413. * Gets a tag by name.
  414. *
  415. * @param string $name The tag name
  416. *
  417. * @return array An array of attributes
  418. */
  419. public function getTag($name)
  420. {
  421. return isset($this->tags[$name]) ? $this->tags[$name] : array();
  422. }
  423. /**
  424. * Adds a tag for this definition.
  425. *
  426. * @param string $name The tag name
  427. * @param array $attributes An array of attributes
  428. *
  429. * @return $this
  430. */
  431. public function addTag($name, array $attributes = array())
  432. {
  433. $this->tags[$name][] = $attributes;
  434. return $this;
  435. }
  436. /**
  437. * Whether this definition has a tag with the given name.
  438. *
  439. * @param string $name
  440. *
  441. * @return bool
  442. */
  443. public function hasTag($name)
  444. {
  445. return isset($this->tags[$name]);
  446. }
  447. /**
  448. * Clears all tags for a given name.
  449. *
  450. * @param string $name The tag name
  451. *
  452. * @return $this
  453. */
  454. public function clearTag($name)
  455. {
  456. unset($this->tags[$name]);
  457. return $this;
  458. }
  459. /**
  460. * Clears the tags for this definition.
  461. *
  462. * @return $this
  463. */
  464. public function clearTags()
  465. {
  466. $this->tags = array();
  467. return $this;
  468. }
  469. /**
  470. * Sets a file to require before creating the service.
  471. *
  472. * @param string $file A full pathname to include
  473. *
  474. * @return $this
  475. */
  476. public function setFile($file)
  477. {
  478. $this->file = $file;
  479. return $this;
  480. }
  481. /**
  482. * Gets the file to require before creating the service.
  483. *
  484. * @return string|null The full pathname to include
  485. */
  486. public function getFile()
  487. {
  488. return $this->file;
  489. }
  490. /**
  491. * Sets if the service must be shared or not.
  492. *
  493. * @param bool $shared Whether the service must be shared or not
  494. *
  495. * @return $this
  496. */
  497. public function setShared($shared)
  498. {
  499. $this->shared = (bool) $shared;
  500. return $this;
  501. }
  502. /**
  503. * Whether this service is shared.
  504. *
  505. * @return bool
  506. */
  507. public function isShared()
  508. {
  509. return $this->shared;
  510. }
  511. /**
  512. * Sets the scope of the service.
  513. *
  514. * @param string $scope Whether the service must be shared or not
  515. *
  516. * @return $this
  517. *
  518. * @deprecated since version 2.8, to be removed in 3.0.
  519. */
  520. public function setScope($scope, $triggerDeprecationError = true)
  521. {
  522. if ($triggerDeprecationError) {
  523. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  524. }
  525. if (ContainerInterface::SCOPE_PROTOTYPE === $scope) {
  526. $this->setShared(false);
  527. }
  528. $this->scope = $scope;
  529. return $this;
  530. }
  531. /**
  532. * Returns the scope of the service.
  533. *
  534. * @return string
  535. *
  536. * @deprecated since version 2.8, to be removed in 3.0.
  537. */
  538. public function getScope($triggerDeprecationError = true)
  539. {
  540. if ($triggerDeprecationError) {
  541. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  542. }
  543. return $this->scope;
  544. }
  545. /**
  546. * Sets the visibility of this service.
  547. *
  548. * @param bool $boolean
  549. *
  550. * @return $this
  551. */
  552. public function setPublic($boolean)
  553. {
  554. $this->public = (bool) $boolean;
  555. return $this;
  556. }
  557. /**
  558. * Whether this service is public facing.
  559. *
  560. * @return bool
  561. */
  562. public function isPublic()
  563. {
  564. return $this->public;
  565. }
  566. /**
  567. * Sets the synchronized flag of this service.
  568. *
  569. * @param bool $boolean
  570. *
  571. * @return $this
  572. *
  573. * @deprecated since version 2.7, will be removed in 3.0.
  574. */
  575. public function setSynchronized($boolean, $triggerDeprecationError = true)
  576. {
  577. if ($triggerDeprecationError) {
  578. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
  579. }
  580. $this->synchronized = (bool) $boolean;
  581. return $this;
  582. }
  583. /**
  584. * Whether this service is synchronized.
  585. *
  586. * @return bool
  587. *
  588. * @deprecated since version 2.7, will be removed in 3.0.
  589. */
  590. public function isSynchronized($triggerDeprecationError = true)
  591. {
  592. if ($triggerDeprecationError) {
  593. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
  594. }
  595. return $this->synchronized;
  596. }
  597. /**
  598. * Sets the lazy flag of this service.
  599. *
  600. * @param bool $lazy
  601. *
  602. * @return $this
  603. */
  604. public function setLazy($lazy)
  605. {
  606. $this->lazy = (bool) $lazy;
  607. return $this;
  608. }
  609. /**
  610. * Whether this service is lazy.
  611. *
  612. * @return bool
  613. */
  614. public function isLazy()
  615. {
  616. return $this->lazy;
  617. }
  618. /**
  619. * Sets whether this definition is synthetic, that is not constructed by the
  620. * container, but dynamically injected.
  621. *
  622. * @param bool $boolean
  623. *
  624. * @return $this
  625. */
  626. public function setSynthetic($boolean)
  627. {
  628. $this->synthetic = (bool) $boolean;
  629. return $this;
  630. }
  631. /**
  632. * Whether this definition is synthetic, that is not constructed by the
  633. * container, but dynamically injected.
  634. *
  635. * @return bool
  636. */
  637. public function isSynthetic()
  638. {
  639. return $this->synthetic;
  640. }
  641. /**
  642. * Whether this definition is abstract, that means it merely serves as a
  643. * template for other definitions.
  644. *
  645. * @param bool $boolean
  646. *
  647. * @return $this
  648. */
  649. public function setAbstract($boolean)
  650. {
  651. $this->abstract = (bool) $boolean;
  652. return $this;
  653. }
  654. /**
  655. * Whether this definition is abstract, that means it merely serves as a
  656. * template for other definitions.
  657. *
  658. * @return bool
  659. */
  660. public function isAbstract()
  661. {
  662. return $this->abstract;
  663. }
  664. /**
  665. * Whether this definition is deprecated, that means it should not be called
  666. * anymore.
  667. *
  668. * @param bool $status
  669. * @param string $template Template message to use if the definition is deprecated
  670. *
  671. * @return $this
  672. *
  673. * @throws InvalidArgumentException when the message template is invalid
  674. */
  675. public function setDeprecated($status = true, $template = null)
  676. {
  677. if (null !== $template) {
  678. if (preg_match('#[\r\n]|\*/#', $template)) {
  679. throw new InvalidArgumentException('Invalid characters found in deprecation template.');
  680. }
  681. if (false === strpos($template, '%service_id%')) {
  682. throw new InvalidArgumentException('The deprecation template must contain the "%service_id%" placeholder.');
  683. }
  684. $this->deprecationTemplate = $template;
  685. }
  686. $this->deprecated = (bool) $status;
  687. return $this;
  688. }
  689. /**
  690. * Whether this definition is deprecated, that means it should not be called
  691. * anymore.
  692. *
  693. * @return bool
  694. */
  695. public function isDeprecated()
  696. {
  697. return $this->deprecated;
  698. }
  699. /**
  700. * Message to use if this definition is deprecated.
  701. *
  702. * @param string $id Service id relying on this definition
  703. *
  704. * @return string
  705. */
  706. public function getDeprecationMessage($id)
  707. {
  708. return str_replace('%service_id%', $id, $this->deprecationTemplate ?: self::$defaultDeprecationTemplate);
  709. }
  710. /**
  711. * Sets a configurator to call after the service is fully initialized.
  712. *
  713. * @param callable $callable A PHP callable
  714. *
  715. * @return $this
  716. */
  717. public function setConfigurator($callable)
  718. {
  719. $this->configurator = $callable;
  720. return $this;
  721. }
  722. /**
  723. * Gets the configurator to call after the service is fully initialized.
  724. *
  725. * @return callable|null The PHP callable to call
  726. */
  727. public function getConfigurator()
  728. {
  729. return $this->configurator;
  730. }
  731. /**
  732. * Sets types that will default to this definition.
  733. *
  734. * @param string[] $types
  735. *
  736. * @return $this
  737. */
  738. public function setAutowiringTypes(array $types)
  739. {
  740. $this->autowiringTypes = array();
  741. foreach ($types as $type) {
  742. $this->autowiringTypes[$type] = true;
  743. }
  744. return $this;
  745. }
  746. /**
  747. * Is the definition autowired?
  748. *
  749. * @return bool
  750. */
  751. public function isAutowired()
  752. {
  753. return $this->autowired;
  754. }
  755. /**
  756. * Enables/disables autowiring.
  757. *
  758. * @param bool $autowired
  759. *
  760. * @return $this
  761. */
  762. public function setAutowired($autowired)
  763. {
  764. $this->autowired = $autowired;
  765. return $this;
  766. }
  767. /**
  768. * Gets autowiring types that will default to this definition.
  769. *
  770. * @return string[]
  771. */
  772. public function getAutowiringTypes()
  773. {
  774. return array_keys($this->autowiringTypes);
  775. }
  776. /**
  777. * Adds a type that will default to this definition.
  778. *
  779. * @param string $type
  780. *
  781. * @return $this
  782. */
  783. public function addAutowiringType($type)
  784. {
  785. $this->autowiringTypes[$type] = true;
  786. return $this;
  787. }
  788. /**
  789. * Removes a type.
  790. *
  791. * @param string $type
  792. *
  793. * @return $this
  794. */
  795. public function removeAutowiringType($type)
  796. {
  797. unset($this->autowiringTypes[$type]);
  798. return $this;
  799. }
  800. /**
  801. * Will this definition default for the given type?
  802. *
  803. * @param string $type
  804. *
  805. * @return bool
  806. */
  807. public function hasAutowiringType($type)
  808. {
  809. return isset($this->autowiringTypes[$type]);
  810. }
  811. }