voku/simple-php-code-parser
Get a simple data structure from your php code.
0.22.3
42K downloads/mo
#3485 most downloaded on Packagist
voku/Simple-PHP-Code-Parser
What this package is like to depend on
Last release 7 days ago
16 Aug 2026
Ships unpredictably
gaps range from 1 weeks to 2.7 years
Nearly every release is documented
notes for 46 of 46 stable releases
Nothing withdrawn
no release was ever pulled
6 years old
46 releases · first in 2020
5 releases in the last 12 months
see the full history below
Release timeline
46 releases · May 2020 to Aug 2026Releases
latest 46-
0.22.316 Aug 2026Release notes
Open source →- add
AstNodeInspectorhelpers for exact node source slices, one-based start columns, and shallow value-independent AST shape fingerprints so downstream analyzers can reuse parser mechanics without reimplementing traversal plumbing - fix PHP 8.5 relative
self/parent/statictype preservation so lexical AST types win only when AST evidence exists, while pure Reflection stays honest - fix inheritdoc merging when no parent class exists by avoiding null parent lookups
- add
-
0.22.205 Aug 2026Release notes
Open source →Document the behaviour changes since 0.22.1 in the changelog and add the
tests that prove nothing else changed.The behaviour delta was measured by diffing the full parsed model of a
433-file corpus (synthetic syntax fixtures, nikic/php-parser and
phpdocumentor) between 0.22.1 and HEAD. Exactly three changes showed up,
all of them intended:- reflected property/parameter types are now consistently fully
qualified (\Psr\Container\ContainerInterfaceinstead of
Psr\Container\ContainerInterface) - enum cases no longer leak into
PHPEnum::$constants PHPEnum::$is_final/$is_abstract/$is_anonymousare no longer
nullfor enums that cannot be autoloaded
New tests:
- ReflectionTypeFormattingRegressionTest: pins the rendered type strings
for the AST path and the reflection path and asserts they agree, plus
the no-autoload guarantee - PublicApiSurfaceTest: snapshot of every public property and method, so
a removal or an incompatible signature change fails the build - ModelInvariantsRegressionTest: parses the whole library and every
fixture and checks the model invariants, including that class-like
types are always fully qualified - ParserEntryPointsTest: end-to-end coverage of getAstFromFile(),
getFileInfoFromFile(), the container setters and getFunctionsInfo(),
which had no test before - PHPEnumRegressionTest / AutoloadSafetyRegressionTest: extended to all
three enum read paths and to the shared autoload guard
All new tests fail against 0.22.1 and pass on both nikic/php-parser v4
and v5.Also widen the extractHooksFromReflection() array key type, which
phpstan rejected on PHP 8.4 because getHooks() is keyed by name.Co-Authored-By: Claude Opus 5 [email protected]
Release notes
Open source →- BREAKING (output only):
PHPProperty::$type/PHPParameter::$typeread via reflection are now consistently fully qualified, e.g.Psr\Container\ContainerInterfaceis now reported as\Psr\Container\ContainerInterface. Previously the leading\was only added whenclass_exists()happened to be true, so interfaces, enums-in-unloadable-files and any not-yet-autoloadable class silently lost it, while the AST path always emitted it. Both paths now agree. Consumers that compare these strings verbatim have to expect the leading\(built-in types,self,parent,staticand intersection types are unchanged) - BREAKING (output only): enum cases no longer show up in
PHPEnum::$constants; they were already available (with more detail) via$cases/$caseDetails - fix: formatting a reflected property/parameter type no longer autoloads the referenced class, which could fatal when that class uses syntax the current runtime cannot compile
- fix:
PHPEnumread from a plainReflectionClass(which is whatUtils::createClassReflectionInstance()returns) now reports$scalarTypeand$cases/$caseDetails; before, that data was only filled in when aReflectionEnumwas passed explicitly - fix:
PHPEnum::$is_final/$is_abstract/$is_anonymousnow always reflect the language guarantees (true/false/false) instead of stayingnullwhen the enum could not be autoloaded - fix: traits with constants use the shared PHP-version autoload guard again, so the runtime-compatibility check is identical for classes, interfaces, traits and enums
- add regression coverage for all of the above, plus a public-API surface test, model invariants over the whole code base and end-to-end coverage of every
PhpCodeParserentry point
- reflected property/parameter types are now consistently fully
-
0.22.113 Jul 2026Release notes
Open source →- fix: reflecting/parsing a private or protected class constant referenced from outside its declaring class (via
constant()/ReflectionParameter::getDefaultValue()) threw an uncaught\Errorand aborted the whole parse; now recovered gracefully - fix:
PHPConstreflection path assigned an unnormalizedgettype()string (e.g.'NULL'instead of'null') when a constant's value couldn't be resolved - add regression coverage for parsing/reflecting code that references private/protected constants across class boundaries
- fix: phpstan dead-catch false positive on the
\Errorcatch aroundReflectionParameter::getDefaultValue()(its stub only declares\ReflectionException, but it also throws\Errorat runtime for this case)
- fix: reflecting/parsing a private or protected class constant referenced from outside its declaring class (via
-
0.22.010 Jul 2026Release notes
Open source →- add source-range info to every model element:
endLine,startFilePos,endFilePos(byte offsets), enabling precisesed/byte-range reads of a single declaration without loading the whole file - add
PHPFileInfo+PhpCodeParser::getFileInfoFromFile()for a lightweight per-file summary (namespaces, imports, declares) - add
PhpCodeParser::getAstFromFile()/getAstFromString()to expose the names-resolved php-parser AST directly for syntax outside the compact Model API - add import-aware, resolved phpdoc types via
PhpDocContextConnector:typeFromPhpDocResolved/returnTypeFromPhpDocResolvedresolve aliased class names (e.g.use Vendor\Payload as Message;) without touching legacy rendered fields - add
$traitUses/$traitAdaptations(aliasing,insteadof) to class-like models; interfaces now retain all declared parent interfaces - add
$throws(from@throws),is_returned_by_ref, and (for methods)is_abstractto function/method models; addis_promotedto parameters - add
PHPEnumCase+$caseDetailsonPHPEnumfor source-aware, attribute-aware enum cases, alongside the existing legacy$casesvalue map - fix: only the first property in a multi-property declaration (e.g.
public $a, $b;) was parsed; all properties in the group are now read - add extensive regression coverage for the above
- add source-range info to every model element:
-
0.21.021 Apr 2026Release notes
Open source →- BREAKING: runtime support now requires PHP >= 8.1 (instead of PHP >= 7.4), while the parser still analyzes older PHP source syntax from PHP 5.3 through PHP 8.5
- add broad PHP 8.x syntax and metadata support, including enums, attributes, typed constants, readonly / promoted properties,
#[\Override], and property hooks with asymmetric visibility - improve phpdoc parsing and recovery for malformed docs, modern type syntax, inherited annotations, and raw
@param/@returnpreservation - modernize parser compatibility and dependencies: support
nikic/php-parserv4.18 and v5, update phpDocumentor / phpdoc-parser / phpunit / phpstan dependencies, and replace React-based file reads - improve autoloading and reflection safety for version-specific syntax and better file read error reporting
- add extensive regression coverage plus feature validation for analyzable PHP source syntax from PHP 5.3 through PHP 8.5
-
0.20.113 Aug 2023 -
0.20.031 Jul 2023Release notes
Open source →- add support for "readonly" properties
- replace deprecated "parts" property from nikic/PHP-Parser
- use "phpstan/phpdoc-parser" as fallback for parameters e.g. for
callable()types - use php types
- add more tests
-
0.19.623 Sep 2022Release notes
Open source →- try to fix autoload #11
- inheritDoc: use all types (not only from phpdoc) from parent classes & interfaces
- add more tests
-
0.19.529 Aug 2022 -
0.19.429 Aug 2022 -
0.19.327 Aug 2022Release notes
Open source →- update "phpdocumentor/type-resolver" (with support for int-ranges)
- clean-up some errors reported by phpstan
-
0.19.215 Feb 2022 -
0.19.115 Feb 2022Release notes
Open source →- optimize NULL detecting from reflection for types
- "BasePHPClass" -> add more information from reflection
- "PHPConst" -> add "visibility"
-
0.19.002 Feb 2022Release notes
Open source →- use native php reflection, instead of (slower) better reflection
- remove "react/filesystem" (not working with phar files)
-
0.18.229 Nov 2021 -
0.18.003 Oct 2021 -
0.17.026 Jul 2021 -
0.16.626 Dec 2020Release notes
Open source →- "PhpCodeParser" -> optimize exception handling of "amphp/parallel" for async code analysis per file
-
0.16.526 Dec 2020 -
0.16.418 Nov 2020 -
0.16.330 Oct 2020 -
0.16.230 Oct 2020 -
0.16.130 Oct 2020 -
0.16.030 Oct 2020 -
0.15.307 Oct 2020Release notes
Open source →- update vendor libs
- PHP 7.2 as minimal requirement
- remove custom PseudoTypes for phpDocumentor (PseudoTypes are now build in into phpDocumentor itself)
- add more tests
-
0.15.204 Sep 2020 -
0.15.104 Sep 2020 -
0.15.031 Aug 2020Release notes
Open source →- move "PhpCodeChecker" in a separate repository
- move "PhpCodeDumpApi" in a separate repository
- clean-up vendor dependencies
-
0.14.022 Aug 2020Release notes
Open source →- "PhpCodeCheckerCommand" -> allow to exclude some files
- optimize parallel execution (cpu cores === max parallel executions)
- update vendor (phpdocumentor & better-reflection)
-
0.13.206 Aug 2020 -
0.13.018 Jul 2020 -
0.12.004 Jul 2020Release notes
Open source →- "PhpCodeParser" -> fix cache key
- "PhpCodeChecker" -> fix the autoloader parameter
-
0.11.017 Jun 2020Release notes
Open source →- "PHPInterface" -> fix recursion
- "PhpCodeParser" -> analyse only ".php" files in the given path
-
0.10.017 Jun 2020Release notes
Open source →- "PhpCodeParser" -> ignore errors outside the current file-path-scope
- "PhpCodeParser" -> use more generic autoloader logic
- "PhpCodeChecker" -> fix more inheritdoc errors
-
0.9.016 Jun 2020Release notes
Open source →- "PhpCodeChecker" -> check wrong phpdocs from class properties
- "PhpCodeParser" -> allow to exclude some files
-
0.8.015 Jun 2020Release notes
Open source →- replace PhpReflection with BetterReflection v2
- fix bugs reported by PhpStan & PhpCodeCheck
-
0.7.002 Jun 2020 -
0.6.025 May 2020 -
0.5.024 May 2020Release notes
Open source →- "ParserErrorHandler" -> show more parsing errors in the results
- "PHPInterface" -> fix PhpReflection usage
-
0.4.223 May 2020 -
0.4.123 May 2020 -
0.4.022 May 2020Release notes
Open source →- add default values for parameter and properties
- add types from default values
- normalize types (e.g. double => float)
-
0.3.021 May 2020 -
0.2.120 May 2020 -
0.2.018 May 2020 -
0.1.013 May 2020Release notes
Open source →- init (forked from "JetBrains/phpstorm-stubs")
- add "PHPProperties"
- add "PHP Reflection" AND / OR "nikic/PHP-Parser"
- get phpdocs types via phpDocumentor (+ psalm)