This file contains 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 | |
$server = socket_create(AF_INET, SOCK_STREAM, 0); | |
socket_bind($server, '127.0.0.1', '9090'); | |
socket_set_nonblock($server); | |
socket_listen($server); | |
$selectSockets = [$server]; | |
$null = null; |
This file contains 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 | |
$input = [10,20,40,60,100]; | |
$result = []; | |
$first = false; | |
foreach ($input as $item) { | |
if (false === $first) { | |
$first = $item; | |
continue; |
This file contains 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 | |
// A Action | |
$em = $this->getDoctrine()->getMamanger(); | |
$em->persist($objectA); | |
$em->flush() | |
// B Action | |
$em = $this->getDoctrine()->getMamanger(); | |
$em->persist($objectB); |
This file contains 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 | |
new SomeKindAction(new SomeKindAction(new SomeKindAction(..new SomeKindActionWhich gives array()))); |
This file contains 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 | |
// Before | |
$em = $this->getDoctrine()->getManager(); | |
$em->persist($input); | |
$em->flush(); | |
$data = $this->getDataMapper()->map($input); | |
$client = $this->getElasticSearch()->index('index', 'type', $data); |
This file contains 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 | |
function actions($input) | |
{ | |
return new PipelineAction( | |
$input, | |
new SomeAction(), | |
new OtherAction() | |
); | |
} |
This file contains 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 | |
function actions($input) | |
{ | |
return new SequalAction( | |
new DoctrinePersitAction($input), | |
new ElasticSearchIndexAction('index', 'type', new DataMapAction('mapper', $input)), | |
new RedisCacheAction('some:data:' . $input->getId(), $input) | |
) | |
} |
This file contains 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 | |
use Symfony\Component\Finder\Finder; | |
use Symfony\Component\Finder\SplFileInfo; | |
require_once __DIR__ . '/vendor/autoload.php'; | |
$groups = ['Collection', 'String', 'Objects']; | |
foreach ($groups as $groupName) { |
This file contains 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 /tmp/a.php | |
PHP TypeError: Argument 1 passed to a() must be callable, string given, called in /private/tmp/a.php on line 8 in /private/tmp/a.php on line 3 | |
PHP Stack trace: | |
PHP 1. {main}() /private/tmp/a.php:0 | |
PHP 2. a() /private/tmp/a.php:8 | |
TypeError: Argument 1 passed to a() must be callable, string given, called in /private/tmp/a.php on line 8 in /private/tmp/a.php on line 3 | |
Call Stack: |
This file contains 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
require "logger" | |
module Apple | |
class Logger < ::Logger | |
attr_accessor :program_name, :debug | |
def initialize program_name, save_logs, log_file, log_level | |
if save_logs | |
super(log_file) | |
else | |
super(STDOUT) |