laravel / telescope

An elegant debug assistant for the Laravel framework.
https://laravel.com/docs/telescope
MIT License
4.77k stars 560 forks source link

str_contains(): Argument #1 ($haystack) must be of type string, DateTime given #1493

Closed lanrenbulan closed 3 days ago

lanrenbulan commented 3 days ago

Telescope Version

5.1.0

Laravel Version

11.12.0

PHP Version

8.2.12

Database Driver & Version

MySql8.4

Description

    public function replaceBindings($event)
    {
        if (version_compare(app()->version(), '10.0.0', '>=')) {
            // The problem is here, and fix?
            // return $event->connection->getQueryGrammar()->substituteBindingsIntoRawSql($event->sql, $this->formatBindings($event));
            return $event->connection->getQueryGrammar()->substituteBindingsIntoRawSql($event->sql, $event->bindings);
        }

        $sql = $event->sql;

        foreach ($this->formatBindings($event) as $key => $binding) {
            $regex = is_numeric($key)
                ? "/\?(?=(?:[^'\\\']*'[^'\\\']*')*[^'\\\']*$)/"
                : "/:{$key}(?=(?:[^'\\\']*'[^'\\\']*')*[^'\\\']*$)/";

            if ($binding === null) {
                $binding = 'null';
            } elseif (! is_int($binding) && ! is_float($binding)) {
                $binding = $this->quoteStringBinding($event, $binding);
            }

            $sql = preg_replace($regex, $binding, $sql, 1);
        }

        return $sql;
    }

Steps To Reproduce

['created_at' => new DateTime()]

driesvints commented 3 days ago

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to open up a new issue with a link to the original one and we'll gladly help you out.

Thanks!