Skip to content

Latest commit

 

History

History
48 lines (35 loc) · 1.43 KB

015-phpstorm.md

File metadata and controls

48 lines (35 loc) · 1.43 KB

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

  • Metadata should be placed in /.phpstorm.meta.php directory.
  • Configuration should be split into files. Each file should be named after a class it configures.

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