4

Fatal error: Cannot use 'Object' as class name as it is reserved

I'm trying to bake my project but it shows this error. I'm using cakephp 2.5.4 and PHP 7.0.32

I tried to change the lib folder I used the lib folder for 2.8.0 and I tried to change PHP version to 5.6.38 but nothing worked. :(

ZUHDI
  • 43
  • 1
  • 1
  • 4
  • 3
    Please add your code that will be easy for understand what actually problem you happend – MD. Jubair Mizan Dec 19 '18 at 07:37
  • That is true `Class Object` or `Class true` or any of the other "reserved" words don't work as class name. It's just part of the "deal" – ArtisticPhoenix Dec 19 '18 at 07:43
  • Note that you aren't actually using PHP 7.0.32 or 5.6.38, but PHP 7.2+, as `Object` is only a reservered name as of PHP 7.2. You're probably looking in the wrong place, hence whatever you're changing with regards to the PHP version has no effect. For CakePHP 2.x you need to use the latest 2.10 version for proper PHP 7.2 compatibility. **https://stackoverflow.com/questions/52981403/cannot-use-object-as-class-name-as-it-is-reserved-cake-2-2-x** – ndm Dec 19 '18 at 11:32
  • almost same question, in different framework.. https://stackoverflow.com/questions/50269306/cannot-use-yii-base-object-as-object-because-object-is-a-special-class-name-yi – Budi Mulyo Jul 26 '19 at 09:09

3 Answers3

8

"Object" is one of the reserved keyword of PHP. You can not use it as class name. Change the class name to resolve the error.

Rakesh P
  • 438
  • 5
  • 19
7

Use Php 7.1 version. It will solve that issue

Sreejith vs
  • 93
  • 1
  • 11
0

I upgraded my composer and it worked well for me.

Nätu
  • 304
  • 5
  • 16