1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

PHPStan integration and implications for the PocketMine-MP ecosystem

Discussion in 'Contributing & RFCs' started by dktapps, Feb 10, 2020.

  1. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    It's been a while since I wrote one of these.

    Anyone watching development may have noticed that the rate of actual development has significantly dropped in recent months. This is because of two things:
    1. my lack of a PC is slowing me down, and
    2. most importantly, all of my available time for PM development in recent months has been spent on integrating PHPStan into our CI.

    What is PHPStan?
    For those of the community who aren't familiar with the PHP landscape outside of PM, PHPStan is a fantastic static analyser for PHP code. It finds entire classes of bugs in your code without ever running it.

    Great, you fixed a few bugs. Is that all?
    As you might have guessed from my writing this post, integration of PHPStan is a much bigger deal than just fixing a handful of core bugs.

    Permanently raising the quality bar.
    Going forward, an entire class of bugs will no longer reach production, thanks to PHPStan integration into our Travis CI builds. This means that Travis failures will actually show problems with the code now.

    Saving a LOT of maintainer time and effort on trivial stuff.
    The development process can become much more efficient when we don't have to worry about undefined variables or passing the wrong arguments to a function.

    Making it far, far easier to deal with (and accept) third party contributions (pull requests).
    This package of joy comes with quite a few flavours.
    • PHPStan provides fast, objective feedback on code. The negative impact of needing human reviewers, who are imperfect and sometimes take days to respond, to find simple errors in code, cannot be understated. Contributors and reviewers both can get frustrated by the drawn-out back-and-forth review-fix-review-fix process, so discussions can get heated. Having an automated tool to reduce this problem will make PR contribution flow much faster and more cordial.
    • Maintainers don't need to spend as much effort reviewing code. This is a big deal, because there aren't a lot of core maintainers (right now, I'm the only particularly active one), and my time is in short supply. PHPStan enables reviewers to look for actual bugs instead of worrying about undefined stuff.
    Far too often, maintainers have had to reject PRs from outside contributors. In a lot of cases, this has been simply because the time and effort spent on making such PRs conform to our quality standards was less than just redoing such changes ourselves, or simply rejecting the PR.

    Having PHPStan in the mix of this should make it significantly easier for both contributors and reviewers.

    Improvements to the plugin ecosystem.
    There is talk of integrating PHPStan into Poggit CI, which would significantly improve the usefulness of the linting tool. Given that Poggit CI is heavily used by public plugins, this could result in significant quality improvements in public plugins, improving experience for server owners.

    In the meantime, plugin developers are actively adopting this tool on their own and starting to realize some of the same benefits.

    Where can I learn more about PHPStan?
    You can learn more by visiting its GitHub repository at https://github.com/phpstan/phpstan.
     
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    So... What's the point of this thread other than showing your love for phpstan? Is this just documenting your motivation for reference, or are you suggesting something further?
     
  3. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    Advance TL;DR: I want to attract contributors.

    Historically, we have been very unforgiving to contributors because of the high cost of manual code review. This has led to a culture of "I'm not good enough to contribute" mindsets, or "PMMP is too strict about quality".

    The reality is that we have previously been less strict than most other OSS PHP projects, while also being much less effective at CR and QA than most other projects because all review was being done manually by humans.

    Now that we have PHPStan in place, it should become much easier for contributors to meet the quality & standards requirement with much less work for everyone involved.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.