Repository: symfony/symfony
File: src/Symfony/Component/Config/Definition/BaseNode.php (PHP)

Code before:
     * @param \Closure[] $closures An array of Closures used for final validation
     */
    public function setFinalValidationClosures(array $closures): void
    {
        $this->finalValidationClosures = $closures;
    }

    public function isRequired(): bool
    {
        return $this->required;
    }

    /**
     * Checks if this node is deprecated.
     */
    public function isDeprecated(): bool
    {
        return (bool) $this->deprecation;
    }

    /**
     * @param string $node The configuration node name
     * @param string $path The path of the node
     * @return array{package: string, version: string, message: string}
     */
    public function getDeprecation(string $node, string $path): array
    {
        return [
            'package' => $this->deprecation['package'],
            'version' => $this->deprecation['version'],
            'message' => strtr($this->deprecation['message'], ['%node%' => $node, '%path%' => $path]),
        ];
    }

    public function getDeprecationMessage(string $node, string $path): string
    {
        if (!$this->deprecation) {
            throw new \LogicException(sprintf('The node "%s" is not deprecated.', $node));
        }

        $message = strtr($this->deprecation['message'], ['%node%' => $node, '%path%' => $path]);
        if ($this->deprecation['package'] || $this->deprecation['version']) {
            $message = sprintf('Since %s %s: ', $this->deprecation['package'], $this->deprecation['version']) . $message;
        }

        return $message;
    }

    public function getName(): string
    {
        return $this->name;

Review comment (refactor):
We can also update the returned message to prepend the package and version. But this could duplicate the "since ..." prefix if its prepended somewhere outside. This method is not used in Symfony outside of the Config component.

Code after:
     *
     * @param \Closure[] $closures An array of Closures used for final validation
     */
    public function setFinalValidationClosures(array $closures): void
    {
        $this->finalValidationClosures = $closures;
    }

    public function isRequired(): bool
    {
        return $this->required;
    }

    /**
     * Checks if this node is deprecated.
     */
    public function isDeprecated(): bool
    {
        return (bool) $this->deprecation;
    }

    /**
     * @param string $node The configuration node name
     * @param string $path The path of the node
     *
     * @return array{package: string, version: string, message: string}
     */
    public function getDeprecation(string $node, string $path): array
    {
        if (!$this->deprecation) {
            throw new LogicException(\sprintf('The node "%s" is not deprecated.', $this->getName()));
        }

        return [
            'package' => $this->deprecation['package'],
            'version' => $this->deprecation['version'],
            'message' => strtr($this->deprecation['message'], ['%node%' => $node, '%path%' => $path]),
        ];
    }

    /**
     * @internal
     */
    public function getDeprecationMessage(?NodeInterface $parent = null): string
    {
        if (!$this->deprecation) {
            throw new LogicException(\sprintf('The node "%s" is not deprecated.', $this->getName()));
        }

        $message = strtr($this->deprecation['message'], ['%node%' => $this->getName(), '%path%' => ($parent ?? $this->parent ?? $this)->getPath()]);
        if ($this->deprecation['package'] || $this->deprecation['version']) {