php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62859 Give __construct() the respect it deserves
Submitted: 2012-08-18 19:48 UTC Modified: 2012-08-20 01:32 UTC
From: michaelduff2 at yahoo dot com Assigned:
Status: Wont fix Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-08-18 19:48 UTC] michaelduff2 at yahoo dot com
Description:
------------
Here's a PHP6 -- or PHP7 ;) request for you; many will scream NOOOOoooooooo, but hear me out:

Make it possible to return an object from __construct().

Yeah, I said it. Sounds crazy, but this would make factories more abstract, and enables all sorts of magic without user code being any wiser (unless they Reflect upon it, I suppose.)

For type safety, the object returned should probably be an instanceof __CLASS__.

If no return() exists, then normal 'new' semantics would apply.

Discuss.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-20 01:32 UTC] aharvey@php.net
Given that you can already implement factories perfectly well via static methods, I can't think of any use for this that doesn't end in making code less clear.

If you want a discussion, write an RFC and post it to Internals, but I can't see this getting up.
 [2012-08-20 01:32 UTC] aharvey@php.net
-Status: Open +Status: Wont fix
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 03:01:28 2024 UTC