GithubHelp home page GithubHelp logo

classicvalues / pecl-php-parsekit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from php/pecl-php-parsekit

1.0 1.0 0.0 44 KB

PHP Opcode Analyser

Home Page: http://pecl.php.net/package/parsekit

PHP 0.76% C 99.24%

pecl-php-parsekit's Introduction

parsekit: PHP Opcode Analyser

Provides a userspace interpretation of the opcodes 
generated by the Zend engine compiler built into PHP.

This extension is meant for development and debug 
purposes only and contains some code which is 
potentially non-threadsafe.

This extension exports two functions 
(parsekit_compile_string(string phpcode[, array &errors]) 
and parsekit_compile_file(string filename[, array &errors])) 
which will attempt to compile one or more blocks of PHP 
code into Zend opcodes.  

The output of these functions is an n-depth hash containing 
the main block of code's oparray at its root, with 
function_table and class_table elements to hold any functions 
or classes declared within the compiled code.

In order to accomplish these compilation steps within 
the context of an active execution, some potentially unsafe
methods are used.

1) Compilation modifies EG(function_table) and EG(class_table),
   after compilation completes, parsekit pops these functions
   and classes off the end of these stacks.

2) To avoid parse errors in supplied code causing a zend_bailout(),
   parsekit replaces zend_error_cb with a wrapper which passes E_CORE_ERROR
   or any error which occurs outside of parsekit_compile_*() onto
   the original zend_error_cb.  If another module which replaced
   zend_error_cb were to be loaded prior to parsekit, then unloaded
   after parsekit's startup, but prior to parsekit's shutdown, then
   the global value zend_error_cb could become populated with an
   invalid function pointer.

The moral of the story:  Use this at your own risk.

This extension also exports constant entries for all class types,
function types, node types, and opcodes.  While a name collision
would be unexpected, all constants are prefixed with PARSEKIT_
just to be safe.

Example:

#define ZEND_NOP	0

Exported as:

REGISTER_LONG_CONSTANT("PARSEKIT_ZEND_NOP",	0, CONST_CS | CONST_PERSISTENT);

For examples on usage, refer to the examples subdirectory in this package.

pecl-php-parsekit's People

Contributors

sgolemon avatar scoates avatar johannes avatar sebastianbergmann avatar auroraeosrose avatar felipensp avatar fmk avatar pierrejoye avatar

Stargazers

Classic Values avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.