Php array unsupported operand types

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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

Unsupported operand types #2016

Unsupported operand types #2016

Comments

Hello,
I’m actually trying to use Auth0 integration on a Prestashop module, but after installed the integration with Composer, i’ve this error :

[PrestaShop] Fatal error in module file: /var/www/html/modules/prestashop/vendor/guzzlehttp/guzzle/src/Client.php:236
Unsupported operand types

Is that a bug ? It’s actually stucking me.
Thanks in advance.

The text was updated successfully, but these errors were encountered:

I’m sorry, it’s actually the first time i’m asking help here for something.
My PHP version is 7.1.14 (running on a Docker), and it’s actually installed with Auth0 package (Composer) so i don’t have the version but i guess it should be the last one..

About the logs, it’s all i got.
I just downloaded it with Composer and i got this error :

I’m sorry, it’s actually the first time i’m asking help here for something.

No problem, just a friendly reminder. 😉

(Composer) so i don’t have the version but i guess it should be the last one..

You can check the version in the composer.lock file

I’ll keep that in my mind for the future, thanks 🙂

Without the actual stack trace it’s going to be hard to identify the problem. Can you debug the code?

If you have no debugging tools at hand, at least could you go to that line and var_dump the two operands (poor mans debug)?

I’ve only the code of the guzzle library on my folder. The only line of code i’ve called is
«require_once(dirname(FILE) . ‘/vendor/autoload.php’);»

It concern the operand «$result = $options + $defaults;»

Here’s the complete function affiliated :

 private function prepareDefaults($options) < $defaults = $this->config; if (!empty($defaults['headers'])) < // Default headers are only added if they are not present. $defaults['_conditional'] = $defaults['headers']; unset($defaults['headers']); >// Special handling for headers is required as they are added as // conditional headers and as headers passed to a request ctor. if (array_key_exists('headers', $options)) < // Allows default headers to be unset. if ($options['headers'] === null) < $defaults['_conditional'] = null; unset($options['headers']); >elseif (!is_array($options['headers'])) < throw new \InvalidArgumentException('headers must be an array'); >> // Shallow merge defaults underneath options. $result = $options + $defaults; // Remove null values. foreach ($result as $k => $v) < if ($v === null) < unset($result[$k]); >> return $result; > 

Yup, that’s it. This line in particular:

$result = $options + $defaults;

Can you dump those two variables before merging them?

Here’s what i got.
The first (string) is the $options value, and the second one is $defaults.

string(38) "1var/www/html/app/cache/dev/cacert.pem" 
array(9) < ["base_url"]=>string(33) "https://api-addons.prestashop.com" ["defaults"]=> array(1) < ["timeout"]=>string(3) "5.0" > ["handler"]=> object(GuzzleHttp\HandlerStack)#393 (3) < ["handler":"GuzzleHttp\HandlerStack":private]=>object(Closure)#446 (2) < ["static"]=>array(2) < ["default"]=>object(Closure)#416 (2) < ["static"]=>array(2) < ["default"]=>object(GuzzleHttp\Handler\CurlMultiHandler)#457 (5) < ["factory":"GuzzleHttp\Handler\CurlMultiHandler":private]=>object(GuzzleHttp\Handler\CurlFactory)#459 (2) < ["handles":"GuzzleHttp\Handler\CurlFactory":private]=>array(0) < >["maxHandles":"GuzzleHttp\Handler\CurlFactory":private]=> int(50) > ["selectTimeout":"GuzzleHttp\Handler\CurlMultiHandler":private]=> int(1) ["active":"GuzzleHttp\Handler\CurlMultiHandler":private]=> NULL ["handles":"GuzzleHttp\Handler\CurlMultiHandler":private]=> array(0) < >["delays":"GuzzleHttp\Handler\CurlMultiHandler":private]=> array(0) < >> ["sync"]=> object(GuzzleHttp\Handler\CurlHandler)#454 (1) < ["factory":"GuzzleHttp\Handler\CurlHandler":private]=>object(GuzzleHttp\Handler\CurlFactory)#389 (2) < ["handles":"GuzzleHttp\Handler\CurlFactory":private]=>array(0) < >["maxHandles":"GuzzleHttp\Handler\CurlFactory":private]=> int(3) > > > ["parameter"]=> array(2) < ["$request"]=>string(10) "" ["$options"]=> string(10) "" > > ["streaming"]=> object(GuzzleHttp\Handler\StreamHandler)#394 (1) < ["lastHeaders":"GuzzleHttp\Handler\StreamHandler":private]=>array(0) < >> > ["parameter"]=> array(2) < ["$request"]=>string(10) "" ["$options"]=> string(10) "" > > ["stack":"GuzzleHttp\HandlerStack":private]=> array(4) < [0]=>array(2) < [0]=>object(Closure)#464 (1) < ["parameter"]=>array(1) < ["$handler"]=>string(10) "" > > [1]=> string(11) "http_errors" > [1]=> array(2) < [0]=>object(Closure)#469 (1) < ["parameter"]=>array(1) < ["$handler"]=>string(10) "" > > [1]=> string(15) "allow_redirects" > [2]=> array(2) < [0]=>object(Closure)#470 (1) < ["parameter"]=>array(1) < ["$handler"]=>string(10) "" > > [1]=> string(7) "cookies" > [3]=> array(2) < [0]=>object(Closure)#423 (1) < ["parameter"]=>array(1) < ["$handler"]=>string(10) "" > > [1]=> string(12) "prepare_body" > > ["cached":"GuzzleHttp\HandlerStack":private]=> NULL > ["allow_redirects"]=> array(5) < ["max"]=>int(5) ["protocols"]=> array(2) < [0]=>string(4) "http" [1]=> string(5) "https" > ["strict"]=> bool(false) ["referer"]=> bool(false) ["track_redirects"]=> bool(false) > ["http_errors"]=> bool(true) ["decode_content"]=> bool(true) ["verify"]=> bool(true) ["cookies"]=> bool(false) ["_conditional"]=> array(2) < ["Accept"]=>string(16) "application/json" ["User-Agent"]=> string(39) "GuzzleHttp/6.2.1 curl/7.38.0 PHP/5.6.33" > > 

(Sorry for the late answer)

Источник

Solve PHP Fatal Error: Unsupported operand types

Posted on Sep 30, 2022

The PHP Fatal Error: Unsupported operand types is an error message that indicates you have used operators on values that are not supported.

PHP operators like + and — can be used on int type values. When you try to combine values like array or string with an int , the error message will appear:

 This fatal error commonly occurs in PHP v8, where the execution of operands is made stricter.

In PHP v7 or below, the string will be ignored and PHP will print out the int value:

To solve this fatal error, you need to make sure that the operands (the values on the left or right side of the operator) are supported by PHP.

Arithmetic operators like + , — , * , and / support int and float types.

You can’t add an array and an int , or a string and a float when using these operators:

 Even PHP v5 will show “Unsupported operand types” when you add an array and an int as in the example above.

When you don’t know how to fix the issue, use var_dump() to see the type of the variable like this:

The above example will output the content of the $arr variable:
     Knowing that it’s an array, you can choose to perform addition to the number element, which is the price element:

PHP requires you to use supported operand types for the code.

When you see the message “Fatal Error: Unsupported operand types”, you need to pay attention to the variables used as operands.

They are the variables on the left or right side of the operator symbol. You can find information about them using the var_dump() function.

Once you know the operand types, adjust your code accordingly to solve this error.

And that’s how you handle PHP Fatal Error: Unsupported operand types. Nice work! 😉

Take your skills to the next level ⚡️

I’m sending out an occasional email with the latest tutorials on programming, web development, and statistics. Drop your email in the box below and I’ll send new stuff straight into your inbox!

About

Hello! This website is dedicated to help you learn tech and data science skills with its step-by-step, beginner-friendly tutorials.
Learn statistics, JavaScript and other programming languages using clear examples written for people.

Type the keyword below and hit enter

Tags

Click to see all tutorials tagged with:

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

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

PHP8 Error: unsupported operand types: int & array #1464

PHP8 Error: unsupported operand types: int & array #1464

Comments

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don’t comment if you have no relevant information to add. It’s just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Expected behaviour

Actual behaviour

Logging of Error core

**TypeError**: Unsupported operand types: int & array 1. */var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php* *- line 74:* OC\Files\Cache\Wrapper\CachePermissionsMask->formatCacheEntry() 2. */var/www/nextcloud/apps/groupfolders/lib/Versions/VersionsBackend.php* *- line 170:* OC\Files\Cache\Wrapper\CacheWrapper->get() 3. `>` *OCA\GroupFolders\Versions\VersionsBackend->OCA\GroupFolders\Versions\(**"\**\* sensiti . \*"**) 4. */var/www/nextcloud/apps/groupfolders/lib/Versions/VersionsBackend.php* *- line 169:* array_map() 5. */var/www/nextcloud/apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php* *- line 64:* OCA\GroupFolders\Versions\VersionsBackend->getAllVersionedFiles() 6. */var/www/nextcloud/apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php* *- line 58:* OCA\GroupFolders\Versions\GroupVersionsExpireManager->expireFolder() 7. */var/www/nextcloud/apps/groupfolders/lib/BackgroundJob/ExpireGroupVersions.php* *- line 40:* OCA\GroupFolders\Versions\GroupVersionsExpireManager->expireAll() 8. */var/www/nextcloud/lib/private/BackgroundJob/Job.php* *- line 52:* OCA\GroupFolders\BackgroundJob\ExpireGroupVersions->run() 9. */var/www/nextcloud/lib/private/BackgroundJob/TimedJob.php* *- line 59:* OC\BackgroundJob\Job->execute() 10. */var/www/nextcloud/cron.php* *- line 128:* OC\BackgroundJob\TimedJob->execute() 

Server configuration

The text was updated successfully, but these errors were encountered:

Источник

Читайте также:  Overloading constructors in python
Оцените статью