Skip to content

Instantly share code, notes, and snippets.

@orolyn
orolyn / overloading.php
Last active June 6, 2016 12:28
Emulated Overloading
<?php
/*
* DISCLAIMER: This is a benchmark, not a use case. Please forgive the rudimentary example below.
*
* The following demonstrates a relatively common implementation of overload emulation.
*
* The benchmark measures the overhead in counting the anonymous arguments
* and delegating the the respective function.
*
@orolyn
orolyn / typehint.php
Last active August 29, 2015 14:07
Concept of custom type hints
<?php
/**
* The typehint definition requires an implementation of ::evaluate.
* It accepts a reference to a value as an argument.
* From here an assertion can be performed, or the value can be modified.
*
* The visibility of the method and whether it is static or not may be irrelevant.
*/
typehint Int
<?php
/**
* Given a GearmanWorker and an instance of Job, run it
*
* @param \GearmanWorker $gearmanWorker Gearman Worker
* @param Object $objInstance Job instance
* @param array $jobs Array of jobs to subscribe
* @param integer $iterations Number of iterations
*