DPC2019: Refactoring Huge Legacy PHP Applications - From 100 hours to minutes - Tomáš Votruba

"Learn how to refactor legacy PHP applications efficiently using Rector, a static analysis tool, and discover how it can reduce code complexity, improve maintainability, and upgrade outdated PHP versions to modern standards."

Key takeaways
  • Legacy code is not a problem unique to PHP, every programming language has its legacy code.
  • 100 hours of refactoring reduced to minutes using Rector, a static analysis tool for PHP code.
  • Rector rewrites PHP code to newer standards, already supported in 7.4, with minimal manual effort required.
  • Use Rector to find and replace cache, debug, and refactor code, making it easier to maintain.
  • Legacy code often means outdated PHP versions, and Rector can facilitate upgrades to newer versions like 7.4.
  • When updating frameworks, Rector can automatically migrate between frameworks like Laravel, Symfony, and Zend.
  • Rector can also refactor complex code, reducing lines of code and making it more maintainable.
  • Code becomes legacy as soon as it is written, and refactoring regularly is essential to maintaining code quality.
  • The bigger the project, the more difficult it becomes to refactor and maintain.
  • Error-prone code can be replaced with more resilient code, improving code quality and preventing bugs.
  • Code review is essential, and Rector can automate code review, making it more efficient.
  • Annotations and type declarations can simplify code and make it easier to understand.
  • Fixes are often found in simple code, not complex code.
  • Legacy code can be refactored to modern standards in a short time with the help of Rector.
  • PHP 7.4 has a number of improvements, including improved error handling and type hints.
  • Code complexity can be reduced using Rector, making it easier to maintain.
  • The process of refactoring should not start from scratch, but from a baseline of existing code.