[PHP-DEV] SVN Account Request: afshin

2011-02-03 Thread Afshin Mehrabani
Translating the documentation

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



[PHP-DEV] A quick consensus on magic method idea

2011-02-03 Thread Chris Stockton
Hello,

I haven't seen a magic method proposed in a while so I am not sure how
people feel about them, obviously adding them can break BC (although
it is recommended people should not use __). I'm sure a good amount of
use/desire needs to be shown for inclusion. Here is what I decided I
would like to have and just implemented:

Loader.php:
--
class Loader {
  static public function __compiled() {
echo I was ran at the end of zend_do_end_class_declaration;
  }
}

Run script:
?php
include Loader.php;

Prints:
I was ran at the end of zend_do_end_class_declaration

At first thought I figured this would be pretty simple to implement,
which it is.. for a basic use case. It seems I will need a bit more
work to handle issues when you do certain things inside __compiled. If
anyone has any interest I would fix it and make a clean patch, so
would anyone find this useful?

-Chris

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



Re: [PHP-DEV] A quick consensus on magic method idea

2011-02-03 Thread Ben Schmidt

On 4/02/11 3:30 PM, Chris Stockton wrote:

Hello,

I haven't seen a magic method proposed in a while so I am not sure how
people feel about them, obviously adding them can break BC (although
it is recommended people should not use __). I'm sure a good amount of
use/desire needs to be shown for inclusion. Here is what I decided I
would like to have and just implemented:

Loader.php:
--
class Loader {
   static public function __compiled() {
 echo I was ran at the end of zend_do_end_class_declaration;
   }
}

Run script:
?php
include Loader.php;

Prints:
I was ran at the end of zend_do_end_class_declaration

At first thought I figured this would be pretty simple to implement,
which it is.. for a basic use case. It seems I will need a bit more
work to handle issues when you do certain things inside __compiled. If
anyone has any interest I would fix it and make a clean patch, so
would anyone find this useful?


Do you yourself have any situation where this is useful? Does it solve
some problem? Does it enable you to do things better than before?

Ben.




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



Re: [PHP-DEV] A quick consensus on magic method idea

2011-02-03 Thread Chris Stockton
Hello,

On Thu, Feb 3, 2011 at 8:38 PM, Ben Schmidt
mail_ben_schm...@yahoo.com.au wrote:

 Do you yourself have any situation where this is useful? Does it solve
 some problem? Does it enable you to do things better than before?

 Ben.


It does not provide a solution to a currently unsolvable problem, it
is simply a convenience for situations when you want a class to
perform any kind of initialization directly after compilation/loading
(whatever term you find easier on the ears).

It provides a cleaner more encapsulated approach to a (not entirely
uncommon) case such as:

Foo.php:
class Foo {
  // class body
}

Foo::registerSomeStuff();


Just a idea I wanted to share,

-Chris

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



Re: [PHP-DEV] A quick consensus on magic method idea

2011-02-03 Thread Rasmus Lerdorf
On 2/3/11 8:49 PM, Chris Stockton wrote:
 Hello,
 
 On Thu, Feb 3, 2011 at 8:38 PM, Ben Schmidt
 mail_ben_schm...@yahoo.com.au wrote:

 Do you yourself have any situation where this is useful? Does it solve
 some problem? Does it enable you to do things better than before?

 Ben.

 
 It does not provide a solution to a currently unsolvable problem, it
 is simply a convenience for situations when you want a class to
 perform any kind of initialization directly after compilation/loading
 (whatever term you find easier on the ears).

This creates problems for opcode caches since the classes are all
precompiled and usually optimized to the point where the opcodes that
loads them are NOP'ed away and you just have the full class table cached
in memory for each op_array.  Walking through that class table on every
request and looking for these magic methods to call would be quite
annoying, especially since most of them wouldn't have such a method to
begin with.

-Rasmus

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



Re: [PHP-DEV] A quick consensus on magic method idea

2011-02-03 Thread Chris Stockton
Hello,

On Thu, Feb 3, 2011 at 8:53 PM, Rasmus Lerdorf ras...@lerdorf.com wrote:

 This creates problems for opcode caches since the classes are all
 precompiled and usually optimized to the point where the opcodes that
 loads them are NOP'ed away and you just have the full class table cached
 in memory for each op_array.  Walking through that class table on every
 request and looking for these magic methods to call would be quite
 annoying, especially since most of them wouldn't have such a method to
 begin with.


That is a good point and something I didn't think about. The pain that
would create immediately negates the small luxury it would add.

Thanks,

-Chris

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