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

Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead #756

Open
keithlaikf opened this issue Jul 8, 2020 · 1 comment

Comments

@keithlaikf
Copy link

Summary of issue

array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead

API URI
/en/api/user/users?page=1&per_page=30&order_by=&order=&search=

Response:
"message": "array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead",
"exception": "ErrorException",
"file": "C:\xampp7420\htdocs\cms\myAsgardCmsPlatform\vendor\laravel\framework\src\Illuminate\Http\Resources\DelegatesToResource.php",
"line": 53,

Steps to reproduce

  1. Login as Admin in /backend
  2. Click Users

System Details

  • Operating System: Windows 10 Pro
  • PHP Version: 7.4.2
  • Laravel Version: 5.5
  • Asgardcms/Platform version: master branch - 4.0.x-dev
@mikemand
Copy link
Contributor

mikemand commented Aug 3, 2020

Hi @keithlaikf,

This error occurs because of PHP 7.4 depreciations. If possible, use PHP 7.3. If not possible, you will have to edit line 53 of the file vendor/laravel/framework/src/Illuminate/Http/Resources/DelegatesToResource.php to be:

return isset($this->resource[$offset]);

You can use the exclude-from-classmap in your composer.json and then include your own version of the \Illuminate\Http\Resources\DelegatesToResource class (be sure to match the namespace!), or you can patch it: https://tomasvotruba.com/blog/2020/07/02/how-to-patch-package-in-vendor-yet-allow-its-updates/

Edit: Nope, you can't patch it. The Workshop module is locking symfony/yaml to v3, but the patch method requires v5.

Here's how I did it:

...
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/",
            "Modules\\": "Modules/",
            "Illuminate\\Http\\Resources\\": "overrides/Illuminate/Http/Resources"
        },
        "exclude-from-classmap": [
            "vendor/laravel/framework/src/Illuminate/Http/Resources/DelegatesToResource.php"
        ]
    },
...

Then I copied vendor/laravel/framework/src/Illuminate/Http/Resources/DelegatesToResource.php to overrides/Illuminate/Http/Resources/DelegatesToResource.php and changed line 53.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants