yajra / pdo-via-oci8

PHP PDO_OCI functions via OCI8 extension
Other
88 stars 61 forks source link

Calling reset() on an object is deprecated in (Statement.php on line 690) PHP 8.1.4 #108

Closed nazarialireza closed 2 years ago

nazarialireza commented 2 years ago

Summary of problem or feature request

I'm using Laravel OCI8 v9 which I have many deprecation logs for Calling reset() function for PHP 8.1.4:

local.WARNING: reset(): Calling reset() on an object is deprecated in *\vendor\yajra\laravel-pdo-via-oci8\src\Pdo\Oci8\Statement.php on line 690

I already post comment in Laravel OCI8 here

Code snippet of problem

The following code fixed my issue hope do the same for other, line 690, 691of yajra\laravel-pdo-via-oci8\src\Pdo\Oci8\Statement.php need to be update from this:

 if ((is_array($row) || is_object($row)) && is_resource( reset($row) )) {
                $stmt = new self(reset($row)), $this->connection, $this->options);

To this:

 if ((is_array($row) || is_object($row)) && is_resource( current( ( (array) $row) ) )) {
                $stmt = new self(current(((array) $row)), $this->connection, $this->options);

The above code fixed my deprecation logs. this is my Log::alert(reset($row) . ' ' . current(((array) $row)) ); [2022-06-11 09:12:09] local.ALERT: BACKUP BACKUP

System details

yajra commented 2 years ago

Would you be able to review this PR https://github.com/yajra/pdo-via-oci8/pull/104 if it fixes the issue? Will merge when you confirm it's working.

nazarialireza commented 2 years ago

Yes its working according to my test in this comment

yajra commented 2 years ago

Released on v3.2.3 thanks!