Re: [PHP-DEV] Cannot call constructor

2013-05-29 Thread Richard Lynch
First, thanks for all the comments!

Responding in-line to myself to address everything so far in this thread:

On Thu, May 23, 2013 4:24 pm, Richard Lynch wrote:
 Consider this common scenario:

 I use some OOP library, that is a black box and I like it that way.

This was a made-up scenario.

Well, somewhat...

In my experience, this sort of thing usually happens in the corporate
environment with Jr. Programmer, rather than in publicly-released
libraries.

Educating Jr. Programmer regarding documentation needs to happen and
will happen, but it will probably be out-of-band from using their
code.

 if (method_exists(get_parent_class(), '__construct'))
 parent::__construct();

99% of the time, I need to call their constructor before mine to
initialize stuff.

I'm very pragmatic.

If PHP had default __construct, and in the absence of [decent] docs
for the parent, I'm going to call the parent constructor first and
pray.

I thought all PHP user-land class were rooted in stdClass. The class
functions that display hierarchy obscure that, but there it's there
under the hood.

If so, adding the magic anti-pattern methods to stdClass would be
easy, right?

Extensions that return PHP objects should get the free ride from
stdClass, I would expect.

The sample init() pattern or whatever from Etienne made my eyes
un-focus in the first couple lines.
I'm not saying it's not the better pattern, or even that what I
propose isn't an anti-pattern.
Just it was way too complicated for what I need 99% of the time.
I'm sure if I *needed* that particular pattern's properties it would
make a whole lot more sense.

My thoughts on which magic methods [don't] fit this treatment:

DO FIT
__construct: 99% I let them init their stuff, and I init mine
__destruct: I tear down my stuff, and call the parent
__toString: I would imagine children tacking on
(actually, I think parent::__toString being safe might be baked in
already, as all classes have a toString, right?...)
__call*: Parent first, do my stuff, usually return parent result
__invoke? Never used it, don't like it, basing on description

DO NOT FIT
__sleep
__wakeup
__get
__set
__isset
__set_state Already effectively calls all descendants if the first
note is correct...
__clone Already has an :after method __done() to deal with this

I'm not particularly strongly for or against any of them except
__construct __destruct

Well, __set_state and __clone pretty much have to be the NOT FIT pile,
as far as I can see.

Again, I'm VERY pragmatic. The base object having __construct and
__destruct so I can call them in FIFO/LIFO order covers 99% of the use
cases.

If I was writing an RFC today, and I'm not until there is a little
more discussion on-list, I would explicitly include only ctor/dtor in
it as a trial, and leave the rest for later. Or never if that's
the way it pans out.



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] date.timezone E_WARNING -- Really necessary? What's the rationale?

2013-05-29 Thread Richard Lynch
On Thu, May 23, 2013 3:10 pm, Stas Malyshev wrote:
 I'm probably not the typical PHP user; I spend 99% of my PHP time
 using the CLI (and not web SAPIs).
 This means that I frequently run PHP without an .ini file. As a

 I'm not sure how this follows - CLI is capable of using ini file just
 like the rest of SAPIs. Why not create it?

 The U in UTC *does* stand for Universal, after all. It's a
 sensible default and as such shouldn't

 I don't think it's a sensible default - people don't actually use UTC
 when considering dates. A minority of people can use timezone that
 coincides with UTC, but not very many use actual UTC.

I don't know about everybody else, but if I need a timezone-aware
application, I always use GMT/UTC and have I/O routines for
user-interface to convert to local for them.



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php