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

  • SEARCH
  • Home
  • 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 937963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:33:47+00:00 2026-05-15T21:33:47+00:00

i declared classes like this: class Foo{ public function __construct(){ echo ‘Foo was created!’;}

  • 0

i declared classes like this:

class Foo{ public function __construct(){ echo 'Foo was created!';} }

class Foo2 extends Foo{ public function __construct(){ parent::__construct(); echo 'Foo2 was created!';} }

class Bar{
    public function __construct(Foo $foo){ echo 'Bar was created!';}
}

in main code:

$foo2 = new Foo2();
$bar = new Bar($foo2);

What is reason of this error in main code:

Fatal error: Default value for parameters with a class type hint can only be NULL

php version: PHP 5.3.2

————————————–Updated!—————————————-

file: system.data.php

namespace system\data{

    include ('system.php');

    use system;    
class DBConnection implements system\IDisposable {
    protected $serverName;
    protected $userId;
    protected $password;
    protected $handler;
    protected $isOpened;

    /*
     * create a new instance of DBConnection.
    */
    public function __construct($server, $uid, $password) {
        $this->isOpened = false;
        $this->serverName = $server;
        $this->userId = $uid;
        $this->password = $password;
    }
class DBCommand implements \system\IDisposable {

    public function  __construct(DBConnection $connection, int $type) {
        $this->connection = $connection;
        $this->queryType= $type;
}

}

file: system.data.mysql.php

namespace system\data\mysql{
    class MySqlCommand extends DBCommand {

        public function __construct(data\DBConnection $connection, int $type = 0) {
            parent::__construct($connection, $type);
        }
    }

class MySqlConnection extends DBConnection {

    public function  __construct($server, $uid, $password) {
        parent::__construct($server, $uid, $password);
        }

    }
}

error:

Fatal error: Default value for parameters with a class type hint can only be NULL in C:\Program Files\Apache Software Foundation\...\system.data.mysql.php on line 35(constructor declartion) 
  • 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-05-15T21:33:48+00:00Added an answer on May 15, 2026 at 9:33 pm

    Thank you for the full code, here’s your error:

    public function __construct(data\DBConnection $connection, int $type = 0)
    

    PHP 5.3 only supports type hinting for arrays and classes.

    Your declaration of int $type = 0 is looking for a class named “int”, and parses it as such, even if the class doesn’t exist.

    You’ll need to remove the bogus type hint. The PHP developers are considering adding other type hints in the future. There’s currently code in PHP’s trunk to perform type hinting for scalar values, but much has changed since that blog article was posted. I’ll see if I can track down the current state of things, but searching the PHP internals mailing list is a dreadfully horrible task.


    Edit: After digging through PHP Internals, I found the latest Type Hinting thread. It looks like this the current Type Hinting RFC, but there doesn’t appear to be consensus on the direction. Zeev wanted to rollback the commit, but it’s not clear if that was done.

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

Sidebar

Ask A Question

Stats

  • Questions 494k
  • Answers 494k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is actually really rather simple: The application is likely… May 16, 2026 at 10:59 am
  • Editorial Team
    Editorial Team added an answer I wrote a post-commit hook for just this purpose. The… May 16, 2026 at 10:59 am
  • Editorial Team
    Editorial Team added an answer A DataRow knows which table it's in, so two rows… May 16, 2026 at 10:59 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I would like to do something like this: public class Foobar { @Tag final
Consider this abstract class public abstract class Foo { public Injectable Prop {get;set;} }
I have an interesting problem. Consider this class hierachy: class Base { public: virtual
I would like to use factory classes and methods to generate GUI components, but
I have two classes. One is a management class, which stores a bunch of
here i am again ;) My problem atm is with nested php classes, i
I'm in the process of reverse-engineering a Windows executable. I found a class that
I code in Python a lot, and I frequently create classes. Now, I'm not
I know this question must have been covered endless of times, but I've searched
I am using a custom class based off RelativeLayout but it obviously doesn't render

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.