Skip to content

vlasales/Simple-PHP-Code-Parser

 
 

Repository files navigation

Build Status Coverage Status Codacy Badge Latest Stable Version Total Downloads License Donate to this project using Paypal Donate to this project using Patreon

❤ Simple PHP Code Parser

You can simple scan a string, a file or a full directory. This code is mostly copy&pasted from JetBrains/phpstorm-stubs ;)

Install via "composer require"

composer require voku/simple-php-code-parser

Quick Start

Parse a string:

$code = ' <?php namespace tests; class SimpleClass {} $obja = new class() {}; $objb = new class {}; class AnotherClass {} '; $phpCode = \SimplePhpParser\Parsers\PhpCodeParser::getFromString($code); $phpClasses = $phpCode->getClasses(); var_dump($phpClasses['tests\SimpleClass']); // "PHPClass"-object

Parse one file:

$phpCode = \SimplePhpParser\Parsers\PhpCodeParser::getPhpFiles(__DIR__ . '/Dummy.php'); $phpClasses = $phpCode->getClasses(); var_dump($phpClasses[Dummy::class]); // "PHPClass"-object

Parse many files:

$phpCode = \SimplePhpParser\Parsers\PhpCodeParser::getPhpFiles(__DIR__ . '/src'); $phpClasses = $phpCode->getClasses(); var_dump($phpClasses[Dummy::class]); // "PHPClass"-object

Support

For support and donations please visit Github | Issues | PayPal | Patreon.

For status updates and release announcements please visit Releases | Twitter | Patreon.

For professional support please contact me.

Thanks

  • Thanks to GitHub (Microsoft) for hosting the code and a good infrastructure including Issues-Managment, etc.
  • Thanks to IntelliJ as they make the best IDEs for PHP and they gave me an open source license for PhpStorm!
  • Thanks to Travis CI for being the most awesome, easiest continous integration tool out there!
  • Thanks to StyleCI for the simple but powerfull code style check.
  • Thanks to PHPStan && Psalm for relly great Static analysis tools and for discover bugs in the code!

About

❤ Simple PHP Code Parser

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%