Skip to content

Instantly share code, notes, and snippets.

View maks-rafalko's full-sized avatar

Maks Rafalko maks-rafalko

View GitHub Profile
<?php
interface SalaryInterface {
public function getSalary(): float;
}
class DynamicStrategy implements SalaryInterface {
/**
* @var int
*/
@maks-rafalko
maks-rafalko / MaskSecretsLineFormatter.php
Created October 8, 2019 05:39
Symfony: do not log secrets (custom Monolog Formatter) to avoid secrets disclosure
<?php
declare(strict_types=1);
namespace Core\Monolog\Formatter;
use Doctrine\DBAL\Connection;
use Monolog\Formatter\LineFormatter;
/**
// 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;
- });
@maks-rafalko
maks-rafalko / books-for-php-developer.md
Last active July 18, 2022 16:04
Books for PHP developer from Junior to Senior

Литература для рекомендации

Junior

  • Документация PHP - http://php.net/
  • http://www.phptherightway.com/
  • Мэт Зандстра "PHP. Объекты, шаблоны и методики программирования" ISBN 978-5-8459-1922-9
  • Мартин. Чистый код.
// 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]);
// 1. in the loop
foreach ($someVar as $record) {
// ...
- break;
+ continue;
}
// 2. in the switch statement
// 1. spaceship operator
- $a <=> $b;
+ $b <=> $a;
// 2. break; <-> continue;
foreach (...) {
- break;
+ continue;
<?php
class Addition extends MutatorAbstract
{
public static function getMutation(array &$tokens, $index)
{
$tokens[$index] = '-';
}
public static function mutates(array &$tokens, $index)
{
<?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
{