Runtime.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Runtime class definitions. \Reflection is used to parse constructor signatures. Should be used only in dev mode.
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Framework\ObjectManager\Definition;
  9. class Runtime implements \Magento\Framework\ObjectManager\DefinitionInterface
  10. {
  11. /**
  12. * @var array
  13. */
  14. protected $_definitions = [];
  15. /**
  16. * @var \Magento\Framework\Code\Reader\ClassReaderInterface
  17. */
  18. private $_reader;
  19. /**
  20. * @param \Magento\Framework\Code\Reader\ClassReaderInterface $reader
  21. */
  22. public function __construct(\Magento\Framework\Code\Reader\ClassReaderInterface $reader = null)
  23. {
  24. $this->_reader = $reader ?: new \Magento\Framework\Code\Reader\ClassReader();
  25. }
  26. /**
  27. * Get list of method parameters
  28. *
  29. * Retrieve an ordered list of constructor parameters.
  30. * Each value is an array with following entries:
  31. *
  32. * array(
  33. * 0, // string: Parameter name
  34. * 1, // string|null: Parameter type
  35. * 2, // bool: whether this param is required
  36. * 3, // mixed: default value
  37. * );
  38. *
  39. * @param string $className
  40. * @return array|null
  41. */
  42. public function getParameters($className)
  43. {
  44. if (!array_key_exists($className, $this->_definitions)) {
  45. $this->_definitions[$className] = $this->_reader->getConstructor($className);
  46. }
  47. return $this->_definitions[$className];
  48. }
  49. /**
  50. * Retrieve list of all classes covered with definitions
  51. *
  52. * @return array
  53. */
  54. public function getClasses()
  55. {
  56. return [];
  57. }
  58. }