docs

Various Yii 3.0 related documentation

View the Project on GitHub yiisoft/docs

015 - PhpStorm metadata and attributes

PhpStorm metadata

PhpStorm metadata helps IDE to understand code better in cases when regular types and PHPDoc tags don’t help.

We use the following set of coding styles for metadata.

Metadata location

Note: There is no support for subdirectories in PhpStorm yet.

Constants

All constant dictionaries should be named as {Class FQN}::{Group name}. Group name should be short and written in capital letters. Use underscore as a word separator that’s \Yiisoft\Http\Status::STATUSES. For example:

expectedReturnValues(
  \Psr\Http\Message\RequestInterface::getMethod(),
  argumentsSet('\Yiisoft\Http\Method::METHODS'),
);

registerArgumentsSet(
  '\Yiisoft\Http\Method::METHODS',
  \Yiisoft\Http\Method::GET,
  \Yiisoft\Http\Method::POST,
  \Yiisoft\Http\Method::PUT,
  \Yiisoft\Http\Method::DELETE,
  \Yiisoft\Http\Method::PATCH,
  \Yiisoft\Http\Method::HEAD,
  \Yiisoft\Http\Method::OPTIONS,
);

PhpStorm attributes

PhpStorm attributes CAN be used in code, but package jetbrains/phpstorm-attributes MUST be added as a dev dependency:

composer require --dev jetbrains/phpstorm-attributes

Using with ComposerRequireChecker

When ComposerRequireChecker is also used within the same package, add involved attributes’ class names to whitelist in config. For example:

{
    "symbol-whitelist": [
        "JetBrains\\PhpStorm\\ExpectedValues",
        "JetBrains\\PhpStorm\\Pure"
    ]
}