Skip to content

Commit

Permalink
Remove deprecated, increase countInstantiatedServices performances
Browse files Browse the repository at this point in the history
  • Loading branch information
steevanb committed Aug 6, 2018
1 parent c149267 commit a92ca8a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
10 changes: 4 additions & 6 deletions ContainerIntrospectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ public function countRegisteredServices(): int

public function getInstantiatedServices(): array
{
$services = array_keys($this->getPrivatePropertyValue('services'));
sort($services);
$services = $this->getPrivatePropertyValue('services');
ksort($services);

$return = [];
foreach ($services as $id) {
$service = $this->container->get($id);

foreach ($services as $id => $service) {
if (is_object($service)) {
$ocramiusLazy = $service instanceof VirtualProxyInterface;
$className = ($ocramiusLazy) ? get_parent_class($service) : get_class($service);
Expand Down Expand Up @@ -101,7 +99,7 @@ public function getInstantiatedServices(): array

public function countInstantiatedServices(): int
{
return count($this->getInstantiatedServices());
return count($this->getPrivatePropertyValue('services'));
}

public function getPrivateServices(): array
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![version](https://img.shields.io/badge/version-1.0.1-green.svg)](https://github.com/steevanb/symfony-container-introspection/tree/1.0.1)
[![version](https://img.shields.io/badge/version-1.0.2-green.svg)](https://github.com/steevanb/symfony-container-introspection/tree/1.0.2)
[![php](https://img.shields.io/badge/php-^7.1-blue.svg)](https://php.net)
[![symfony](https://img.shields.io/badge/symfony/dependency--injection-^3.4||^4.0-blue.svg)](https://symfony.com)
![Lines](https://img.shields.io/badge/code%20lines-734-green.svg)
![Lines](https://img.shields.io/badge/code%20lines-738-green.svg)
![Total Downloads](https://poser.pugx.org/steevanb/symfony-container-introspection/downloads)
[![Scrutinizer](https://scrutinizer-ci.com/g/steevanb/symfony-container-introspection/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/steevanb/symfony-container-introspection/)

Expand All @@ -24,7 +24,7 @@ Installation
============

```bash
composer require --dev steevanb/symfony-container-introspection ^1.0
composer require --dev steevanb/symfony-container-introspection ^1.0.2
```

If you use Symfony (and not just symfony/dependency-injection), you can add `ContainerIntrospectionBundle` to your Kernel:
Expand Down
7 changes: 6 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
### [1.0.1](../../../compare/1.0.0...1.0.1) - 2018-06-06
### [1.0.2](../../compare/1.0.1...1.0.2) - 2018-08-06

- Do not call `ContainerInterface::get()` to retrieve informations on service, we already got it. It remove deprecated for private services in Symfony 3, and retrieve private service informations in Symfony 4.
- Increase `ContainerIntrospectionService::countInstantiatedServices()` performances

### [1.0.1](../../compare/1.0.0...1.0.1) - 2018-06-06

- Fix when service is not an object

Expand Down

0 comments on commit a92ca8a

Please sign in to comment.