Repository: symfony/symfony
File: src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php (PHP)

Code before:
            class_alias(AppReference::class, App::class);
        }

        // the closure forbids access to the private scope in the included file
        $load = \Closure::bind(static function ($path, $env) use ($container, $loader, $resource, $type) {
            return include $path;
        }, null, null);

        $instanceof = $this->instanceof;
        $this->instanceof = [];

        try {
            try {
                if (1 === $result = $load($path, $this->env)) {
                    $result = null;
                }
            } catch (\Error $e) {
                $load = \Closure::bind(function ($path, $env) use ($container, $loader, $resource, $type) {
                    return include $path;
                }, $this, ProtectedPhpFileLoader::class);

                if (1 === $result = $load($path, $this->env)) {
                    $result = null;
                }

                throw new LogicException(\sprintf('Using `$this` or its internal scope in config files is deprecated, use the `$loader` variable instead in "%s" on line %d.', $e->getFile(), $e->getLine()));
            }

            if (\is_object($result) && \is_callable($result)) {
                $this->callConfigurator($result, new ContainerConfigurator($this->container, $this, $this->instanceof, $path, $resource, $this->env), $path);
            } elseif (\is_array($result)) {
                $yamlLoader = new YamlFileLoader($this->container, $this->locator, $this->env, $this->prepend);
                $yamlLoader->setResolver($this->resolver ?? new LoaderResolver([$this]));
                $loadContent = new \ReflectionMethod(YamlFileLoader::class, 'loadContent');
                $result = ContainerConfigurator::processValue($result);

                ++$this->importing;
                try {
                    $content = array_intersect_key($result, ['imports' => true, 'parameters' => true, 'services' => true]);
                    $loadContent->invoke($yamlLoader, $content, $path);

                    foreach ($result as $namespace => $config) {
                        if (\in_array($namespace, ['imports', 'parameters', 'services'], true)) {
                            continue;
                        }
                        if (str_starts_with($namespace, 'when@')) {
                            $knownEnvs = $this->container->hasParameter('.container.known_envs') ? array_flip($this->container->getParameter('.container.known_envs')) : [];
                            $this->container->setParameter('.container.known_envs', array_keys($knownEnvs + [substr($namespace, 5) => true]));
                            continue;
                        }
                        $this->loadExtensionConfig($namespace, $config);

Review comment (suggestion):
the message should not say "is deprecated" when it is an error. Saying "is not supported anymore" would be better IMO.

Code after:
            class_alias(AppReference::class, App::class);
        }

        // the closure forbids access to the private scope in the included file
        $load = \Closure::bind(static function ($path, $env) use ($container, $loader, $resource, $type) {
            return include $path;
        }, null, null);

        $instanceof = $this->instanceof;
        $this->instanceof = [];

        try {
            try {
                if (1 === $result = $load($path, $this->env)) {
                    $result = null;
                }
            } catch (\Error $e) {
                $load = \Closure::bind(function ($path, $env) use ($container, $loader, $resource, $type) {
                    return include $path;
                }, $this, ProtectedPhpFileLoader::class);

                if (1 === $result = $load($path, $this->env)) {
                    $result = null;
                }

                throw new LogicException(\sprintf('Using `$this` or its internal scope in config files is not supported anymore, use the `$loader` variable instead in "%s" on line %d.', $e->getFile(), $e->getLine()), $e->getCode(), $e);
            }

            if (\is_object($result) && \is_callable($result)) {
                $this->callConfigurator($result, new ContainerConfigurator($this->container, $this, $this->instanceof, $path, $resource, $this->env), $path);
            } elseif (\is_array($result)) {
                $yamlLoader = new YamlFileLoader($this->container, $this->locator, $this->env, $this->prepend);
                $yamlLoader->setResolver($this->resolver ?? new LoaderResolver([$this]));
                $loadContent = new \ReflectionMethod(YamlFileLoader::class, 'loadContent');
                $result = ContainerConfigurator::processValue($result);

                ++$this->importing;
                try {
                    $content = array_intersect_key($result, ['imports' => true, 'parameters' => true, 'services' => true]);
                    $loadContent->invoke($yamlLoader, $content, $path);

                    foreach ($result as $namespace => $config) {
                        if (\in_array($namespace, ['imports', 'parameters', 'services'], true)) {
                            continue;
                        }
                        if (str_starts_with($namespace, 'when@')) {
                            $knownEnvs = $this->container->hasParameter('.container.known_envs') ? array_flip($this->container->getParameter('.container.known_envs')) : [];
                            $this->container->setParameter('.container.known_envs', array_keys($knownEnvs + [substr($namespace, 5) => true]));
                            continue;
                        }
                        $this->loadExtensionConfig($namespace, $config);