Skip to content

Instantly share code, notes, and snippets.

💡
Having idea's.

Frank de Jonge frankdejonge

💡
Having idea's.
Block or report user

Report or block frankdejonge

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View event-dispatcher.php
<?php
final class EventDispatcher {
private $listeners = [];
public function listen(callable $listener)
{
$this->listeners[] = $listener;
}
View emitter.php
<?php
interface EventDispatcher
{
public function listen(string $event, callable $listener);
public function emit(object $event): object;
}
class ExampleEventDispatcher implements EventDispatcher
{
@frankdejonge
frankdejonge / AssetLocator.php
Last active Oct 22, 2018
Asset locating in Symfony with cashed manifest contents.
View AssetLocator.php
<?php
namespace App\Twig;
interface AssetLocator
{
public function lookup(string $asset): string;
}
View IcuMessageSelector.php
<?php
namespace App\Translator;
use MessageFormatter;
use Symfony\Component\Translation\MessageSelector;
class IcuMessageSelector extends MessageSelector
{
/**
@frankdejonge
frankdejonge / compile.php
Created Mar 8, 2017
Symfony Routing optimisation.
View compile.php
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
include __DIR__.'/vendor/autoload.php';
if (count($argv) < 2) {
die('Not enough arguments');
@frankdejonge
frankdejonge / example.php
Last active May 21, 2017
Mirco-time precise DateTime(Immutable) instances.
View example.php
<?php
function mirco_time_precise_date_time_immutable()
{
return DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', microtime(true)));
}
@frankdejonge
frankdejonge / getter.tpl
Created Jul 1, 2016
PHPStorm getter/setter templates.
View getter.tpl
#set($returnType = ": $TYPE_HINT")
## First we check against a blacklist of primitive and other common types used in documentation.
#set($nonTypeHintableTypes = ["", "mixed", "number", "void", "object", "real", "double", "resource", "null"])
#foreach($nonTypeHintableType in $nonTypeHintableTypes)
#if ($nonTypeHintableType == $TYPE_HINT)
#set($returnType = "")
#end
#end
## Make sure the type hint actually looks like a legal php class name(permitting namespaces too) for future proofing reasons.
## This is important because PSR-5 is coming soon, and will allow documentation of types with syntax like SplStack<int>
View gist:2ba38d59493a6d5e7e28dc3b09915c80
### Keybase proof
I hereby claim:
* I am frankdejonge on github.
* I am frankdejonge (https://keybase.io/frankdejonge) on keybase.
* I have a public key whose fingerprint is CA93 AF44 7B62 E6F1 3EF5 EAA7 F466 19B5 44CB 2D17
To claim this, I am signing this object:
View keybase.md

Keybase proof

I hereby claim:

  • I am frankdejonge on github.
  • I am frankdejonge (https://keybase.io/frankdejonge) on keybase.
  • I have a public key whose fingerprint is A9BB 4EBC E96A 8E2C B27B 6A95 9F66 95E2 CF2D CDC0

To claim this, I am signing this object:

@frankdejonge
frankdejonge / example.php
Created Jul 30, 2015
Subdispatching commandbus
View example.php
<?php
interface Subdispatchable {};
class SubdispatchingCommandBus extends CommandBus
{
public function handle($command)
{
$response = parent::handle($command);
You can’t perform that action at this time.