Skip to content

Commit

Permalink
Container: $methods are not filtered
Browse files Browse the repository at this point in the history
For speed up
  • Loading branch information
dg committed Apr 28, 2024
1 parent fe3ed08 commit 1fa0bc4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
13 changes: 7 additions & 6 deletions src/Bridges/DITracy/ContainerPanel.php
Expand Up @@ -50,11 +50,13 @@ public function getTab(): string
*/
public function getPanel(): string
{
$methods = (fn() => $this->methods)->bindTo($this->container, Container::class)();
$rc = (new \ReflectionClass($this->container));
$services = [];
foreach ($methods as $name => $foo) {
$name = lcfirst(str_replace('__', '.', substr($name, 13)));
$services[$name] = $this->container->getServiceType($name);
foreach ($rc->getMethods() as $method) {
if (preg_match('#^createService.#', $method->getName())) {
$name = lcfirst(str_replace('__', '.', substr($method->getName(), 13)));
$services[$name] = $this->container->getServiceType($name);
}
}
ksort($services, SORT_NATURAL);

Expand All @@ -66,9 +68,8 @@ public function getPanel(): string
}
}

return Nette\Utils\Helpers::capture(function () use ($tags, $services) {
return Nette\Utils\Helpers::capture(function () use ($rc, $tags, $services) {
$container = $this->container;
$rc = (new \ReflectionClass($this->container));
$file = $rc->getFileName();
$instances = (fn() => $this->instances)->bindTo($this->container, Container::class)();
$wiring = (fn() => $this->wiring)->bindTo($this->container, $this->container)();
Expand Down
7 changes: 2 additions & 5 deletions src/DI/Container.php
Expand Up @@ -48,10 +48,7 @@ class Container
public function __construct(array $params = [])
{
$this->parameters = $params + $this->getStaticParameters();
$this->methods = array_flip(array_filter(
get_class_methods($this),
fn($s) => preg_match('#^createService.#', $s),
));
$this->methods = array_flip(get_class_methods($this));
}


Expand Down Expand Up @@ -372,7 +369,7 @@ private function autowireArguments(\ReflectionFunctionAbstract $function, array
/**
* Returns the method name for creating a service.
*/
public static function getMethodName(string $name): string
final public static function getMethodName(string $name): string
{
if ($name === '') {
throw new Nette\InvalidArgumentException('Service name must be a non-empty string.');
Expand Down

0 comments on commit 1fa0bc4

Please sign in to comment.