PHPStan Playground: A Game-Changer for Drupal Developers
Matt Glaman has unveiled an initiative within the Drupal community—the impending launch of a PHPStan Drupal extension, termed "Playground." This extension is poised to become a practical testing tool for developers, offering a controlled environment to assess and refine Drupal code through the lens of PHPStan. Positioned as a valuable resource, the Playground aims to enhance code quality and mitigate potential issues, addressing a crucial aspect of the development process.
Scheduled for release by the end of November, the Playground for phpstan-drupal signifies an important evolution in the functionality of PHPStan. Serving as an online testing platform, it proves invaluable for analyzing and testing code results, especially in bug-reporting scenarios. Matt Glaman, the driving force behind phpstan-drupal, has addressed the financial considerations of this open-source project by securing sponsorship from OPTASY through GitHub Sponsors, ensuring the coverage of operating costs.
Deployed through the Serverless framework on AWS Lambda, the Playground comprises three integral components: a playground-runner, a public API (playground-api), and a website interface. These components work in tandem to execute PHP code with PHPStan configuration, facilitate user interaction, and store results in an S3 bucket. Glaman acknowledges the challenge of integrating phpstan-drupal with the drupal/core package in the vendor directory, anticipating longer execution times for the Playground due to fewer expected visits. Initial support will focus on analyzing code against the latest Drupal version, with plans for customization options in subsequent iterations.
Despite making significant progress, challenges persist, particularly in code analysis discrepancies. While certain configurations yield correct depreciation errors, others, involving the \Drupal class, present debugging hurdles. Glaman outlines plans to optimize the playground-api code, align it with Drupal core's supported PHP versions, and explore accommodating multiple Drupal core versions. The ongoing efforts aim to position the Playground as a valuable resource, catering to developers seeking effective ways to refine and test their Drupal code within the evolving landscape of PHPStan and Drupal development. Read more here.


