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 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.
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 CAN be used in code, but package
jetbrains/phpstorm-attributes
MUST be added as a dev dependency:
composer require --dev jetbrains/phpstorm-attributes
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"
]
}