Re: __constructor parameter limitations.
| From: | Etienne Kneuss | Date: | Sat, 17 Sep 2011 15:21:18 +0000 |
| Subject: | Re: __constructor parameter limitations. | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-55483@lists.php.net to get a copy of this message | ||
On Sat, Sep 17, 2011 at 17:15, Laruence <laruence@php.net> wrote:
> Hi:
> this is really a big bc break...(fatal error)
> is there any reason for us to really change this? In Yaf, there
> are a lot of Abstract classes, the subclass only need declared there
> argument when they really need it.
>
Well, that is wrong. if you declare an abstract method with a set of
arguments, classes implementing that method should be compatible with that
set of arguments.
>
> and I really not think this change is good one, the Intenal class
> can not be saw by userland(sure, doc, reflection), so they only get
> the FATAL ERROR(you are wrong) but will never be told how should they
> to do..
Given that we have been quite flexible with this in the past, I don't
believe a E_FATAL is warranted here, might be better suited as a E_STRICT,
as there is no apparent reason why this would prevent the engine to
continue.
> thanks
>
> 2011/9/17 Ferenc Kovacs <tyra3l@gmail.com>:
> > maybe Richard referring to
> > https://bugs.php.net/bug.php?id=55085 ?
> > but those change only affects the abstract classes.
> >
> > Tyrael
> >
> > On Sat, Sep 17, 2011 at 3:43 PM, Nikita Popov <nikita.ppv@googlemail.com>
> wrote:
> >> Hi Richard!
> >>
> >> Which change are you talking about? I just tried doing:
> >> <?php
> >> class A { public function __construct($a) { } }
> >> class B extends A { public function __construct($a, $b) { } }
> >> And it worked on 5.4 Beta 1 without errors.
> >>
> >> Nikita
> >>
> >> On Sat, Sep 17, 2011 at 3:27 PM, Richard Quadling <rquadling@gmail.com>
> wrote:
> >>> Hi.
> >>>
> >>> With the recent BC with regard the locking of the constructor's
> >>> signature for subclasses, what is the expected mechanism for allowing
> >>> a subclass to have additional parameters?
> >>>
> >>> You can always supply them and use func_get_args() / func_num_args() /
> >>> etc. to read them.
> >>>
> >>> It would seem that the limitation restricts the capabilities. I'm not
> >>> a purist. Software development is a compromise between purity and
> >>> getting the job done in an efficient and understandable manner.
> >>>
> >>> By allowing undocumented parameters to the constructor (due to the
> >>> enforced signature), this would seem to break things on a different
> >>> front (I can't docblock non defined parameters for examples).
> >>
> >> --
> >> PHP Internals - PHP Runtime Development Mailing List
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> >
> >
> > --
> > Ferenc Kovács
> > @Tyr43l - http://tyrael.hu
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
>
> --
> Laruence Xinchen Hui
> http://www.laruence.com/
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Etienne Kneuss
http://www.colder.ch