ADT_Null Demo

This is a demo for class ADT_Null which is a simple data type provided by cmClasses

The object

This is the original ADT_Null instance, a very empty object.
$null = ADT_Null::getInstance() Dump: object(ADT_Null)#2 (0) {}

... is NULL?

ADT_Null is NOT equal to NULL. This is handy for applied object operations.
is_null( $null ) Returns: bool(false)

Typing ...

... to boolean

Boolean intepretation is TRUE since ADT_Null should be used as a positive result which is just empty.
(boolean) $null Dump: bool(true)

... to array

Providing an empty array is handy for applied array operations.
(array) $null Dump: array(0) {}

... to string

ADT_Null converts to an empty string by magic call. This is handy for string operations.
(string) $null Dump: string(0) ""

... others

Typing to integer, float etc. fails.

Accessing ...

... members

Reading member variables will always return the null object again.
echo $null->a; Dump: object(ADT_Null)#2 (0) {}

Setting member variables can be done without any error but WILL NOT store the given value.

$null->a = array( 2, 3 )

... as array

Reading the null object like an array will always return the null object again.
$null["a"] Returns: object(ADT_Null)#2 (0) {} Writing the null object like an array will have no effect.
$null["a"] = 3

... methods

All method calls on this object will do nothing but return the null object again.
$null->a() Returns: object(ADT_Null)#2 (0) {}

Interfaced ...

... using count() [Interface Countable]

Count always should be 0.
count( $null ) Dump: int(0)

... render() [Interface Renderable]

Renders always to empty string.
Dump: $null->render() Dump: string(0) ""