diff --git a/lib/internal/Magento/Framework/Data/Collection.php b/lib/internal/Magento/Framework/Data/Collection.php index 51a066f2660dd..ae378bbf4cc4b 100644 --- a/lib/internal/Magento/Framework/Data/Collection.php +++ b/lib/internal/Magento/Framework/Data/Collection.php @@ -9,8 +9,6 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\Data\Collection\EntityFactoryInterface; use Magento\Framework\DataObject; -use Magento\Framework\Exception\AlreadyExistsException; -use Magento\Framework\Option\ArrayInterface; /** * Data collection @@ -19,8 +17,10 @@ * * @api * @since 100.0.2 + * + * @SuppressWarnings(PHPMD.ExcessivePublicCount) */ -class Collection implements \IteratorAggregate, \Countable, ArrayInterface, CollectionDataSourceInterface +class Collection implements \IteratorAggregate, \Countable, OptionSourceInterface, CollectionDataSourceInterface { const SORT_ORDER_ASC = 'ASC'; @@ -767,6 +767,7 @@ protected function _toOptionArray($valueField = 'id', $labelField = 'name', $add $additional['label'] = $labelField; foreach ($this as $item) { + $data = []; foreach ($additional as $code => $field) { $data[$code] = $item->getData($field); } @@ -915,4 +916,16 @@ public function __wakeup() $objectManager = ObjectManager::getInstance(); $this->_entityFactory = $objectManager->get(EntityFactoryInterface::class); } + + /** + * Export only scalar and arrays properties for var_dump + * + * @return array + */ + public function __debugInfo() + { + return array_filter(get_object_vars($this), function ($v) { + return is_scalar($v) || is_array($v); + }); + } } diff --git a/lib/internal/Magento/Framework/DataObject.php b/lib/internal/Magento/Framework/DataObject.php index 11452c49fa162..87e8830aeab0f 100644 --- a/lib/internal/Magento/Framework/DataObject.php +++ b/lib/internal/Magento/Framework/DataObject.php @@ -183,8 +183,8 @@ public function getDataByKey($key) /** * Get value from _data array without parse key * - * @param string $key - * @return mixed + * @param string $key + * @return mixed */ protected function _getData($key) { @@ -263,7 +263,7 @@ public function toArray(array $keys = []) /** * The "__" style wrapper for toArray method * - * @param array $keys + * @param array $keys * @return array */ public function convertToArray(array $keys = []) @@ -373,9 +373,9 @@ public function toString($format = '') /** * Set/Get attribute wrapper * - * @param string $method - * @param array $args - * @return mixed + * @param string $method + * @param array $args + * @return mixed * @throws \Magento\Framework\Exception\LocalizedException */ public function __call($method, $args) @@ -438,11 +438,11 @@ protected function _underscore($name) * * Example: key1="value1" key2="value2" ... * - * @param array $keys array of accepted keys - * @param string $valueSeparator separator between key and value - * @param string $fieldSeparator separator between key/value pairs - * @param string $quote quoting sign - * @return string + * @param array $keys array of accepted keys + * @param string $valueSeparator separator between key and value + * @param string $fieldSeparator separator between key/value pairs + * @param string $quote quoting sign + * @return string */ public function serialize($keys = [], $valueSeparator = '=', $fieldSeparator = ' ', $quote = '"') { @@ -464,7 +464,7 @@ public function serialize($keys = [], $valueSeparator = '=', $fieldSeparator = ' * Present object data as string in debug mode * * @param mixed $data - * @param array &$objects + * @param array $objects * @return array */ public function debug($data = null, &$objects = []) @@ -541,4 +541,19 @@ public function offsetGet($offset) } return null; } + + /** + * Export only scalar and arrays properties for var_dump + * + * @return array + */ + public function __debugInfo() + { + return array_filter( + get_object_vars($this), + function ($v) { + return is_scalar($v) || is_array($v); + } + ); + } } diff --git a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php index 26697e70a8f87..67c53e40b595e 100644 --- a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php +++ b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php @@ -292,4 +292,15 @@ public function merge(array $config) { $this->_data = $this->pluginListGenerator->merge($config, $this->_data); } + + /** + * Disable show PluginList internals with var_dump + * + * @see https://www.php.net/manual/en/language.oop5.magic.php#object.debuginfo + * @return array + */ + public function __debugInfo() + { + return []; + } } diff --git a/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php b/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php index 08a3f9939d851..5d19a87053d69 100644 --- a/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php +++ b/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php @@ -12,7 +12,12 @@ */ namespace Magento\Framework\ObjectManager; -class ObjectManager implements \Magento\Framework\ObjectManagerInterface +use Magento\Framework\ObjectManagerInterface; + +/** + * Base implementation Object Manager + */ +class ObjectManager implements ObjectManagerInterface { /** * @var \Magento\Framework\ObjectManager\FactoryInterface @@ -34,14 +39,14 @@ class ObjectManager implements \Magento\Framework\ObjectManagerInterface /** * @param FactoryInterface $factory * @param ConfigInterface $config - * @param array &$sharedInstances + * @param array $sharedInstances */ public function __construct(FactoryInterface $factory, ConfigInterface $config, &$sharedInstances = []) { $this->_config = $config; $this->_factory = $factory; $this->_sharedInstances = &$sharedInstances; - $this->_sharedInstances[\Magento\Framework\ObjectManagerInterface::class] = $this; + $this->_sharedInstances[ObjectManagerInterface::class] = $this; } /** @@ -74,6 +79,7 @@ public function get($type) /** * Configure di instance + * * Note: All arguments should be pre-processed (sort order, translations, etc) before passing to method configure. * * @param array $configuration @@ -83,4 +89,15 @@ public function configure(array $configuration) { $this->_config->extend($configuration); } + + /** + * Disable show ObjectManager internals with var_dump + * + * @see https://www.php.net/manual/en/language.oop5.magic.php#object.debuginfo + * @return array + */ + public function __debugInfo() + { + return []; + } }