Refactoring
Martin Fowler
http://martinfowler.com/books/refactoring.html
Slide 15
Slide 15 text
“Legacy”
/leɡəsē/
• Requires an EOL version of PHP
• No automated tests
• Has outdated dependencies
• No autoloading
• No sign of “single responsibility”
Slide 16
Slide 16 text
No content
Slide 17
Slide 17 text
“Legacy”
We’ll assume
…means any code that
can be improved
@SammyK #zendcon2016 joind.in/talk/6d127
(at least for this talk)
ZERO
Step
@SammyK #zendcon2016 joind.in/talk/6d127
Slide 21
Slide 21 text
Around
Poke
@SammyK #zendcon2016 joind.in/talk/6d127
Slide 22
Slide 22 text
Around
Poke
• Composer &/or autoloading?
• Documentation? (Look for hidden docs!)
• Framework/Dependencies? (How out-dated?)
• How is database layer implemented?
• How is config handled?
• How are front-end assets handled?
• Are there tests?
• Production env (PHP version)
PHP 7.0 “Gotchas”
Uniform Variable Syntax
Notice: Array to string conversion in /
foo.php on line 6
Notice: Undefined variable: Array in /
foo.php on line 6
7.x
`iterable` pseudo-type
function foo(iterable $a)
{ /* */ }
PHP 7.1 considerations
$b = [];
foo($b);
class C implements Iterator {}
$b = new C;
foo($b);
Slide 131
Slide 131 text
`iterable` pseudo-type
PHP 7.1 considerations
class D implements IteratorAggregate {}
foo(new D);
Traversable
Or instance of
Slide 132
Slide 132 text
Some tools
I like
@SammyK #zendcon2016 joind.in/talk/6d127
Slide 133
Slide 133 text
vlucas/phpdotenv
.env
No peeking!
No peeking!
Slide 134
Slide 134 text
Some tools I like
pimple/pimple
@SammyK #zendcon2016 joind.in/talk/6d127
Slide 135
Slide 135 text
Some tools I like
monolog/monolog
@SammyK #zendcon2016 joind.in/talk/6d127
Slide 136
Slide 136 text
Some tools I like
nikic/fast-route
@SammyK #zendcon2016 joind.in/talk/6d127
Slide 137
Slide 137 text
Some tools I like
illuminate/database
@SammyK #zendcon2016 joind.in/talk/6d127
Slide 138
Slide 138 text
Some tools I like
symfony/console
@SammyK #zendcon2016 joind.in/talk/6d127
Slide 139
Slide 139 text
Create a PHP
application without a
framework
https://github.com/PatrickLouys/no-framework-tutorial
Patrick Louys
@SammyK #zendcon2016 joind.in/talk/6d127