Bug #74583 [Opn->Nab]: On Create a constructor

[email protected] Fri, 12 May 2017 14:41:45 GMT
Newsgroups php.standards
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=74583&edit=1

 ID:                 74583
 Updated by:         [email protected]
 Reported by:        principe dot borodin at gmail dot com
 Summary:            On Create a constructor
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            PHP Language Specification
 Operating System:   Ubutntu 15.10
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2017-05-12 14:34:44] 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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=74583&edit=1