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

Using PHP 7 in the wild

Using PHP 7 in the wild

Not all of us have the luxury of working with PHP 7 at our day jobs. Luckily, some of us do. This talk will show off pretty interesting benefits for the PHP developers and their managers. PHP 7 lets us do more with less and this talk will get you started in the right direction.

Jan-Marten is an E-commerce developer at MediaCT. His main focus is to work securely with huge amounts of confidential data. He loves to talk about software architecture. A Magento 2 critic, Symfony 3 lover, BIG data hugger and evangelist of PHP 7

Jan-Marten de Boer

October 06, 2016
Tweet

Other Decks in Programming

Transcript

  1. Rock concert movement #1 Jan-Marten de Boer • E-commerce developer

    • Symfony 3 lover • Magento 2 critic • BIG data hugger • Co-author of HylianShield validator • Evangelist of PHP 7
  2. What is the HylianShield Validator? $ A layer between your

    application and data $ The easiest solution to creating a custom validator $ 100% code coverage through sane unit tests $ Supports PHP 5.3, 5.4, 5.5, 5.6, 7
  3. Our focus $ Type hinting $ Return types $ Interfaces

    $ Anonymous classes $ Source code reduction $ Test code reduction $ Single responsibility principle $ Removing validators $ Mediator pattern $ Cyclomatic complexity + Code + Code + Code + Code - Code - Code - Code - Code - Code
  4. PHP 7 is ready $ It is waiting for you

    to make your life awesome. Are you ready?
  5. Anonymous classes $ Optional constructor $ No code base addition

    $ New instances of the same anonymous class are equal $ Less of vague mock objects
  6. Source code reduction $ Removing InvalidArgumentException $ Removing UnexpectedValueException $

    Argument unpacking ... $ Removing features without removing features
  7. Test code reduction $ Less exception checks $ Less data

    providers $ Less mock objects $ Less Reflection* entities $ Less assertInstanceOf and more return types
  8. “Perfection is achieved, not when there is nothing more to

    add, but when there is nothing left to take away.” - Antoine de Saint-Exupery
  9. Cyclomatic complexity Version 0.9.0 with PHP 5.3 support Highest cyclomatic

    complexity: 15 Version 2.1.0 with PHP 7 support Highest cyclomatic complexity: 3
  10. Thanks! Contact me: @johmanx10 [email protected] References $ https://wiki.php.net/rfc/argument_unpacking $ https://wiki.php.net/rfc/return_types

    $ https://wiki.php.net/rfc/scalar_type_hints $ http://php.net/manual/en/language.oop5.anonymous.php $ https://sourcemaking.com/design_patterns/mediator $ https://en.wikipedia.org/wiki/Single_responsibility_principle $ http://php.net/manual/en/book.reflection.php $ https://phpmd.org/rules/codesize.html#cyclomaticcomplexity Books ✍ Principles of Package Design - Matthias Noback