Skip to content

Instantly share code, notes, and snippets.

@romac
Created November 11, 2009 13:20
Show Gist options
  • Select an option

  • Save romac/231940 to your computer and use it in GitHub Desktop.

Select an option

Save romac/231940 to your computer and use it in GitHub Desktop.
A PHP 5 class miming Objective-C's nil object.
<?php
/*
* Copyright (c) 2009, Romain Ruetschi <[email protected]>
* Code licensed under the BSD License:
* See http://opensource.org/licenses/bsd-license.php
*/
final class RRNil
{
private static $_instance = NULL;
public static function getInstance()
{
if( !is_object( self::$_instance ) )
{
self::$_instance = new self();
}
return self::$_instance;
}
private function __construct()
{
}
public function __clone()
{
return $this;
}
public function __wakeup()
{
return $this;
}
public function __get( $name )
{
return $this;
}
public function __set( $name, $value )
{
return $this;
}
public function __isset( $name )
{
return FALSE;
}
public function __unset( $name )
{
return;
}
public function __call( $methodName, $arguments = array() )
{
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment