Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 8, 2024 via composer

phpstan/phpdoc-parser 1.24.4

PHPDoc parser with support for nullable, intersection and generic types
Package summary
Share
0
issues
1
license
1
MIT
Package created
19 Nov 2017
Version published
26 Nov 2023
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
phpstan/phpdoc-parser@1.24.4
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of phpstan/phpdoc-parser 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does phpstan/phpdoc-parser do?

The phpstan/phpdoc-parser package is a PHPDoc parser that supports handling of nullable, intersection, and generic types. It operates via an AST (Abstract Syntax Tree), which makes it capable of parsing and modifying PHPDoc content. In addition, the parser also extends its functionality to operate with Doctrine Annotations, when set to true.

How do you use phpstan/phpdoc-parser?

In terms of usage, the phpstan/phpdoc-parser package can be incorporated in your project by installing it via composer using the command composer require phpstan/phpdoc-parser. Once installed, it can be imported into your PHP files where necessary. Here is an example of how to parse and read a PHPDoc string:

<?php

require_once __DIR__ . '/vendor/autoload.php';

use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Lexer\Lexer;
use PHPStan\PhpDocParser\Parser\ConstExprParser;
use PHPStan\PhpDocParser\Parser\PhpDocParser;
use PHPStan\PhpDocParser\Parser\TokenIterator;
use PHPStan\PhpDocParser\Parser\TypeParser;

// basic setup

$lexer = new Lexer();
$constExprParser = new ConstExprParser();
$typeParser = new TypeParser($constExprParser);
$phpDocParser = new PhpDocParser($typeParser, $constExprParser);

// parsing and reading a PHPDoc string

$tokens = new TokenIterator($lexer->tokenize('/** @param Lorem $a */'));
$phpDocNode = $phpDocParser->parse($tokens); // PhpDocNode
$paramTags = $phpDocNode->getParamTagValues(); // ParamTagValueNode[]
echo $paramTags[0]->parameterName; // '$a'
echo $paramTags[0]->type; // IdentifierTypeNode - 'Lorem'

Where are the phpstan/phpdoc-parser docs?

You can find the documentation for the phpstan/phpdoc-parser on PHPStan's official documentation pages. This includes the PHPDoc Basics (a list of PHPDoc tags), PHPDoc Types (a list of PHPDoc types), and phpdoc-parser API Reference with all the AST node types, etc. These documentation pages provide a comprehensive understanding of how to effectively use this PHPDoc Parser.