Skip to content

Instantly share code, notes, and snippets.

View GodsBoss's full-sized avatar

Timo Reitz GodsBoss

View GitHub Profile
@GodsBoss
GodsBoss / yiiDetachAllEventHandlers.php
Last active August 29, 2015 14:04
Yii: Detaching all event handlers
<?php
class FooHandling extends CComponent
{
public function onFoo($event) {}
}
function handlerOne($event){}
function handlerTwo($event){}
missingNumber = ((v)->
(n)->
v[n] ?0)
2:10
3:15
4:22
5:31
6:42
8:666
@GodsBoss
GodsBoss / gist:1180970
Created August 30, 2011 14:07
A PHP FizzBuzz variant.
<?php
// For the original version, see
// http://forum.golem.de/read.php?54793,2785037,2785926#msg-2785926
$a = array(0,
'fizz',
'buzz',
'fizzbuzz' ) ;
@GodsBoss
GodsBoss / gist:999405
Created May 30, 2011 20:15
Constructor signature
<?php
interface Something{}
interface AnotherThing{}
class Foo{
public function __construct(Something $thing){}
public function foo(Something $thing){}}
// No problem.
@GodsBoss
GodsBoss / gist:960745
Created May 7, 2011 19:06
Access to protected base class members of a subclass via another subclass.
<?php
class Base{
protected $x;
public function getX(){
return $this->x;}}
/**
* This class tries to ensure that $x is always an integer.
@GodsBoss
GodsBoss / gist:923547
Created April 16, 2011 22:07
Verschiedene Implementierungen einer Client-Klasse mit einer optionalen Abhängigkeit.
<?php
/**
* Something the Client may depend on or not.
*/
interface Dependency{
public function action();}
/**
* The Client.