spatie / ray

Debug with Ray to fix problems faster
https://myray.app
MIT License
574 stars 102 forks source link

Dumping the string `date` shows false on app #631

Closed elvispt closed 2 years ago

elvispt commented 2 years ago

Describe the bug When dumping the string "date" ray('date') the ray application shows false.

If I set exit right after the ray function call, I also get this error on the page: Warning: date() expects parameter 1 to be string, object given in /var/www/html/app/plugins/spatie-ray/vendor/spatie/ray/src/Ray.php on line 455

It's clear it's attempting to run the date function, but it should just show the "date" string.

Versions Ray version (you can see this in "About Ray"): 1.19.0

You can use composer show to get the version numbers of:

PHP version: 7.4.26 Laravel version (if applicable):

To Reproduce Steps to reproduce the behavior:

  1. Call ray('date')
  2. Run the code
  3. See the result on the app

Expected behavior Should just dump the string "date" on the application.

Screenshots If applicable, add screenshots to help explain your problem. Example: image

Desktop (please complete the following information):

kemp commented 2 years ago

That would probably be because of this line:

https://github.com/spatie/ray/blob/fa2b3e64a93717ccf478a701048181a515eef2a3/src/Ray.php#L639

And due to the fact that it will call a callable (which date is), according to the documentation:

ray($callable)->catch([$callable, $classname, …]) | Handle any exceptions encountered by try

Source: https://spatie.be/docs/ray/v1/usage/reference

elvispt commented 2 years ago

@kemp I do believe this is unexpected behavior. I came across this when I was dumping the value that was on an array: ray($arr['level1']['level2']) and was confused when ray was showing false, when I expected the value to be a string from a predefined list. I thought my code had a bug.

Nielsvanpach commented 2 years ago

This is already fixed and released: https://github.com/spatie/ray/commit/41412bca9add3374a13310f6e5ceef54633f6bfd You are using 1.19.0 while the latest release is 1.33.2, the issue should be fixed after upgrading.

Sending 'date' as string and array both seem to work fine on the latest release.

Screenshot 2022-02-09 at 11 32 28
elvispt commented 2 years ago

Hi @Nielsvanpach I checked if I have the latest version on the app, and it says I have the latest v1.19.0.

I went to the purchases page to download, and it gives me the same version. Can you tell me where to get the latest? It's the Apple Intel version.

Thanks

Nielsvanpach commented 2 years ago

Which version of spatie/ray are you using in your project? I suggest updating this with composer, not the Ray desktop app.

elvispt commented 2 years ago

Oh so you mean the version at the package level. I am using the version available at WordPress Packagist (https://wordpress.org/plugins/spatie-ray/). There it's on 1.5.1.