GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - glayzzle/php-reflection: :mag_right: Nodejs Reflection API for PHP files based on the php-parser

BranchesTags
Open more actions menu

Latest commit

 

History

246 Commits
246 Commits

Folders and files

NameName
Last commit message
Last commit date
.vscode
.vscode
 
 
bin
bin
 
 
docs
docs
 
 
src
src
 
 
test
test
 
 
.coveralls.yml
.coveralls.yml
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
.istanbul.yml
.istanbul.yml
 
 
.jsbeautifyrc
.jsbeautifyrc
 
 
.jshintrc
.jshintrc
 
 
.npmignore
.npmignore
 
 
.travis.yml
.travis.yml
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
gruntfile.js
gruntfile.js
 
 
index.d.ts
index.d.ts
 
 
index.js
index.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

PHP Reflection

npm version Build Status Coverage Status Gitter

Nodejs Reflection API for PHP files based on the php-parser

Install

npm install php-reflection --save

Usage

var reflection = require('php-reflection');
var workspace = new reflection.Repository('/home/devbox/my-project', {
    // actual default options :
    exclude: ['.git', '.svn'],
    include: ['./'],
    ext: [
        '*.php','*.php3','*.php5','*.phtml',
        '*.inc','*.class','*.req'
    ],
    scanVars: true,
    scanExpr: true,
    encoding: 'utf8',
    cacheByFileSize: true
});
var workers = [
    workspace.parse('some-file.php'),
    workspace.parse('another-file.php'),
    workspace.parse('test-file.php')
];
Promise.all(workers).then(function() {
    console.log('-- list of functions :');
    workspace.getByType('function').each(function(fn) {
        console.log('Function Name : ', fn.name);
        console.log('Located into : ', fn.getFile().name);
        console.log('At line : ', fn.position.start.line);
    });
});

Read the API docs for more details.

What it can do

  • Fully reflection support (classes, inheritance, documentation blocks)
  • Recursively scan directories and add files to repository
  • Request cross files elements (like retrieving a class)
  • Put in-memory documents structure (with a small memory footprint)
  • You can use a cache engine for the repository
  • It avoids parsing a file that is already in memory and not modified since last parsing
  • Symbols relations (what variable instanciate a class, or who extends that class)
  • A cool (and really fast) requesting engine for retrieving elements

What you could do with it

  • Write a documentation generator
  • Write a static code generator based on relection (like an ORM)
  • Write a code analysis tool (like phpMessDetector)
  • Write a code completion plugin

... if you want to share an idea or your project make a pull request

Benchmark

WIP Disclaimer

This project is actually on it's early alpha stage. It may progress rapidly, so watch the project if you are interested to use it.

About

🔎 Nodejs Reflection API for PHP files based on the php-parser

glayzzle.com/php-reflection/

Topics

phpreflectionstatic-code-analysistooling

Resources

Readme
BSD-3-Clause license
Activity
Custom properties

Stars

28 stars

Watchers

6 watching

Forks

3 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.