Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8557619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:36:52+00:00 2026-06-11T15:36:52+00:00

I have updated my machine from PHP 5.3 to PHP 5.4 and my CakePHP

  • 0

I have updated my machine from PHP 5.3 to PHP 5.4 and my CakePHP (version 2.1.1) app keeps getting these errors:

Fatal Error: Class ‘String’ not found in …/Behavior.php on line …

Fatal Error: Class ‘Debugger’ not found in …/Component.php on line …

Etc.

The errors are really not useful, since the LINE and FILE of the error always state the end bracket of the class declaration.

After a lot of searching, I managed to solve SOME of the errors by adding proper public/private function declarations and strong parameter typing, A.K.A.:

function beforeSave($Model) {}

//becomes
public function beforeSave(Model $Model){}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:36:53+00:00Added an answer on June 11, 2026 at 3:36 pm

    After transferring to PHP5.4, you have to cleanup a lot of “bad practices” in your code.

    Strong-typed parameter definition in extended methods

    This means that you have to write the class of the objects which the method receives just before the variable name. This is only needed for methods which replace parent’s class methods, not for all methods. If unsure, just check the method declaration in the parent class in the core files or API.

    // Behavior code
    public function afterSave(Model $model, $created) //GOOD 
    function aferSave($model) //NOT GOOD
    // Component code
    public function shutdown(Controller $Controller) // GOOD
    function shutdown($Controller) // BAD
    

    Remove “Call-time pass by reference”

    I’ve seen a lot of people passing arround Controller and Model objects in functions BY REFERENCE:

    function beforeSave(&$Model)
    

    This throws an error and is wrong.
    Just remove the ampersand before the variable. You will not break any functionality, because Objects are already passed by reference in PHP, and as I get it, this was removed in PHP 5.4.

    Declare all method parameters in extending methods

    If you overwrite a parent-class’ method, you should declare all function parameters in the function definition. If there is a parameter missing, you will get an error.

    Example:

    SomeBehavior extends ModelBehavior
    public function afterSave(Model $Model){ } //WRONG, but works in 5.3
    public function afterSave(Model $Model, $created){ } //RIGHT, works everwhere :)
    

    Add App::load() to load dependencies

    Always good to check if your class is really available, so double-check if you have all the classes you depend loaded with App::load() at the beginning of the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have updated my symfony version to 2.0.12 version. But I have this error
I have recently updated the Cucumber gems ('cucumber' and 'cucumber-rails') on my machine and
I have updated my android-sdk-package from r16 to r17. I have updated the Eclipse
I have updated my website. Previously there were links like these: http://example.com/bla-bla-bla?language=de . After
I have a PHP script which fetches data from Salesforce via the Salesforce API
I have updated my jSon object using the code <script type=text/javascript > jQuery(document).ready(function($){ var
I have updated many records already, but when it came to a word that
I have updated my libraries, and now e-mails are sent without subject. I don't
I have updated code for ActiveX functionality which already installed on client(in their Windows
I have updated my packages using Android SDK Manager and clicked on Help >

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.