Req #70919 [Sus]: class declarations may not be nested - why not!?

From: Date: Sun, 27 Mar 2016 09:57:57 +0000
Subject: Req #70919 [Sus]: class declarations may not be nested - why not!?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200156@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70919&edit=1

 ID:                 70919
 Updated by:         krakjoe@php.net
 Reported by:        teo8976 at gmail dot com
 Summary:            class declarations may not be nested - why not!?
 Status:             Suspended
 Type:               Feature/Change Request
 Package:            Class/Object related
 PHP Version:        7.0.0RC7
 Block user comment: N
 Private report:     N

 New Comment:

This is well defined, expected behaviour; There is no issue, or bug.

What you are requesting is a change to the language, and as mentioned, these kinds of changes must
go through the RFC process.

Please see: https://github.com/php/php-src/blob/master/CONTRIBUTING.md#feature-requests


Previous Comments:
------------------------------------------------------------------------
[2016-03-27 09:39:00] teo8976 at gmail dot com

Oh, I see.

Anyway, if you need an RFC, this issue should stay open until somebody writes one. Writing an RFC is
part of fixing the issue (or the feature request if you prefer to call it that way).

------------------------------------------------------------------------
[2016-03-27 06:32:20] requinix@php.net

> You may have missed this:
HHVM is not PHP. They are separate entities.

------------------------------------------------------------------------
[2016-03-26 22:05:22] teo8976 at gmail dot com

> For this kind of change, an RFC is required.

You may have missed this:

> Note: this does work in hhvm. The fix should be backported to all supported versions.

------------------------------------------------------------------------
[2016-03-26 21:47:43] krakjoe@php.net

For this kind of change, an RFC is required.

Please see: https://wiki.php.net/rfc/howto

------------------------------------------------------------------------
[2015-11-16 22:28:29] teo8976 at gmail dot com

> There's no reason for that Sorter class to 
> be declared within the function, can be declared outside of it like 
> a normal class.

1) My code example is stupid, but there are PLENTY of reasons why you may want to declare it inside
a function. Of course you can declare it outside, but IT'S NOT THE SAME THING: if it is
declared inside the function, the class only exists  if and after the function is executed.

2) That possibility has existed since PHP 5.0

3) If you can do it in a "global" function, there's no reason you shouldn't be
able to do it in a class method. 

3) Note that in hhvm, rather than removing the ability to do it in a function, they have added the
ability to do it in a method. That is, they have fixed the bug already. I don't see a reason
why the fix shouldn't be backported to non-dead PHP versions.

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=70919


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


Thread (8 messages)

« previous php.bugs (#200156) next »