Skip to content

Instantly share code, notes, and snippets.

View .vimrc
" force utf-8 mode
scriptencoding utf-8
" i got 99 problems, but utf-8...
set encoding=utf-8
call plug#begin('~/.vim/plugged')
Plug 'airblade/vim-gitgutter'
View EmailAddress.php
namespace Acme\Domain\Type;
use function Assert\that;
class EmailAddress
/** @var string */
shadowhand / # php - 2018-04-04_13-56-32.txt
Created Apr 4, 2018
php on macOS 10.13.3 - Homebrew build logs
View # php - 2018-04-04_13-56-32.txt
Homebrew build logs for php on macOS 10.13.3
Build date: 2018-04-04 13:56:32
shadowhand / array_chunk_fixed.php
Created May 25, 2017
Array chunking for SplFixedArray
View array_chunk_fixed.php
// Copyright (c) 2017 Woody Gilk (@shadowhand)
// MIT License
* A chunking function for SplFixedArray
* Operates the same as array_chunk() but without $preserve_keys, for obvious reasons.
View JsonStreamParser.php
namespace Acme;
use Bcn\Component\Json\Reader;
use Generator;
class JsonStreamParser
shadowhand / NamedDTO.php
Created Dec 10, 2016
Using named constructors for data transfer objects
View NamedDTO.php
namespace Acme;
class DataTransfer
public static function forUser(
) {
return new static($user_id);
shadowhand /
Created Nov 29, 2016 — forked from mindplay-dk/
Complete overview of the PHP SessionHandler life-cycle

This page provides a full overview of PHP's SessionHandler life-cycle - this was generated by a set of test-scripts, in order to provide an exact overview of when and what you can expect will be called in your custom SessionHandler implementation.

Each example is a separate script being run by a client with cookies enabled.

To the left, you can see the function being called in your script, and to the right, you can see the resulting calls being made to a custom session-handler registed using session_set_save_handler().

shadowhand / NamedCallable.php
Last active Nov 18, 2016
Execute any method, static or instance, as a callable
View NamedCallable.php
namespace Acme;
class NamedCallable
private $invoke;
private $prefix;
public function __construct(callable $invoke, callable $prefix)
shadowhand / RouteInterface.php
Last active May 16, 2017
Routing interfaces for standards discussion
View RouteInterface.php
interface RouteInterface
* Get the HTTP method this route handles.
* @return string
public function getMethod();
View delegates.php
// current proposal
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
// ...
return $delegate->process($request);
// alternative
public function process(ServerRequestInterface $request, DelegateInterface $next)