[PHP-DEV] Making ArrayAccess objects more array-like?

2006-09-13 Thread Terje Slettebø
Hi all. (Again, I've searched the archives, but haven't found anything on this one) The ArrayAccess interface allows one to essentially overload the index operator [] [1], which is nice, as it makes it possible to implement things like type-checked associative arrays, variants, tuples, etc.

Re: [PHP-DEV] Making ArrayAccess objects more array-like?

2006-09-13 Thread Marcus Boerger
Hello Terje, long ago we decided against supporting it in the array functions. best regards marcus Wednesday, September 13, 2006, 8:39:57 AM, you wrote: Hi all. (Again, I've searched the archives, but haven't found anything on this one) The ArrayAccess interface allows one to essentially

[PHP-DEV] Const member functions

2006-09-13 Thread Terje Slettebø
(This may be considered too radical for some, but I ask, anyway... Also, if there's a more appropropriate place to ask such questions, let me know, but as this is the developer's list, it seemed like the right place) In C++, it's possible to declare member functions const meaning they don't

Re: [PHP-DEV] Return type hints

2006-09-13 Thread Richard Quadling
On 12/09/06, Terje Slettebø [EMAIL PROTECTED] wrote: function f(Something $value) /** @return SomethingElse */ { // ... } One of the good things about PHP is the loose typing (1.00 == 1 == 1 sort of thing as I understand it). This has been useful. But one of the first things we are told

[PHP-DEV] PHP5 extensions: using existing functionnames as method names

2006-09-13 Thread danhen
Hi, i just was wondering how existing function names could be used as method names in OO-Extensions for PHP5. I've looked through the SPL-source where this is done with functions like current() and next() in the iterators, but I couldn't find a hint how to do this. Can someone give me a little

Re: [PHP-DEV] PHP5 extensions: using existing functionnames as method names

2006-09-13 Thread messju mohr
On Wed, Sep 13, 2006 at 10:09:08AM +0200, [EMAIL PROTECTED] wrote: Hi, i just was wondering how existing function names could be used as method names in OO-Extensions for PHP5. I've looked through the SPL-source where this is done with functions like current() and next() in the iterators,

Re: [PHP-DEV] PHP5 extensions: using existing function names as method names

2006-09-13 Thread danhen
...Just forgot to CC... you can use any function name as method name without a clash. you just cannot use language constructs that aren't real functions like empty, echo or require as method names. this question better belongs to php-general, btw. Sorry if I didn't made myself clear enough. I'm

Re: [PHP-DEV] Return type hints

2006-09-13 Thread Terje Slettebø
From: Richard Quadling [EMAIL PROTECTED] On 12/09/06, Terje Slettebø [EMAIL PROTECTED] wrote: function f(Something $value) /** @return SomethingElse */ { // ... } One of the good things about PHP is the loose typing (1.00 == 1 == 1 sort of thing as I understand it). This has been

Re: [PHP-DEV] Return type hints

2006-09-13 Thread Richard Quadling
On 13/09/06, Terje Slettebø [EMAIL PROTECTED] wrote: From: Richard Quadling [EMAIL PROTECTED] On 12/09/06, Terje Slettebø [EMAIL PROTECTED] wrote: function f(Something $value) /** @return SomethingElse */ { // ... } But one of the first things we are told about using PHP ITRW is

[PHP-DEV] Re: Tweaking expects parameter # to be... message

2006-09-13 Thread Hannes Magnusson
Either way is fine with me, as long as I get the class name in the warning -Hannes On 9/11/06, Marcus Boerger [EMAIL PROTECTED] wrote: Hello Andrei, for some reason i like instance of class better than class object. The reason is that we have instances rather than objects - So it's a purist

Re: [PHP-DEV] Return type hints

2006-09-13 Thread Ron Korving
Richard Quadling [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED] On 13/09/06, Terje Slettebø [EMAIL PROTECTED] wrote: .. The issue then becomes what would happen to a value of the wrong type? You either have the option of using PHP's own internal casting mechanism, so

Re: [PHP-DEV] PHP5 extensions: using existing functionnames as method names

2006-09-13 Thread Pierre
On Wed, 13 Sep 2006 11:35:16 +0200 [EMAIL PROTECTED] wrote: ...Just forgot to CC... you can use any function name as method name without a clash. you just cannot use language constructs that aren't real functions like empty, echo or require as method names. this question better belongs to

Re: [PHP-DEV] Making ArrayAccess objects more array-like?

2006-09-13 Thread Terje Slettebø
Hi Marcus. long ago we decided against supporting it in the array functions. Ok, thanks. Could I ask what the reasons were (Alternatively get a pointer to the discussion)? Regards, Terje best regards marcus Wednesday, September 13, 2006, 8:39:57 AM, you wrote: Hi all. (Again,

Re: [PHP-DEV] PHP5 extensions: using existing function names as method names

2006-09-13 Thread danhen
It is possible to name a method like an existing function, I'm not sure what you are doing exactly but it works here. I've tried: STRING_METHOD(String, trim) {...} (Yes, I'm trying to build a string class) that means that I also redefinied the Macros. Then I've changed the Macros from

Re: [PHP-DEV] Return type hints

2006-09-13 Thread Brian Moon
Terje Slettebø wrote: I'd say that's debatable. :) Yes, it can make it more convenient to handle data coming from outside the script (such as forms), but it can also hide bugs. While it can be argued that conversions between, say, arithmetic types (int and floats) may be useful, allowing

Re: [PHP-DEV] PHP5 extensions: using existing functionnames as method names

2006-09-13 Thread Pierre
Hello, On 9/13/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: It is possible to name a method like an existing function, I'm not sure what you are doing exactly but it works here. I've tried: STRING_METHOD(String, trim) {...} (Yes, I'm trying to build a string class) that means that I also

Re: [PHP-DEV] PHP5 extensions: using existing functionnames as method names

2006-09-13 Thread Pierre
On 9/13/06, Pierre [EMAIL PROTECTED] wrote: No, as I said it works well before 5.2 except for zip_* function name and a uip class. I mean for zip_* function names and a zip class :) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP5 extensions: using existing functio nnames as method names

2006-09-13 Thread danhen
Can you show some code? It will help to figure out what's wrong. Yes I can :) stringclass.h #ifndef PHP_STRINGCLASS_H #define PHP_STRINGCLASS_H extern zend_module_entry string_module_entry; #define phpext_string_ptr string_module_entry #ifdef PHP_WIN32 #define PHP_STRING_API

Re: [PHP-DEV] PHP5 extensions: using existing functionnames as method names

2006-09-13 Thread Sara Golemon
zend_module_entry string_module_entry = { #if ZEND_MODULE_API_NO = 20010901 STANDARD_MODULE_HEADER, #endif string, string_functions, PHP_MINIT(string), PHP_MSHUTDOWN(string), PHP_RINIT(string), /* Replace with NULL if there's nothing to do at request start */

Re: [PHP-DEV] Re: Tweaking expects parameter # to be... message

2006-09-13 Thread Andrei Zmievski
Show me how many times we use instance versus object in PHP. -Andrei On Sep 11, 2006, at 5:31 PM, Marcus Boerger wrote: Hello Andrei, for some reason i like instance of class better than class object. The reason is that we have instances rather than objects - So it's a purist thing.

Re: [PHP-DEV] PHP5 extensions: using existing function names as method

2006-09-13 Thread danhen
Solution: Change string_functions to NULL in zend_module_entry. Thanks! You rescued my extension. Now I can finish and test the class. #define STRING_METHOD(function_name) \ ZEND_NAMED_FUNCTION(c_stringclass_##function_name) #define STRING_ME(name, arg_info, flags) \

Re: [PHP-DEV] Const member functions

2006-09-13 Thread Stanislav Malyshev
In C++, it's possible to declare member functions const meaning they don't change the object they operate on. This can help reason about programs, because if you have something like (PHP syntax): It would be pretty hard to enforce in PHP - how do you know the object is not changed, without

Re: [PHP-DEV] Return type hints

2006-09-13 Thread Terje Slettebø
Terje Slettebø wrote: I'd say that's debatable. :) Yes, it can make it more convenient to handle data coming from outside the script (such as forms), but it can also hide bugs. While it can be argued that conversions between, say, arithmetic types (int and floats) may be useful, allowing

Re: [PHP-DEV] Const member functions

2006-09-13 Thread Terje Slettebø
In C++, it's possible to declare member functions const meaning they don't change the object they operate on. This can help reason about programs, because if you have something like (PHP syntax): It would be pretty hard to enforce in PHP - how do you know the object is not changed,

Re: [PHP-DEV] Return type hints

2006-09-13 Thread Brian Moon
--- Start --- class Something { public function __construct() { // Oops, forgot to initialise $this-something... } public function f() { return $this-something; } private $something; } error_reporting(E_ALL); $something=new Something; echo $something-f()+10; // Prints

Re: [PHP-DEV] Making ArrayAccess objects more array-like?

2006-09-13 Thread Marcus Boerger
Hello Terje, sorry i often only remember the outcome. best regards marcus Wednesday, September 13, 2006, 9:52:57 AM, you wrote: Hi Marcus. long ago we decided against supporting it in the array functions. Ok, thanks. Could I ask what the reasons were (Alternatively get a pointer to

[PHP-DEV] Re: Re: __autoloading and functions

2006-09-13 Thread Terje Slettebø
Hi François. I think this sounds like a great idea. :) We do something similar with our class loader, in that it scans a lib-directory and its subfolders, building a map of class name to filename (it doesn't open the files - it only builds the map based on file naming convention, allowing it to

Re: [PHP-DEV] Return type hints

2006-09-13 Thread Terje Slettebø
From: Brian Moon [EMAIL PROTECTED] --- Start --- class Something { public function __construct() { // Oops, forgot to initialise $this-something... } public function f() { return $this-something; } private $something; }