Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Refactoring legacy PHP app

Refactoring legacy PHP app

Nemanja Maric

April 25, 2022
Tweet

More Decks by Nemanja Maric

Other Decks in Programming

Transcript

  1. About me • PHP Developer at Orange Hill Development •

    Member of PHP Serbia Community • Co-organizer Laravel Serbia Meetup’s and PHP Serbia Meetup’s • Working with PHP since 2014 • In Laravel world from 2016 • Open source contributor • Contributing to the Laravel Framework • And most !important: Husband and father of two little angels
  2. It’s an old Laravel project started on Laravel 5.4 and

    PHP 5.6, upgraded to Laravel 6 (migrated 3 times) and PHP 7.3 Our goal is to run it on Laravel 9 (Up 3 major version) and PHP 8.1
  3. Rector 1. Instant Upgrades Rector now supports upgrades from PHP

    5.3 to 8.0 and major open-source projects like Symfony, PHPUnit, Nette, Laravel, CakePHP, Doctrine, PHPOffice and TYPO3 out of the box. Do you want to be constantly on the latest PHP/framework version without effort? Use Rector to handle instant upgrades for you. 2. Automated Refactoring Do you have code quality you need, but struggle to keep it with new developers in your team? Do you want to see smart code-reviews even when every senior developers sleeps? Add Rector to your CI and let it continuously refactor your code and keep the code quality high.
  4. Big complexity Poorly designed code is often complex and architecturally

    all off. Like it or not, that is only and only our mistake as developers. This is something that no tool can help you with, so let's dig in.
  5. Complexity is determined by the number of decision points in

    a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
  6. Lower complexity = less issues [Complexity] Having `classes` with more

    than 5 cyclomatic complexity is prohibited - Consider refactoring: TransformationController.php: 17 cyclomatic complexity
  7. How about to concat arrays and search both params to

    see if exist and to get the first one?!?