Static Analysis and Automated Refactoring
Bought separately
Bundle Price

Static Analysis and Automated Refactoring

About the Bundle

As PHP developers we are living in the "Age of Static Analysis". We can use a tool like PHPStan to learn about potential bugs before we ship our code to production, and we can enforce our team's programming standards using custom PHPStan rules. Recipes for Decoupling by Matthias Noback teaches you in great detail how to do this, while also handing out many suggestions to pragmatically decouple your code from frameworks and libraries.

Rector is a tool built on top of PHPStan that is able to automatically improve your code by applying a large set of smart rules. You'll never have to manually upgrade your code base to the next PHP or framework version anymore, and you can apply better programming standards without spending weeks on manual changes. Rector - The Power of Automated Refactoring by Matthias Noback and Tomas Votruba gets you prepared for working with Rector, and makes you an instant power user by teaching you how to write custom code transformations for it.

  • Share this bundle
  • Categories

    • Refactoring
    • PHP
    • Laravel
    • Symfony
    • Zend
    • Software Engineering
    • Automated Software Testing
    • Web Development

About the Books

Rector - The Power of Automated Refactoring

  • 181


  • 100%


  • PDF

  • EPUB

  • WEB

Rector is an extremely powerful tool that can instantly improve the code quality of your PHP projects. It can be used to safely migrate projects from PHP 5.6 to PHP 8. It can help you establish a standard of robust programming practices in your project. And it can save you a lot of time spent on reviewing pull requests.

In this book, seasoned developers Matthias Noback and Tomas Votruba give you all the information you need to become a Rector power user. You'll learn:

  • How to make Rector part of your daily development workflow
  • How to create Rector rules that replace repetitive manual refactoring work
  • How to automate even more with Rector by adding it to your project's build process

Tomas, being the founding father and core maintainer of the Rector project, will shine his light on:

  • What's the place of Rector in the larger ecosystem of PHP tools for code quality assurance?
  • What role will Rector fulfill in the future?

Matthias, who has a strong focus on automated testing, will cover:

  • The concepts behind Rector: tokenizing, parsing, and manipulating PHP AST nodes
  • Test-driven development techniques for creating automated refactorings

What readers say

"I've been following Rector for a couple of years now. I've been very excited by the claims and demos but try as I might to get an understanding and a usable knowledge I just couldn't... until the book. Now within the space of a few days I have started to integrate Rector into a 20-year-old project (with a couple million lines of code) at work. My commits have increased, I have been able to find way more problems early on in code reviews, and I have started to clean up a lot of legacy spaghetti code.

Many thanks for the book, it has really really.... REALLY helped!"

-- Steve Hyde

"Grabbed my copy. This was an absolute nobrainer.

(one day later)

I already read through the whole thing. Nice work. Next step is to create some rules"

-- @psren

"The book is easy to read in a complex subject to me. Congrats both on your excellent work!!"

-- @KPikaza

"18 years ago, I bought my first technical book ever PHP 4 Bible. To master how to automatically refactor code using the same language on which it is written is something I could've not foreseen back then."

-- Oscar Nevarez

"I read most of the book already. Learned lots about the abstract syntax tree and how to create and test Rector rules. I can recommend any PHP developer to read this book!"

-- Tijmen Wierenga

"Purchased! My mind is already buzzing with ideas on how to use this on a legacy PHP project I just took over."

-- Joel Clermont

Recipes for Decoupling

  • 300


  • 100%


  • PDF

  • EPUB

  • WEB

Looking for a print edition? It's available on Lulu.

"Future me will appreciate it if I apply even just half of the recipes in this fantastic book. I learnt something new from every chapter and I can't wait to share some of these methods with my teams." Andrew Barlow

"Another excellent book from Matthias Noback! I learned a lot about techniques how to decouple your application from frameworks, test suites and other libraries. And the best part: it showed me how to unleash the power of PHPStan with custom rules to make sure you stay decoupled." Stefan Blanke

Software is never done. The world around your program changes faster than you want it to. Frameworks and libraries are abandoned and replaced with something better (or just something new), so you need to migrate. You can postpone this work for a bit, but eventually you'll have to catch up, or your project may end up hopelessly outdated. I'm sure you know one or two of those projects!

How can you make all of this easier for yourself and the future maintainers of the project? The keyword is "decoupling". You can change the design of your code to defend it against changes in any dependency your project relies on. Decoupling your code is a way to make it future-proof (without doing too much work that "you ain't gonna need").

About 10 years ago I started looking for ways to decouple my code, but at first I struggled to do it effectively. My code was decoupled in the wrong places, or in the wrong way. I got a better view on this topic after several intense experiences with some legacy projects, a big framework migration, and a complete project rewrite (that I'm sure could have been prevented). I've collected many recipes for decoupling along the way. This book gives you a practical overview of common situations that suffer from an often unintended high level of coupling in web applications. Of course, it also gives you step-by-step recipes to improve these situations. The examples in this book show you how to decouple from your web framework, templating engine, test framework, ORM, and so on.

Decoupling is one thing, but staying decoupled is something else entirely. That's why in this book we focus on how to solidify the decoupling rules with PHPStan, the automated static analysis tool for PHP. That way we don't have to rely on discipline and code reviews, but can let a tool point out possible coupling mistakes.

"Have you ever wondered how to efficiently decouple from your PHP framework? And how to enforce it through tooling? I did! And Recipes For Decoupling delivered me very well thought out explanations, examples and snippets for decoupling. It even explains step by step how to enforce these decoupling rules through PHPStan rules. The book contains examples from a variety of popular PHP frameworks including Symfony, Laravel, Mockery and PHPUnit." - Vincent Hagen

"'Decoupling' is a delightful read that merits a slow read because you will want to stop and code after every chapter! Noback’s clarity and honesty is welcome in an era of big personalities, as is his ability to distill framework concepts to elegant code." - Matthew Gatner

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub