cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted

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
Highlighted

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

5 REPLIES 5
Highlighted

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

Can you tell which Php version your system is running ?

 

Thanks

Highlighted

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

Hello @abdulpathan ,

 

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

 

Highlighted

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

Highlighted

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

Hello @abdulpathan ,

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

Highlighted

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.