diff --git a/composer.json b/composer.json index 14511ec25..389d8da90 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "nette/php-generator": "^3.3.3", "nette/robot-loader": "^3.2", "nette/schema": "^1.0", - "nette/utils": "^3.1" + "nette/utils": "^3.0" }, "require-dev": { "nette/tester": "^2.2", diff --git a/src/Bridges/DITracy/ContainerPanel.php b/src/Bridges/DITracy/ContainerPanel.php index 93e88f79d..eb06c4e62 100644 --- a/src/Bridges/DITracy/ContainerPanel.php +++ b/src/Bridges/DITracy/ContainerPanel.php @@ -45,10 +45,10 @@ public function __construct(Container $container) */ public function getTab(): string { - return Nette\Utils\Helpers::capture(function () { - $elapsedTime = $this->elapsedTime; - require __DIR__ . '/templates/ContainerPanel.tab.phtml'; - }); + ob_start(function () {}); + $elapsedTime = $this->elapsedTime; + require __DIR__ . '/templates/ContainerPanel.tab.phtml'; + return ob_get_clean(); } @@ -57,8 +57,12 @@ public function getTab(): string */ public function getPanel(): string { - $rc = new \ReflectionClass($this->container); + $container = $this->container; + $rc = new \ReflectionClass($container); + $file = $rc->getFileName(); $tags = []; + $instances = $this->getContainerProperty('instances'); + $wiring = $this->getContainerProperty('wiring'); $types = []; foreach ($rc->getMethods() as $method) { if (preg_match('#^createService(.+)#', $method->name, $m) && $method->getReturnType()) { @@ -73,13 +77,9 @@ public function getPanel(): string } } - return Nette\Utils\Helpers::capture(function () use ($tags, $types, $rc) { - $container = $this->container; - $file = $rc->getFileName(); - $instances = $this->getContainerProperty('instances'); - $wiring = $this->getContainerProperty('wiring'); - require __DIR__ . '/templates/ContainerPanel.panel.phtml'; - }); + ob_start(function () {}); + require __DIR__ . '/templates/ContainerPanel.panel.phtml'; + return ob_get_clean(); } diff --git a/src/DI/Compiler.php b/src/DI/Compiler.php index c4ad760fd..50e2b0522 100644 --- a/src/DI/Compiler.php +++ b/src/DI/Compiler.php @@ -242,7 +242,7 @@ public function processExtensions(): void throw new Nette\DeprecatedException("Extensions '$extra' were added while container was being compiled."); } elseif ($extra = key(array_diff_key($this->configs, $this->extensions))) { - $hint = Nette\Utils\Helpers::getSuggestion(array_keys($this->extensions), $extra); + $hint = Nette\Utils\ObjectHelpers::getSuggestion(array_keys($this->extensions), $extra); throw new InvalidConfigurationException( "Found section '$extra' in configuration, but corresponding extension is missing" . ($hint ? ", did you mean '$hint'?" : '.') diff --git a/src/DI/CompilerExtension.php b/src/DI/CompilerExtension.php index 29eef3688..4b0d9a14c 100644 --- a/src/DI/CompilerExtension.php +++ b/src/DI/CompilerExtension.php @@ -89,7 +89,7 @@ public function validateConfig(array $expected, array $config = null, string $na } if ($extra = array_diff_key((array) $config, $expected)) { $name = $name ? str_replace('.', ' › ', $name) : $this->name; - $hint = Nette\Utils\Helpers::getSuggestion(array_keys($expected), key($extra)); + $hint = Nette\Utils\ObjectHelpers::getSuggestion(array_keys($expected), key($extra)); $extra = $hint ? key($extra) : implode("', '{$name} › ", array_keys($extra)); diff --git a/src/DI/ContainerLoader.php b/src/DI/ContainerLoader.php index 255f04362..7cc22ca7c 100644 --- a/src/DI/ContainerLoader.php +++ b/src/DI/ContainerLoader.php @@ -67,9 +67,9 @@ private function loadFile(string $class, callable $generator): void $handle = @fopen("$file.lock", 'c+'); // @ is escalated to exception if (!$handle) { - throw new Nette\IOException("Unable to create file '$file.lock'. " . Nette\Utils\Helpers::getLastError()); + throw new Nette\IOException("Unable to create file '$file.lock'. " . error_get_last()['message']); } elseif (!@flock($handle, LOCK_EX)) { // @ is escalated to exception - throw new Nette\IOException("Unable to acquire exclusive lock on '$file.lock'. " . Nette\Utils\Helpers::getLastError()); + throw new Nette\IOException("Unable to acquire exclusive lock on '$file.lock'. " . error_get_last()['message']); } if (!is_file($file) || $this->isExpired($file, $updatedMeta)) { diff --git a/src/DI/Definitions/FactoryDefinition.php b/src/DI/Definitions/FactoryDefinition.php index e409bf2c8..30ba30986 100644 --- a/src/DI/Definitions/FactoryDefinition.php +++ b/src/DI/Definitions/FactoryDefinition.php @@ -240,7 +240,7 @@ private function completeParameters(Nette\DI\Resolver $resolver): void $this->resultDefinition->getFactory()->arguments[$arg->getPosition()] = Nette\DI\ContainerBuilder::literal('$' . $arg->name); } elseif (!$this->resultDefinition->getSetup()) { - $hint = Nette\Utils\Helpers::getSuggestion(array_keys($ctorParams), $param->name); + $hint = Nette\Utils\ObjectHelpers::getSuggestion(array_keys($ctorParams), $param->name); throw new ServiceCreationException("Unused parameter \${$param->name} when implementing method $interface::create()" . ($hint ? ", did you mean \${$hint}?" : '.')); } $nullable = $hint && $param->allowsNull() && (!$param->isDefaultValueAvailable() || $param->getDefaultValue() !== null);