Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/php/pecl-php-parsekit
PHP Opcode Analyser
https://github.com/php/pecl-php-parsekit
Last synced: 5 days ago
JSON representation
PHP Opcode Analyser
- Host: GitHub
- URL: https://github.com/php/pecl-php-parsekit
- Owner: php
- Archived: true
- Created: 2013-03-02T18:04:32.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-03-02T20:56:27.000Z (over 11 years ago)
- Last Synced: 2024-04-13T21:53:28.868Z (6 months ago)
- Language: C
- Homepage: http://pecl.php.net/package/parsekit
- Size: 140 KB
- Stars: 15
- Watchers: 7
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
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.