spatie / wordpress-ray

Debug with Ray to fix problems faster in WordPress apps
https://myray.app
MIT License
73 stars 14 forks source link

Symfony\Component\VarDumper\Caster\DateCaster not found #24

Closed mauryaratan closed 3 years ago

mauryaratan commented 3 years ago

Hey there! Loving the Ray so far 😍

Was trying to print an object and came across this error.

Fatal error: Uncaught Error: Class 'Symfony\Component\VarDumper\Caster\DateCaster' not found in /public_html/content/plugins/spatie-ray/vendor/symfony/var-dumper/Cloner/AbstractCloner.php on line 348

Using the WordPress plugin btw.

jeffreyvr commented 3 years ago

Just did a quick check and can reproduce the error. Happens when for example running:

ray(new DateTime);

Appears to be caused by the missing namespace prefixes on the $defaultCasters array within AbstractCloner.php from line 25.

jeffreyvr commented 3 years ago

@freekmurze I guess the imposter-plugin package does not pickup on namespaces within arrays etc.

The following might not be an ideal solution, but a quick fix could be running a find replace on the file after the composer install script.

"post-install-cmd": [
    "sed -i '' 's/'\\''Symfony/'\\''Spatie\\\\WordPressRay\\\\Symfony/g' ./vendor/symfony/var-dumper/Cloner/AbstractCloner.php"
]
freekmurze commented 3 years ago

@jeffreyvr thanks for checking. I think that PR might be the way to go for now. Could you PR that?

freekmurze commented 3 years ago

Will be fixed by #25

stanwarri commented 3 years ago

I'm still experiencing this error even after upgrading to the latest wordpress version

jeffreyvr commented 3 years ago

@freekmurze Unfortunately, with https://github.com/spatie/wordpress-ray/commit/30cce28559f3ea724f5e35966e6ddf5d1cfeae30#diff-b690787d29e71943d4eb6bf3c04594ce8cfa7cc5bf56b5016c89854fdfe5f54e the fix was overwritten.

Possibly the composer post install script was not executed.

freekmurze commented 3 years ago

I'll retry by tagging a new version later tonight!

freekmurze commented 3 years ago

I've tagged a new version. The modified classnames are now written correctly: https://github.com/spatie/wordpress-ray/blob/855a811487751a3e96c30ab1f2c57a7ef4f3d6f0/vendor/symfony/var-dumper/Cloner/AbstractCloner.php#L24