class DeprecationParser (View source)

Extracts deprecation state — the flag and the PHP version it starts at — from a stub element.

Two distinct attributes mark deprecation in the stubs, and their positional arguments differ:

  • JetBrains\PhpStorm\Deprecated($reason, $replacement, $since)since is argument 2.
  • the built-in \Deprecated(?string $message, ?string $since) (PHP 8.4+) — since is argument 1. The named since: form is what the stubs overwhelmingly use, but positional args are read too, per flavour, so a positional since is never mistaken for a replacement or a message.

Precedence mirrors {\StubTests\Framework\Parsers\Stubs\Versions\DefaultAvailableVersionParser}: an attribute overrides the PhpDoc tag.

Constants

private FLAVOUR_JETBRAINS

private FLAVOUR_BUILTIN

private SINCE_POSITION

Position of the since argument when it is passed positionally, per attribute flavour.

Methods

parseDeprecation(array $attributes, array $imports = [], ParsedPhpDoc|null $phpDoc = null)

No description

static string|null
normalizePhpVersion(string $version)

Is $version one of the PHP versions this suite validates?

Details

ParsedDeprecation parseDeprecation(array $attributes, array $imports = [], ParsedPhpDoc|null $phpDoc = null)

No description

Parameters

array $attributes

Array of AttributeNode objects

array $imports

Map of import aliases to fully qualified names

ParsedPhpDoc|null $phpDoc

Already-parsed PhpDoc, contributing @_deprecated [version]

Return Value

ParsedDeprecation

static string|null normalizePhpVersion(string $version)

Is $version one of the PHP versions this suite validates?

Used to filter the @_deprecated PhpDoc tag, whose leading token is a PHP version on some entries (@_deprecated 7.1) but a library version on others (@_deprecated 2.3.0 use ..., for PECL extensions that version independently of PHP). Only recognised PHP versions are accepted, so a library version is never read as a language level. A patch component is tolerated — @_deprecated 7.0.7 narrows to 7.0 — because deprecation is tracked per minor.

Parameters

string $version

Return Value

string|null