Platforms
Platforms
A platform is a set of tags the parser knows: their definitions, aliases and combinators.
use TypeLang\PhpDoc\DocBlockParser;
// every built-in platform$parser = DocBlockParser::createDefault();
// every built-in platform and your own$parser = DocBlockParser::createDefault(additionalPlatforms: [ new MoneyPlatform(),]);
// only the given ones: any other tag is a plain Tag$parser = new DocBlockParser(platforms: [ new StandardPlatform(), new PhpStanPlatform(),]);A later platform overrides a tag, an alias or a combinator of an earlier one with the same name. No name is shared by two built-in platforms, so their order does not matter. The names are matched without regard to case.
Built-in platforms
Section titled “Built-in platforms”| Platform | Tags |
|---|---|
StandardPlatform |
Standard and Advanced |
PhpDocumentorPlatform |
phpDocumentor |
PhpStanPlatform |
PHPStan and the @phpstan- spellings of the shared tags |
PsalmPlatform |
Psalm and the @psalm- spellings |
PhanPlatform |
Phan and the @phan- spellings |
PhpStormPlatform |
PhpStorm |
PhpCodeSnifferPlatform |
PHP CodeSniffer |
Custom platform
Section titled “Custom platform”A platform extends Platform and overrides what it adds:
use TypeLang\PhpDoc\Platform\Platform;
final class MoneyPlatform extends Platform{ // definitions by the name of the tag public function getTags(): iterable { return ['money' => new MoneyTagDefinition()]; }
// other spellings of a tag: @price is read as @money public function getAliases(): iterable { return ['price' => 'money']; }
// combinators the definitions use, by their names public function getCombinators(): iterable { return [PriorityCombinator::NAME => new PriorityCombinator()]; }}A combinator is a CombinatorInterface or any callable(Cursor): mixed.
See custom tags for the whole way from a
tag to a platform.
The registered definitions are $parser->tags, a countable and iterable
TagRegistryInterface.