php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74583 On Create a constructor
Submitted: 2017-05-12 14:34 UTC Modified: 2017-05-12 18:46 UTC
From: principe dot borodin at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: Irrelevant OS: Ubutntu 15.10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: principe dot borodin at gmail dot com
New email:
PHP Version: OS:

 

 [2017-05-12 14:34 UTC] principe dot borodin at gmail dot com
Description:
------------
I received the error


igor@nt-pronon06:/var/www/html/testes$ php interface.php 
PHP Catchable fatal error:  Argument 1 passed to MeToo::meToo() must implement interface Key, none given, called in /var/www/html/testes/interface.php on line 32 and defined in /var/www/html/testes/interface.php on line 22
PHP Stack trace:
PHP   1. {main}() /var/www/html/testes/interface.php:0
PHP   2. MeToo->meToo() /var/www/html/testes/interface.php:32

The php5 Still considers method with same class name as class constructor? Its was in php4?

I'm using php 5.6.11

Test script:
---------------
https://gist.github.com/IgorDePaula/e0d20c4528318dbbebb75661d9d0f4b5

Expected result:
----------------
None error given

Actual result:
--------------
igor@nt-pronon06:/var/www/html/testes$ php interface.php 
PHP Catchable fatal error:  Argument 1 passed to MeToo::meToo() must implement interface Key, none given, called in /var/www/html/testes/interface.php on line 32 and defined in /var/www/html/testes/interface.php on line 22
PHP Stack trace:
PHP   1. {main}() /var/www/html/testes/interface.php:0
PHP   2. MeToo->meToo() /var/www/html/testes/interface.php:32

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-12 14:41 UTC] peehaa@php.net
-Status: Open +Status: Not a bug
 [2017-05-12 14:41 UTC] peehaa@php.net
RTM: http://php.net/manual/en/language.oop5.decon.php

> For backwards compatibility with PHP 3 and 4, if PHP cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class. Effectively, it means that the only case that would have compatibility issues is if the class had a method named __construct() which was used for different semantics.

> Warning
> Old style constructors are DEPRECATED in PHP 7.0, and will be removed in a future version. You should always use __construct() in new code.
 [2017-05-12 18:46 UTC] requinix@php.net
-Package: PHP Language Specification +Package: Class/Object related
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 03 23:01:27 2024 UTC