hhvm/hhast
最新稳定版本:v4.168.3
Composer 安装命令:
composer require hhvm/hhast
包简介
A mutable AST library for Hack with linting and code migrations
README 文档
README
HHAST is a toolkit for processing the AST of Hack files.
Abstract syntax trees can be an extremely powerful basis for many kinds of tooling beyond compilers and optimization; HHAST is built on top of Hack's Full Fidelity Parser (FFP), providing a Hack object representation of a mutable AST.
Unlike traditional ASTs, the FFP's AST includes all 'trivia' - such as whitespace and comments - allowing you to fully recreate the file from the AST, or create an updated file after mutating the AST, preserving comments and whitespace.
HHAST has 3 main APIs:
- a low-level library for inspecting and manipulating the FFP AST
- a linting framework, with support for auto-fixing linters
- a migration framework
Linters
Linters are designed for subjective or style changes which do not substantially alter the behavior of the code, and may be rejected on a case-by-case basis. Lint errors can provide a suggested fix, which may be based on an AST mutation, but doesn't have to be.
We've included several linters as a starting point, including:
- don't use await in a loop
- methods should be ->lowerCamelCase(), functions should be under_scored()
- always use braces for control flow
- always use
<<__Override>>where possible
Linters can be used both interactively, or unattended. Autofixing is not supported unattended, however it will exit with non-zero if there are any lint issues, to ease integration with CI systems.
Editor and IDE Support
HHAST is supported by:
- ALE for Vim 8 and neovim
- atom-ide-hhast for Atom IDE and Nuclide
- vscode-hack for Visual Studio Code
Migrations
- user documentation
- most of the linters developer documentation applies for migrations too
Migrations are for sweeping changes you want to apply across your entire codebase, and are often more complex. Taking this into account, the migration framework has built-in support for multi-step migrations (unlike linters). AST-aware migrations can be a powerful tool for:
- adjusting for changes to the language (for example, the shape changes described below)
- replacing deprecated APIs with new ones
- general clean-up of the codebase
Low-level AST library
See the documentation.
License
HHAST is MIT-licensed.
hhvm/hhast 适用场景与选型建议
hhvm/hhast 是一款 基于 Hack 开发的 Composer 扩展包,目前已累计 1.03M 次下载、GitHub Stars 达 69, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hhvm/hhast 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hhvm/hhast 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.03M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 69
- 点击次数: 34
- 依赖项目数: 71
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04


