PHP code example of nxu / php-nano-class-parser
1. Go to this page and download the library: Download nxu/php-nano-class-parser library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nxu / php-nano-class-parser example snippets
$class = PhpClass::parse(
<<<'PHP'
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class LaravelModel extends Model
{
use HasFactory;
}
PHP
);
$imports = $class->analyze()->imports();
$imports->firstLine;
// 5
$imports->lastLine;
// 6
$imports->imports;
// [
// 'Illuminate\Database\Eloquent\Factories\HasFactory',
// 'Illuminate\Database\Eloquent\Model',
// ]
$class = \Nxu\PhpNanoClassParser\PhpClass::parse('...PHP source code...');
$class->analyze()->classDefinition();
$class->analyze()->classOutline();
$class->analyze()->firstFunction();
$class->analyze()->traits();
$class->analyze()->imports();