settype() has some really strange, potentially buggy behavior.
As noted by Michael Benedict, using settype() on a variable will initialize that variable. What is stranger is that using settype() on an uninitialized variable that you are treating as an array or object will also initialize the variable. So:
<?php
settype($foo->bar,"integer"); ?>
This works for a chain of any length: $foo->bar['baz']->etc
Next we look at what happens if $foo is already set.
<?php
$foo = false;
settype($foo->bar,"integer"); ?>
In and of itself, this wouldn't be problematic. It might even make sense. But in all other cases where $foo is defined, even if (boolean) $foo === false, it will throw an error unless $foo->bar is valid (i.e. $foo is an object already).
<?php
$foo = true;
settype($foo->bar,"integer"); ?>