Python Get PHP-AST
Install
pip install php-ast
exapme
# get bytes php code ast
from php_ast import php_ast
php_ast=php_ast()
php_ast.get_ast(b"<?php phpinfo();?>")
{'status': 'successed', 'ast': {'kind': 'AST_STMT_LIST', 'flags': 0, 'lineno': 1, 'children': [{'kind': 'AST_CALL', 'flags': 0, 'lineno': 1, 'children': {'expr': {'kind': 'AST_NAME', 'flags': 1, 'lineno': 1, 'children': {'name': 'phpinfo'}}, 'args': {'kind': 'AST_ARG_LIST', 'flags': 0, 'lineno': 1, 'children': []}}}]}}
# get php file ast
from php_ast import php_ast
php_ast=php_ast()
php_ast.get_file_ast("/home/11.php")
{'status': 'successed', 'ast': {'kind': 'AST_STMT_LIST', 'flags': 0, 'lineno': 1, 'children': [{'kind': 'AST_CALL', 'flags': 0, 'lineno': 1, 'children': {'expr': {'kind': 'AST_NAME', 'flags': 1, 'lineno': 1, 'children': {'name': 'phpinfo'}}, 'args': {'kind': 'AST_ARG_LIST', 'flags': 0, 'lineno': 1, 'children': []}}}]}}
说明
- 本项目是基于php-ast扩展的python模块,用于获取php代码的ast树
- 暂时只支持Linux 系统
参考:
Metadata
Release files for php-ast 1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| php_ast-1.5.tar.gz | 4.0 MB | Without provenance | Details for php_ast-1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| php_ast-1.5-py3-none-any.whl | Python 3 | none | any | Details for php_ast-1.5-py3-none-any.whl |
Total release size: 8.1 MB
Release files / php_ast-1.5.tar.gz
| Download URL | php_ast-1.5.tar.gz |
|---|---|
| Size | 4.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47112778ae23754c0c6696901040c77da3790d355ddb2b11e7ab94b08f70b3cf
|
|
BLAKE2b-256 checksum How to use checksums |
89b6243f17a73d19b944a2497b2275f236b2f969e56c88542a310e8c04a3b03c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.9
|
Release files / php_ast-1.5-py3-none-any.whl
| Download URL | php_ast-1.5-py3-none-any.whl |
|---|---|
| Size | 4.0 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e7c032f96b90152b9bb3c9da5908d0e273082702aad1c310d499a83e0353a387
|
|
BLAKE2b-256 checksum How to use checksums |
bcdedf6082610bfd7bb2e84f2eaadcfb6fa62e978a62595c1c43e5d0bbe25f88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.9
|
Security for php-ast 1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.