Using var_dump($this) in class that extends Exception

can someone try this and see if they get the same result? or maybe knows whats happening?

if i extend the php exception class and within the constructor call “var_dump($this);”

i get an infinite loop… but im not quite sure if this is php behaviour or whether its my set up or maybe slim

i could understand an error but an infinite loop is pretty sketchy

run it as is and it should execute fine, but for me uncommenting the // extends \Exception

results in an infinite loop of some kind

<?php
/*
 * ExampleException.php
 *
 */
namespace app\exception;

class ExampleException // extends \Exception
{
    public function __construct($message = null)
    {
        var_dump($message);
        
        var_dump(get_class($this));
        
        var_dump(json_encode($this));
        
        //if i extend exception the following line results in infinite loop 
        var_dump($this);
        
        die;
    }
}

and run it from somewhere

throw new \app\exception\ExampleException(‘why it do like that’);

Hi! You can try it here in isolation: https://3v4l.org/WidJF

hmm it seems to execute fine

i guess i must have something else going on somewhere