3

i was using PHP 7.0 i used to use Zend\Form\Annotation\Object Now i have upgraded my system to 7.2 and Now i am getting an error that

PHP Fatal error: Cannot use Zend\Form\Annotation\Object as Object because 'Object' is a special class name

please suggest me Alternative for this class

2

UPDATE #1

If you look at the source file you can see they have added a note

Since PHP 7 adds "object" as a reserved keyword, we can no longer have a class * named that and retain PHP 7 compatibility. The original class has been * renamed to "Instance", and this class is now an extension of it. It raises an * E_USER_DEPRECATED to warn users to migrate.

So as advised, use Zend\Form\Annotation\Instance instead of Zend\Form\Annotation\Object

from PHP 7.2+ onwards the ClassName will not be allowed to be named after special / reserverd keywords like Object.

So either you need to upgrade your Magento version which is compatible with PHP 7.2+ (Yah sounds terrible) or downgrade your PHP version.

Good news, you are not alone, there are people out there facing this issue and this one can fix your issue. (Hope it will)

https://github.com/ongr-io/ElasticsearchBundle/issues/828#issuecomment-443437917

| improve this answer | |
  • so whats alernative of Zend\Form\Annotation\Object class in 7.2 any idea? – Waqar Ali Nov 9 '19 at 12:15
  • 1
    @WaqarAli yes use Zend\Form\Annotation\Instance instead of Object, checked the updated answer. – Haijerome Nov 9 '19 at 12:19
  • thank you so much dude you are my Hero – Waqar Ali Nov 9 '19 at 12:48
  • happy that it helps you dude, God Bless Pakistan ! – Haijerome Nov 9 '19 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.