spatie/global-ray

Problem with float

Closed this issue · 3 comments

Hi,

Just started using Ray and already loving it. But there seems to be a problem with floats on php 7.4

Describe the bug

    $arraytest = array( 'price' => 412.39); // as float
    ray($arraytest);

Gives an error:
PHP Fatal error: Uncaught Error: Call to undefined function str_contains() in phar://C:/Users//Composer/vendor/spatie/global-ray/ray-phars/ray_php_7.4.phar/vendor/symfony/var-dumper/Dumper/CliDumper.php:126
Stack trace:
#0 phar://C:/Users/
/Composer/vendor/spatie/global-ray/ray-phars/ray_php_7.4.phar/vendor/symfony/var-dumper/Cloner/Data.php(371): GlobalRay\Symfony\Component\VarDumper\Dumper\CliDumper->dumpScalar(Object(GlobalRay\Symfony\Component\VarDumper\Cloner\Cursor), 'double', '412.39')
spatie/ray#1 phar://C:/Users//Composer/vendor/spatie/global-ray/ray-phars/ray_php_7.4.phar/vendor/symfony/var-dumper/Cloner/Data.php(278): GlobalRay\Symfony\Component\VarDumper\Cloner\Data->dumpItem(Object(GlobalRay\Symfony\Component\VarDumper\Dumper\HtmlDumper), Object(GlobalRay\Symfony\Component\VarDumper\Cloner\Cursor), Array, 412.39)
spatie/ray-app#5 phar://C:/Users/
/Composer/vendor/spatie/global-ray/ray-phars/ray_php_7.4.phar/vendor/symfony/var-dumper/Dumper/AbstractDumper.php(120): in phar://C:/Users/***/Composer/vendor/spatie/global-ray/ray-phars/ray_php_7.4.phar/vendor/symfony/var-dumper/Dumper/CliDumper.php on line 126

To my understanding, str_contains() isn't available in php 7.4 yet but only in PHP 8, might that be the problem?

    $arraytest = array( 'price' => '412.39'); // As a string
    ray($arraytest);

Works fine btw.

Versions
Ray version 2.0.1.0
PHP version 7.4.28

To Reproduce
Just create a simple php script and try the above 2 different options.

Expected behavior
Expected to see the array in Ray ;)

Desktop (please complete the following information):

  • OS: WIN 10
  • Version 21H2

str_contains is not in the spatie/ray codebase. I'm assuming this is caused by how the phrase of Global Ray are built.

Thx for the quick response. I've installed spatie/ray directly to the app i'm building, and that works. Not sure why it failed as a global install but I don't want to waste time figuring that out. ;)
Will be happily debugging now!

Have fun debugging! 👍