cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 : Deprecated Functionality: Function ReflectionType::__toString() is deprecated.

SOLVED

Magento 2 : Deprecated Functionality: Function ReflectionType::__toString() is deprecated.

Hello all,

When I try to execute bin/magento setup:install from the command line

I get an exception as "Deprecated Functionality: Function ReflectionType::__toString() is deprecated".

It gives the same error for my previous Magento instance when I do bin/magento setup:upgrade.

It was running all good a few days earlier.

Does anyone have solution for this?

 

Thank You.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 2 : Deprecated Functionality: Function ReflectionType::__toString() is deprecated.

Magento 2.3 is not compatible with Php 7.4, So there are two possible solutions:


1. Downgrade you Php version to 7.3 - Recommended
2. If it is not possible for you to downgrade php version, you need to perform few changes in core files. This is a work around until Magento get compatible version for Php 7.4. When installing on my end I had faced few issues, this is what I did to solve them.

 

Change1:

File: vendor/zendframework/zend-code/src/Reflection/ParameterReflection.php
In function `detectType()` replace line

 

return (string) $type;

 

with

 

return $type->getName();

 

 

Change2:

Error: Deprecated Functionality: implode(): Passing glue string after array is deprecated
File: vendor/magento/framework/DB/Sql/UnionExpression.php
In function `__toString()` replace line

$sql = implode($parts, $this->type);

with

$sql = implode($this->type,$parts);

Change3:

File: vendor/magento/framework/App/AreaList.php
In function `getCodeByFrontName()` replace line

if ($areaInfo['frontName'] == $frontName)

with

if (isset($areaInfo) && $areaInfo['frontName'] == $frontName)

 

Hope it helps you,

Thanks

View solution in original post

8 REPLIES 8

Re: Magento 2 : Deprecated Functionality: Function ReflectionType::__toString() is deprecated.

Can you tell which Php version your system is running ?

 

Thanks

Re: Magento 2 : Deprecated Functionality: Function ReflectionType::__toString() is deprecated.

Hello @Abdul Pathan ,

 

I am using PHP 7.4, And I have installed Magento 2.3

 

Re: Magento 2 : Deprecated Functionality: Function ReflectionType::__toString() is deprecated.

Magento 2.3 is not compatible with Php 7.4, So there are two possible solutions:


1. Downgrade you Php version to 7.3 - Recommended
2. If it is not possible for you to downgrade php version, you need to perform few changes in core files. This is a work around until Magento get compatible version for Php 7.4. When installing on my end I had faced few issues, this is what I did to solve them.

 

Change1:

File: vendor/zendframework/zend-code/src/Reflection/ParameterReflection.php
In function `detectType()` replace line

 

return (string) $type;

 

with

 

return $type->getName();

 

 

Change2:

Error: Deprecated Functionality: implode(): Passing glue string after array is deprecated
File: vendor/magento/framework/DB/Sql/UnionExpression.php
In function `__toString()` replace line

$sql = implode($parts, $this->type);

with

$sql = implode($this->type,$parts);

Change3:

File: vendor/magento/framework/App/AreaList.php
In function `getCodeByFrontName()` replace line

if ($areaInfo['frontName'] == $frontName)

with

if (isset($areaInfo) && $areaInfo['frontName'] == $frontName)

 

Hope it helps you,

Thanks

Re: Magento 2 : Deprecated Functionality: Function ReflectionType::__toString() is deprecated.

Hello @Abdul Pathan ,

Thanks For your quick reply.
I tried the second solution, yes it's working.
Is this a Magento bug?
 
Once again Thanks a lot Smiley Happy

Re: Magento 2 : Deprecated Functionality: Function ReflectionType::__toString() is deprecated.

Its not an Magento bug, its just that Php7.4 has deprecated few functionality which were working in Php7.3. Such changes usually are carried inorder to improve the efficiency/security in Php. Any application using these deprecated functionality are supposed to update its code in-order to support new version of Php . Hope it makes it clear.

Re: Magento 2 : Deprecated Functionality: Function ReflectionType::__toString() is deprecated.

Hi Abdul

Apologies for hijacking this thread but I have the same issue when my hosting company automatically upgraded to php 7.4

I reverted it back to 7.3 but I'm still having the same issue.

Does Magento 2.3.3 change any code when it atempts to use php 7.4?

I don't understand why I'm still getting these issues.

I can't run php bin/magento setup:upgrade or php -dmemory_limit=4G bin/magento setup:di:compile

Hope someone can help

Thank you

Andy

Re: Magento 2 : Deprecated Functionality: Function ReflectionType::__toString() is deprecated.

Update:
My hosting company has set php 7.4 as the default so to access v 7.3 when running scripts I had to specify the php version - /usr/local/php73/bin/php-cli

Hope this helps others.

Re: Magento 2 : Deprecated Functionality: Function ReflectionType::__toString() is deprecated.

Magento 2.4 is not compatible with Php 8.1, any sol?.......

PHP Fatal error:  During inheritance of Iterator: Uncaught Exception: Deprecated Functionality: Return type of