|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-07-07 21:37 UTC] stas@php.net
-Package: PHP Language Specification
+Package: *General Issues
[2016-07-08 06:15 UTC] requinix@php.net
[2016-07-13 01:42 UTC] kalle@php.net
[2016-07-13 01:44 UTC] kalle@php.net
-Status: Open
+Status: Verified
[2021-11-18 18:17 UTC] cmb@php.net
-Status: Verified
+Status: Suspended
[2021-11-18 18:17 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 20:00:02 2025 UTC |
Description: ------------ Currently, PHP have a function that returns the TOKENs of language (token_get_all), but if you wants to read AST, you should use some package like nikic/php-parser, and it have some specific problems: 1. It's slower than PHP AST because it reprocess code and implements it own lexer; 2. It should be updated together of PHP (currently not is a great problem because is very active); It should be done by own PHP, because it have all process that allows does that (I guess). Basically need some code to allow read it by code. But need some considerations: It should not implements a lot of classes, onde for each AST key. It should send raw parameters data to a processor that will decides how it will be parsed. Basically, I think that a raw array can solve that. Example: echo "Hello", "World"; Hello\World('Foo', 'Bar' . 'Baz'); Expectative: Note: simple values can stays as literals, array should specify the object key type (maybe the biggest problem). [ [ 'key' => 'echo', 'exprs' => [ 'Hello', 'World' ] ], [ 'key' => 'functionCall', 'name' => [ 'hello', 'world' ], 'args' => [ 'Foo', [ 'key' => 'concatenate', 'values' => [ 'Bar', 'Baz', ] ] ] ] ] And some limitations: It'll be PHP version dependent, it is, if I try to parse a 4.x PHP code it'll be impossible because of the PHP 7.1 code compatibility, in this case, the package can work on a polyfill. In same circunstancies, could be impossible, on PHP 7.1, parses a code fom PHP 7.2, so, polyfills too can solve that;