{"action":"created","issue":{"url":"https://api.github.com/repos/laminas/laminas-stdlib/issues/3","repository_url":"https://api.github.com/repos/laminas/laminas-stdlib","labels_url":"https://api.github.com/repos/laminas/laminas-stdlib/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/laminas/laminas-stdlib/issues/3/comments","events_url":"https://api.github.com/repos/laminas/laminas-stdlib/issues/3/events","html_url":"https://github.com/laminas/laminas-stdlib/issues/3","id":544281240,"node_id":"MDU6SXNzdWU1NDQyODEyNDA=","number":3,"title":"[Suggestion] Code split for Array Utility","user":{"login":"weierophinney","id":25943,"node_id":"MDQ6VXNlcjI1OTQz","avatar_url":"https://avatars1.githubusercontent.com/u/25943?v=4","gravatar_id":"","url":"https://api.github.com/users/weierophinney","html_url":"https://github.com/weierophinney","followers_url":"https://api.github.com/users/weierophinney/followers","following_url":"https://api.github.com/users/weierophinney/following{/other_user}","gists_url":"https://api.github.com/users/weierophinney/gists{/gist_id}","starred_url":"https://api.github.com/users/weierophinney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weierophinney/subscriptions","organizations_url":"https://api.github.com/users/weierophinney/orgs","repos_url":"https://api.github.com/users/weierophinney/repos","events_url":"https://api.github.com/users/weierophinney/events{/privacy}","received_events_url":"https://api.github.com/users/weierophinney/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2019-12-31T22:26:55Z","updated_at":"2019-12-31T22:27:08Z","closed_at":null,"author_association":"MEMBER","body":"Looking at some dependency graph for zend components, one way of requiring zend-stdlib is to use the array functions.\r\n\r\nSome of these libraries are:\r\n1. [Zend\\Config](https://github.com/zendframework/zend-config/search?utf8=%E2%9C%93&q=ArrayUtils) \r\n2. [Zend\\Router](https://github.com/zendframework/zend-router/search?utf8=%E2%9C%93&q=ArrayUtils)\r\n3. [Zend\\View](https://github.com/zendframework/zend-view/search?utf8=%E2%9C%93&q=ArrayUtils)\r\n4. [Zend\\ConfigAggregator](https://github.com/zendframework/zend-config-aggregator/blob/master/src/ConfigAggregator.php#L99-L129) - (copy-pasted code because it **ONLY** needs the array utility)\r\n\r\nSeparating this may have a relevant value to packages that utilizes array functions such as the [framework](https://github.com/zendframework/ZendSkeletonApplication) itself since the default configuration is in array.\r\n\r\nPorted repository: https://github.com/php-refactoring/zend-array-utility\r\n- [X] Supports PHP 5.6\r\n- [X] Added QA checks like [Zend coding standard](https://github.com/zendframework/zend-coding-standard) and [license header validation](https://github.com/malukenho/docheader)\r\n\r\n\r\n**Pros:**\r\n- Be able to upgrade the array utility classes, such as array sort, merge, find, etc.\r\n- Will be able to stress test and benchmark all scenarios.\r\n- We can have separate documentation on how to use this library.\r\n- Zend Components and other packages that requires **_zend-stblib_** but not using the Array* classes will not be (that much) affected.\r\n\r\n**Cons:**\r\n- Zend components and other packages that requires **_zend-stblib_** and uses the Array* classes will be affected. Thus, it will require **_zendframework/zend-array-utility_** as dependecy for **_zend-stdlib_** to be BC compatible.\r\n\r\n**To do:**\r\n- [ ] Include the array utility package as **_zendframework/zend-array-utility_** as dependecy for **_zend-stdlib_**\r\n- [ ] Integration testing for components requiring **_zend-stdlib_** and uses the Array* classes\r\n- [ ] Dedicated documentation for array utilities\n\n---\n\nOriginally posted by @gabbydgab at https://github.com/zendframework/zend-stdlib/issues/69"},"comment":{"url":"https://api.github.com/repos/laminas/laminas-stdlib/issues/comments/569999511","html_url":"https://github.com/laminas/laminas-stdlib/issues/3#issuecomment-569999511","issue_url":"https://api.github.com/repos/laminas/laminas-stdlib/issues/3","id":569999511,"node_id":"MDEyOklzc3VlQ29tbWVudDU2OTk5OTUxMQ==","user":{"login":"weierophinney","id":25943,"node_id":"MDQ6VXNlcjI1OTQz","avatar_url":"https://avatars1.githubusercontent.com/u/25943?v=4","gravatar_id":"","url":"https://api.github.com/users/weierophinney","html_url":"https://github.com/weierophinney","followers_url":"https://api.github.com/users/weierophinney/followers","following_url":"https://api.github.com/users/weierophinney/following{/other_user}","gists_url":"https://api.github.com/users/weierophinney/gists{/gist_id}","starred_url":"https://api.github.com/users/weierophinney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weierophinney/subscriptions","organizations_url":"https://api.github.com/users/weierophinney/orgs","repos_url":"https://api.github.com/users/weierophinney/repos","events_url":"https://api.github.com/users/weierophinney/events{/privacy}","received_events_url":"https://api.github.com/users/weierophinney/received_events","type":"User","site_admin":false},"created_at":"2019-12-31T22:27:08Z","updated_at":"2019-12-31T22:27:08Z","author_association":"MEMBER","body":"@Ocramius \r\n\r\nThe commits are in this repository: https://github.com/php-refactoring/zend-array-utility (develop branch)\r\n\r\n> Please don't do that - the CCLOC is there due to past benchmarks. If you are doing a split, just do that and add issues for further improvements later.\r\n\r\nI will not touch that in the upstream (zend-stdlib); just want to demonstrate that the created classes ([SimpleIterator](https://github.com/php-refactoring/zend-array-utility/blob/develop/src/Iterator/SimpleIterator.php) and [RecursiveIterator](https://github.com/php-refactoring/zend-array-utility/blob/develop/src/Iterator/RecursiveIterator.php)) can be used on the current logic.\r\n\r\nUpstream code: [ArrayUtils::iteratorToArray() method](https://github.com/zendframework/zend-stdlib/blob/master/src/ArrayUtils.php#L216-L255) \r\n```php\r\n    public static function iteratorToArray($iterator, $recursive = true)\r\n    {\r\n        if (! is_array($iterator) && ! $iterator instanceof Traversable) {\r\n            throw new Exception\\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable object');\r\n        }\r\n        if (! $recursive) {\r\n            if (is_array($iterator)) {\r\n                return $iterator;\r\n            }\r\n            return iterator_to_array($iterator);\r\n        }\r\n        if (method_exists($iterator, 'toArray')) {\r\n            return $iterator->toArray();\r\n        }\r\n        $array = [];\r\n        foreach ($iterator as $key => $value) {\r\n            if (is_scalar($value)) {\r\n                $array[$key] = $value;\r\n                continue;\r\n            }\r\n            if ($value instanceof Traversable) {\r\n                $array[$key] = static::iteratorToArray($value, $recursive);\r\n                continue;\r\n            }\r\n            if (is_array($value)) {\r\n                $array[$key] = static::iteratorToArray($value, $recursive);\r\n                continue;\r\n            }\r\n            $array[$key] = $value;\r\n        }\r\n        return $array;\r\n    }\r\n```\r\n\r\nWill be simplified to use the Iterator classes in the proposed **Zend\\ArrayUtils** package for BC compatibility\r\n```php\r\n    public static function iteratorToArray($iterator, $recursive = true)\r\n    {\r\n        if (! $recursive) {\r\n            return SimpleIterator::toArray($iterator);\r\n        }\r\n        return RecursiveIterator::toArray($iterator);\r\n    }\r\n```\r\n\r\nI'm thinking that, if applied, will set as deprecated method then suggest to use the appropriate array utily (**Zend\\ArrayUtils**) package moving forward.\n\n---\n\nOriginally posted by @gabbydgab at https://github.com/zendframework/zend-stdlib/issues/69#issuecomment-271120387"}}
{"actor":{"display_login":"weierophinney"}}