adrianbj / TracyDebugger

The ultimate debugging and development tool for ProcessWire
https://adrianbj.github.io/TracyDebugger/
GNU General Public License v2.0
88 stars 13 forks source link

TypeError: ReflectionObject::__construct(): Argument #1 ($object) must be of type object, string given in DebugModePanel.php:206 #57

Closed matjazpotocnik closed 3 years ago

matjazpotocnik commented 3 years ago

Hi Adrian!

I'm getting strange warning in this line in DebugModePanel.php

$ro = new \ReflectionObject($toObject);

I used this to debug:

if(is_string($toObject)) bd($toObject);

and $toObjecs is an empty string (''). Not sure how this happened...

adrianbj commented 3 years ago

Thanks @matjazpotocnik - I actually already have a fix for that in place here, just not committed yet.

                    if($toMethod instanceof \Closure) {
                        $rc = new \ReflectionFunction($toMethod);
                    }
                    *elseif($hook['toObject']) {*
                        if(method_exists("\ProcessWire\\$toObject", $toMethod)) {
                            $rc = new \ReflectionMethod("\ProcessWire\\$toObject", $toMethod);
                        }

Change the line between the asterisks.

This error was initially introduced when I was working with @BernhardBaumrock on a feature request. I had things kinda working how he wanted, but I think last I heard he wanted to make some further changes. Bernhard - did you ever get this working as you wanted?

BernhardBaumrock commented 3 years ago

Sorry for the delay on this, but I was not able to work on it yet. I'm working on different projects now that seem to have a different setup... so the 0::xxx did not appear at all. Sorry for the troubles!

matjazpotocnik commented 3 years ago

I changed the line, no more warnings

adrianbj commented 3 years ago

@matjazpotocnik - this should be fixed in the latest version, but please reopen if you still have issues.