- Theo Fidry https://twitter.com/tfidry
- PHP UG Dresden, Germany https://www.youtube.com/watch?v=dlVASJ-MbUE
- PHP Barcelona, Spain https://www.youtube.com/watch?v=GRB0sTweUVY
- PHPDay (Italy) https://vimeo.com/274779478
- Badoo PHP Meetup, Moscow
- Maks Rafalko https://twitter.com/maks_rafalko
- Onliner PHP Meetup 2019 (Minsk, Belarus)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface SalaryInterface { | |
public function getSalary(): float; | |
} | |
class DynamicStrategy implements SalaryInterface { | |
/** | |
* @var int | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace Core\Monolog\Formatter; | |
use Doctrine\DBAL\Connection; | |
use Monolog\Formatter\LineFormatter; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// array_map | |
- $lowercasedStrings = array_map(['P', 'H', 'P'], function ($v) { | |
- return strtolower($v); | |
- }); | |
+ $lowercasedStrings = ['P', 'H', 'P']; | |
// array_filter | |
- $evenNumbers = array_filter([1, 2, 3, 4], function ($v) { | |
- return $v % 2; | |
- }); |
Литература для рекомендации
- Документация PHP - http://php.net/
- http://www.phptherightway.com/
- Мэт Зандстра "PHP. Объекты, шаблоны и методики программирования" ISBN 978-5-8459-1922-9
- Мартин. Чистый код.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Throw_ Mutator | |
- throw new FileNotFoundException('...'); | |
+ new FileNotFoundException('...'); | |
// DecrementInteger Mutator | |
- new Assert\Length(['min' => 10]); | |
+ new Assert\Length(['min' => 9]); | |
// IncrementInteger Mutator | |
- new Assert\Length(['min' => 10]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. in the loop | |
foreach ($someVar as $record) { | |
// ... | |
- break; | |
+ continue; | |
} | |
// 2. in the switch statement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. spaceship operator | |
- $a <=> $b; | |
+ $b <=> $a; | |
// 2. break; <-> continue; | |
foreach (...) { | |
- break; | |
+ continue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Addition extends MutatorAbstract | |
{ | |
public static function getMutation(array &$tokens, $index) | |
{ | |
$tokens[$index] = '-'; | |
} | |
public static function mutates(array &$tokens, $index) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Plus implements Mutator | |
{ | |
public function mutate(Node $node) | |
{ | |
return new BinaryOp\Minus($node->left, $node->right, $node->getAttributes()); | |
} | |
public function shouldMutate(Node $node) : bool | |
{ |
NewerOlder