PHP 5.5.16 Invalid offset type in isset or empty

I'm working with Laravel here (semi-irrelevant) and am running into strange PHP issues that I haven't seen before. I am getting an exception with this error:

Invalid offset type in isset or empty

The code is in the Laravel framework (Illuminate \ View \ Factory.php) and the corresponding error snippet is:

if (isset($this->aliases[$view])) $view = $this->aliases[$view];


Now, I understand that if you pass an array or object as an array key, it will throw this error. But I dropped $this->aliases

and got:

array(0) { }


And unloaded $view

and got:

string(11) ""


So, no matter if the array is empty, the call isset

should just return false since the string key is not set.

I don't think this should be a bug at all, but is there a setting in php.ini that can cause severe errors like this that I can change, or am I just not understanding the main operation of the isset()



This should be related to Mihai Stancu's comment below. I just tested this and it works fine without exception:

$key = 'test-key';
$test = array();
if (isset($test[$key]))


This outputs "Nope" as expected.


source to share

1 answer

Just declare $something = aliases[$view]

and parse it as a string and then

if (isset($this->$something))




All Articles