Skip to content

Instantly share code, notes, and snippets.

View frankdejonge's full-sized avatar

Frank de Jonge frankdejonge

View GitHub Profile
@frankdejonge
frankdejonge / getter.tpl
Created July 1, 2016 21:46
PHPStorm getter/setter templates.
#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>
### 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:
@frankdejonge
frankdejonge / keybase.md
Created March 26, 2016 14:23
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 July 30, 2015 10:12
Subdispatching commandbus
<?php
interface Subdispatchable {};
class SubdispatchingCommandBus extends CommandBus
{
public function handle($command)
{
$response = parent::handle($command);
@frankdejonge
frankdejonge / example.php
Created July 23, 2015 10:10
FTP to ZipArchive
<?php
$zipFilesystem = new Filesystem(new ZipArchiveAdapter($directory.'/zipname.zip'));
$ftpFilesystem = new Filesystem(new Ftp($ftpOptions));
$ftpFilesystem->addPlugin(new ListFiles);
$paths = $ftpFilesystem->listFiles($sourceDir, true);
foreach ($paths as $path) {
$stream = $ftpFilesystem->readStream($path);
@frankdejonge
frankdejonge / example.php
Created July 20, 2015 12:05
Concurrent upload to S3 buckets with Flysystem and pthreads
<?php
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
function get_filesystem() {
$client = new S3Client([
'credentials' => [
'key' => getenv('AWS_KET'),
<?php
class Any implements Specification
{
private $specifications = [];
public function __construct(array $specifications = [])
{
$this->specifications = $specifications;
}
@frankdejonge
frankdejonge / example.php
Created April 26, 2015 09:30
Streamed upload
<?php
$source = $_FILES['name']['tmp_name'];
$handle = fopen($source, 'r+');
$filesystem->writeStream('destination/file.txt', $handle);
if (is_resource($handle)) {
fclose($handle);
}
@frankdejonge
frankdejonge / failing-composer.json
Created April 7, 2015 14:04
Require doctrine/mbongodb without ext-mongo
{
"name": "frankdejonge/tester",
"require": {
"doctrine/mongodb": "*"
},
"minimun-stability": "dev",
"prefer-stable": true
}
<?php
class DomainListener
{
public function handle(EventInterface $event)
{
// PASS
}
public function handle(DomainEvent $event)