#2517·larastan

Installing `phpmyadmin/sql-parser` breaks squashed migration parsing

Author: FeBe95Created Jul 21, 2026Updated Jul 21, 2026
Labelsbug
  • Larastan Version: 3.9.6
  • Laravel Version: 12.64.0

Description

We installed phpmyadmin/sql-parser while working on a new feature in our project. Immediately afterwards, PHPStan started reporting more than 8,000 new errors.

After some debugging, we discovered that Larastan automatically uses phpmyadmin/sql-parser whenever it is installed. Unfortunately, if the parser fails to parse a schema dump, the exception is silently suppressed:

https://github.com/larastan/larastan/blob/9ad17e83e96b63536cb6ac39c3d40d29ff9cf636/src/SQL/PhpMyAdminSqlParser.php#L23-L25

https://github.com/larastan/larastan/blob/9ad17e83e96b63536cb6ac39c3d40d29ff9cf636/src/Properties/SquashedMigrationHelper.php#L67-L70

In our case, the schema dump was generated by MariaDB, and the parser throws the following exception:

The name of the CTE was expected.

Because the exception is swallowed, Larastan falls back to an incomplete state, resulting in a large number of seemingly unrelated analysis errors that are difficult to diagnose.

Proposed solution

  • Add a configuration option to explicitly enable or disable the use of phpmyadmin/sql-parser. This would allow projects to depend on the package for other purposes without Larastan automatically using it.
  • Surface the parser exception as an analysis error (or otherwise report it) instead of suppressing it silently. This would make the root cause much easier to identify.