Matt Brown

@mattbrowndev@mastodon.social

One unambiguously good thing PHP project could would be to port the parser to Rust, which would unlock the potential for lightning-fast static analysis. Right now anyone venturing into a PHP-specific compiled language tooling has to also write and maintain their own parser, which is out of reach of basically everyone except JetBrains.

July 12, 2025 at 7:00:42 PM
Web

I mean, I don't really understand our YACC parser, but I think the main aversion is that we would require a new toolchain which is less "common" and doesn't support all architectures (because people smh use PHP on embedded devices)

But I think that would be neat, I know @pollita was at one point playing around with Rust to make a PHP parser.

@Girgias @mattbrowndev

I did take a whack at this recently, but grmtools was immature and I couldn't find anything better.

I invite anyone who'd like to prove (a) that it's significantly faster to justify having an additional compile complexity, and (b) that it's doable at all.

@pollita @Girgias yeah I don’t think there’s a speed boost to be had — it’s more about the potential speed improvements for tooling (e.g. my all-Rust tool can analyse Hack code 7x faster than similar tooling written in PHP). That speedup would only be important for codebases > 100KLOC though, and given the tools don’t exist it’s a purely theoretical improvement.

@mattbrowndev @pollita Mago which is a new SA tool written by @azjezz in Rust is incredibly speedy.

I think they plan to release the analyser as an individual crate.

@Girgias @pollita @[email protected] though that gets into the other issue, that PHP static analysis is tricky due to magic methods, which traditionally (aka since we started creating SA tools) has been handled with custom PHP extensions performing dynamic reflection. A pure static analysis tool would not be a fit for how PHP is used at most places.

@mattbrowndev @pollita magic methods are truly the bane of existence 😔

@Girgias @pollita could the runtime be made measurably faster in configurable switch turning off magic methods in php.ini?

Elk Logo

Welcome to Elk!

Elk is a nimble Mastodon web client. You can login to your Mastodon account and use it to interact with the fediverse.

Expect some bugs and missing features here and there. Elk is Open Source and we're actively improving it as a community project. Join us and let's build it together!

If you'd like to report a bug, help us testing, give feedback, or contribute, reach out to us on GitHub and get involved.

To boost development, you can sponsor the Team through GitHub Sponsors. We hope you enjoy Elk!

三咲智子 Kevin DengAnthony FuPatakTAKAHASHI ShuujiDaniel RoeJoaquín Sánchez

The Elk Team