Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.1 show Warning reset(): Calling reset() on an object is deprecated #692

Closed
jirapetr opened this issue Jan 11, 2022 · 5 comments
Closed
Labels

Comments

@jirapetr
Copy link

Summary of problem or feature request

Laravel debugbar show lots of LOG.warnings:

warning: Return type of Yajra\Pdo\Oci8\Statement::bindColumn($column, &$variable, $dataType = null, $maxLength = -1, $options = null) should either be compatible with PDOStatement::bindColumn(string|int $column, mixed &$var, int $type = PDO::PARAM_STR, int $maxLength = 0, mixed $driverOptions = null): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in ../vendor/yajra/laravel-pdo-via-oci8/src/Pdo/Oci8/Statement.php on line 223

warning: reset(): Calling reset() on an object is deprecated in ../vendor/yajra/laravel-pdo-via-oci8/src/Pdo/Oci8/Statement.php on line 650

I want no warning

Code snippet of problem

if ((is_array($row) || is_object($row)) && is_resource(reset($row))) {

System details

  • Ubuntu 20.04
  • PHP Version: 8.1
  • Laravel Version: 8.76
  • Laravel-OCI8 Version : 8.5
@yajra yajra added the PHP 8.1 label Jan 12, 2022
@yajra
Copy link
Owner

yajra commented Jan 12, 2022

Thanks for reporting. I haven't had time to upgrade to 8.1 and still stuck with 7.4. If you can fix, please do not hesitate to submit a PR.

@jamespavett
Copy link

Just to confirm, will this be combined with Laravel 9 support seeing as that is now released?

@yajra
Copy link
Owner

yajra commented Feb 9, 2022

@jamespavett Yes, any fixes on 8.x will be added on 9.x version if that is what you were referring to.

Also, would you be able to help reviewing this PR: yajra/pdo-via-oci8#95 if it fixes the issue?

@nazarialireza
Copy link

nazarialireza commented Jun 11, 2022

Same issue here I have many deprecation logs for Calling reset().
PHP: 8.1.4
Laravel: 9.17

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

It's maybe the solution, in line 690 & 691 you need to replace the reset() with current() some discussion can be found here

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

update to

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

Update:
Maybe as official PHP here I just test the second solution and it's working.

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

Note: I did try both method to get raid of deprecation logs, I get same result with current( ((array) $row)) and $row = get_mangled_object_vars($row); before if condition

Please fix the issue and update the composer.json in Laravel OCI8 to use the last version of pdo-via-oci8 if required, also please update the name of pdo-via-oci8 in composer.json becuase it's still laravel-pdo-via-oci8, I get confused for find right place to check the issue.

@yajra
Copy link
Owner

yajra commented Jun 11, 2022

Fixed via yajra/pdo-via-oci8#104 - v3.2.3. Thanks!

@yajra yajra closed this as completed Jun 11, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants