On Sun, Sep 29, 2013 at 11:12 PM, Joe Watkins <krak...@php.net> wrote:

> Hi All,
>
>     I'd like to RFC on Nested Classes (Draft):
>
>         
> https://wiki.php.net/rfc/**nested_classes<https://wiki.php.net/rfc/nested_classes>
>
>     There's been a little bit of discussion already about it, in the usual
> places mostly, but also while considering anonymous classes on the lists
> ... time to make it public I guess ...
>
> Cheers
> Joe
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Hi Joe,

I really like the idea, as it is a recurring problem that you create a
library/package, what you want others to use, but there are some parts of
it, which you want to keep as a blackbox to your users, so you can change
it in the future, without breaking their code.
Currently if you want hard guarantees your only option is to keep that kind
of code in private functions, and if you put that into logically separated
classes, your only option is to use docblock comments like the @api to hint
that which parts are intended for consumption, but sadly nobody really
follows that.
So I would really like the idea of having classes which can only be
accessed from that specific component, but sadly we don't have real
packages in php with package level visibility as that could also solve this
problem.
Having nested classes could be still really useful in this scenario, so I'm
+1 on this feature, but there are a couple of questions I would like to see
answered:

   1. Would there be reflection support for this feature (currently you can
   access private methods/properties through Reflection, I think it would make
   sense to be able to do the same with the nested classes).
   2. Would it be possible to serialize/unserialize a class referencing an
   instance of a nested class without losing the information it holds?
   3. What happens when a nested class with the same name is used in two
   separate class?

What do you think?

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

Reply via email to