Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Ferenc Kovacs
this one looks much more intuitive. Tyrael 2009/7/2 Ford, Mike : > > >> -Original Message- >> From: Lukas Kahwe Smith [mailto:m...@pooteeweet.org] >> Sent: 02 July 2009 14:05 >> To: Ilia Alshanetsky >> Cc: Paul Biggar; PHP Internals; Derick Rethans; Stanislav Malyshev; >> Hannes Magnusson

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Ólafur Waage
On Thu, Jul 2, 2009 at 9:09 PM, Ryan Panning wrote: > Ford, Mike wrote: > >>function func(int $i) >> >> for strict type checking, and >> >>function func((int)$i) >> >> for coercion aka casting (although now I've seen it written down I'm not >> so sure! ;). >> > > Just want to throw my 2 c

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Ryan Panning
Ford, Mike wrote: function func(int $i) for strict type checking, and function func((int)$i) for coercion aka casting (although now I've seen it written down I'm not so sure! ;). Just want to throw my 2 cents in. Big +1 for this syntax I think with the addition of this and __cast()

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Kalle Sommer Nielsen
Hi 2009/7/2 Stanislav Malyshev : > Without saying anything on the merits of having both syntaxes, visually I > think this looks much nicer, even with the disadvantage of parentheses > overload. I agree, using the type cast operators for casting to the type, and non parentheses for strict checking

Re: [PHP-DEV] PHP 5.3.0, phar symlink breaks rpm building.

2009-07-02 Thread Rasmus Lerdorf
Xyntrix wrote: > Congratulations on the 5.3 milestone! > > Packaging the 5.3.0 stable release into an RPM (linux) will error as the > bin/phar symlink is created using the build-time path variable. This has been > submitted as bug: > > http://bugs.php.net/bug.php?id=48740 > > Patch: > > --- p

[PHP-DEV] PHP 5.3.0, phar symlink breaks rpm building.

2009-07-02 Thread Xyntrix
Congratulations on the 5.3 milestone! Packaging the 5.3.0 stable release into an RPM (linux) will error as the bin/phar symlink is created using the build-time path variable. This has been submitted as bug: http://bugs.php.net/bug.php?id=48740 Patch: --- php-5.3.0/ext/phar/Makefile.frag.orig

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Stanislav Malyshev
Hi! function func(int $i) for strict type checking, and function func((int)$i) Without saying anything on the merits of having both syntaxes, visually I think this looks much nicer, even with the disadvantage of parentheses overload. -- Stanislav Malyshev, Zend Software Architect

RE: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Ford, Mike
> -Original Message- > From: Lukas Kahwe Smith [mailto:m...@pooteeweet.org] > Sent: 02 July 2009 14:05 > To: Ilia Alshanetsky > Cc: Paul Biggar; PHP Internals; Derick Rethans; Stanislav Malyshev; > Hannes Magnusson > Subject: Re: [PHP-DEV] Re: Flexible type hinting > > > On 02.07.2009,

Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3

2009-07-02 Thread Alain Williams
On Thu, Jul 02, 2009 at 09:59:43AM -0700, Stanislav Malyshev wrote: > >A big +1 from me to incorporate type hinting into PHP. > > I think calling this proposal "type hinting" just confuses the > discussion. It's (optional) strict typing and it should be called so. +1 But first we must fix the

Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3

2009-07-02 Thread Stanislav Malyshev
Hi! Doesn't "stuff their code with explicit type conversions" actually mean "perform appropriate validation and conversion on incoming data" ? Sometimes it does, but in many cases it doesn't - since variables are not typed and types can be juggled, you'd have to take precautions even though

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Stanislav Malyshev
Hi! Are optional argument specifications inherited? I did not think they were, but its not clear if you are saying they are. Of course they are - how couldn't they be, they are part of method definition. My understanding of PHP's optional arguments is that they only apply to a function onc

Re: [PHP-DEV] constructors are callable as regular functions.

2009-07-02 Thread Kalle Sommer Nielsen
2009/7/2 troels knak-nielsen : > [snip] ... - I don't remember ever > seen __construct() called directly. Its commonly done when extending reflection for example, or to populate the Exception class constructor when extending it: code = (integer) $code; parent::__construct($message);

Re: [PHP-DEV] constructors are callable as regular functions.

2009-07-02 Thread Greg Beaver
troels knak-nielsen wrote: > On Thu, Jul 2, 2009 at 4:47 PM, Edward Z. Yang wrote: >> Excerpts from troels knak-nielsen's message of Thu Jul 02 10:14:18 -0400 >> 2009: >>> I would have expected the second call to __construct() to yield an error. >> Why should it? Especially since this is idiomatic

Re: [PHP-DEV] constructors are callable as regular functions.

2009-07-02 Thread Edward Z. Yang
Excerpts from troels knak-nielsen's message of Thu Jul 02 10:55:48 -0400 2009: > I understand that. It's not a technical issue - It's more a matter of > language semantics. Constructors are used for initializing state on an > object. Basically, this behaviour makes it impossible to implement > immu

Re: [PHP-DEV] constructors are callable as regular functions.

2009-07-02 Thread troels knak-nielsen
On Thu, Jul 2, 2009 at 4:47 PM, Edward Z. Yang wrote: > Excerpts from troels knak-nielsen's message of Thu Jul 02 10:14:18 -0400 2009: >> I would have expected the second call to __construct() to yield an error. > > Why should it? Especially since this is idiomatic code: > > class A { >  public fun

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Lewis Wright
2009/7/2 Paul Biggar > On Thu, Jul 2, 2009 at 3:17 PM, Jonathan Bond-Caron > wrote: > > From userland, I'm a big fan of this proposal / agree to the principle > although I'm not convinced that > > > > function($quantity) > > function(int $quantity) > > function(+int $quantity) > > function(-int $

Re: [PHP-DEV] constructors are callable as regular functions.

2009-07-02 Thread Edward Z. Yang
Excerpts from troels knak-nielsen's message of Thu Jul 02 10:14:18 -0400 2009: > I would have expected the second call to __construct() to yield an error. Why should it? Especially since this is idiomatic code: class A { public function __construct($a) { $this->a = $a; } } class B extend

Re: [PHP-DEV] constructors are callable as regular functions.

2009-07-02 Thread Kalle Sommer Nielsen
2009/7/2 troels knak-nielsen : > Has this been discussed before? In that case, was it decided to go > with this behaviour or is it purely accidental? Are there perhaps some > implementation issues in preventing the second call to __construct()? Magic methods can always be called directly because t

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Paul Biggar
On Thu, Jul 2, 2009 at 3:17 PM, Jonathan Bond-Caron wrote: > From userland, I'm a big fan of this proposal / agree to the principle > although I'm not convinced that > > function($quantity) > function(int $quantity) > function(+int $quantity) > function(-int $quantity) > > looks appropriate... > >

RE: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Jonathan Bond-Caron
On Thu Jul 2 08:53 AM, Paul Biggar wrote: > On Thu, Jul 2, 2009 at 1:43 PM, Ilia Alshanetsky wrote: > > > > On 2-Jul-09, at 4:45 AM, Paul Biggar wrote: > >> I think you might not have read what I suggested (it is different > >> than the one I emailed to you privately). What you want is fully > sup

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Ilia Alshanetsky
On 2-Jul-09, at 10:02 AM, Paul Biggar wrote: On Thu, Jul 2, 2009 at 1:53 PM, Ilia Alshanetsky wrote: Paul's proposal is some part does not make sense because it allows weak type hinting, which should not be used if you need type hinting. The whole idea about type hinting is definition of st

[PHP-DEV] constructors are callable as regular functions.

2009-07-02 Thread troels knak-nielsen
I just realised that the following is valid php code: class Foo { function __construct() { echo "constructor called\n"; } } $f = new Foo(); $f->__construct(); Output: constructor called constructor called I would have expected the second call to __con

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Paul Biggar
On Thu, Jul 2, 2009 at 1:53 PM, Ilia Alshanetsky wrote: > Paul's proposal is some part does not make sense because it allows weak type > hinting, which should not be used if you need type hinting. The whole idea > about type hinting is definition of strict interfaces, not loosely based > one. That'

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Robert Cummings
Ilia Alshanetsky wrote: On 2-Jul-09, at 9:04 AM, Robert Cummings wrote: Ilia Alshanetsky wrote: Paul's proposal is some part does not make sense because it allows weak type hinting, which should not be used if you need type hinting. The whole idea about type hinting is definition of stri

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Robert Cummings
Ilia Alshanetsky wrote: On 2-Jul-09, at 9:23 AM, Robert Cummings wrote: Ilia Alshanetsky wrote: On 2-Jul-09, at 9:04 AM, Robert Cummings wrote: Ilia Alshanetsky wrote: Paul's proposal is some part does not make sense because it allows weak type hinting, which should not be used if you

Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3

2009-07-02 Thread Kalle Sommer Nielsen
2009/7/2 Robert Cummings : > Ionut G. Stan wrote: > I think it should be E_WARNING with auto type juggling if bad data comes > through. This way it behaves as normal PHP code does without special > handling to mitigate a script failure. The log files will still alert you to > the problem, and if yo

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Ilia Alshanetsky
On 2-Jul-09, at 9:23 AM, Robert Cummings wrote: Ilia Alshanetsky wrote: On 2-Jul-09, at 9:04 AM, Robert Cummings wrote: Ilia Alshanetsky wrote: Paul's proposal is some part does not make sense because it allows weak type hinting, which should not be used if you need type hinting. The

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Ilia Alshanetsky
On 2-Jul-09, at 9:04 AM, Robert Cummings wrote: Ilia Alshanetsky wrote: Paul's proposal is some part does not make sense because it allows weak type hinting, which should not be used if you need type hinting. The whole idea about type hinting is definition of strict interfaces, not lo

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Lukas Kahwe Smith
On 02.07.2009, at 15:02, Ilia Alshanetsky wrote: Personally, I am uncertain about +int or -int in general, IMO that compromise will eventually be identical to numeric an cause endless confusion for the users between (+/-)int and int. The reason I used a completely different name is to prev

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Robert Cummings
Ilia Alshanetsky wrote: Paul's proposal is some part does not make sense because it allows weak type hinting, which should not be used if you need type hinting. The whole idea about type hinting is definition of strict interfaces, not loosely based one. That's just my opinion, which admitte

[PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Ilia Alshanetsky
Personally, I am uncertain about +int or -int in general, IMO that compromise will eventually be identical to numeric an cause endless confusion for the users between (+/-)int and int. The reason I used a completely different name is to prevent confusion. On 2-Jul-09, at 8:53 AM, Paul Bigg

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Ilia Alshanetsky
On 2-Jul-09, at 4:56 AM, Lukas Kahwe Smith wrote: On 02.07.2009, at 10:45, Paul Biggar wrote: to work in a future with a library/framework that is strict about its input or some far fetched idea that it will change the very nature of PHP. I don't think we are worried about it changing PH

[PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Paul Biggar
On Thu, Jul 2, 2009 at 1:43 PM, Ilia Alshanetsky wrote: > > On 2-Jul-09, at 4:45 AM, Paul Biggar wrote: >> I think you might not have read what I suggested (it is different than >> the one I emailed to you privately). What you want is fully supported. >> If you must be passed an int, use the +int h

[PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Ilia Alshanetsky
On 2-Jul-09, at 4:45 AM, Paul Biggar wrote: On Thu, Jul 2, 2009 at 5:26 AM, Ilia Alshanetsky wrote: 1) Strict type hinting helps to solve bugs, both the ones made out of careless/missing validation as well as subtle logic bugs that often take hours to resolve. I can tell you that within a w

[PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Ilia Alshanetsky
On 2-Jul-09, at 3:28 AM, Stanislav Malyshev wrote: Hi! 2) Type hinting will not create a mess of cast to the right types in the code as Stas had suggested, in close to a million lines of PHP code we have, I've been able to find less then 1000 (just did a grep) instances of casts. There i

Re: [PHP-DEV] RFC: Boxing and Unboxing

2009-07-02 Thread Lukas Kahwe Smith
Hi, I recommend that you sign up on the wiki and publish your proposal on wiki.php.net/rfc regards, Lukas -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3

2009-07-02 Thread Richard Quadling
2009/7/1 Stanislav Malyshev : > Hi! > >> The patch is available here: http://ia.gd/patch/type_hint_53.txt > > Technical comment: as this patch changes binary API this shouldn't happen in > 5.3 branch. So maybe it's better to make it for 6. > > As for the idea itself, it is obvious that many people

Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3

2009-07-02 Thread Robert Cummings
Ionut G. Stan wrote: On 7/2/2009 13:56, Hannes Magnusson wrote: Actually, I'd use an exception class which extends from the builtin ErrorException class, but that's not the point. Anyway, probably Kalle Sommer Nielsen is right, and the way PHP already behaves in that regard should be kept.

Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3

2009-07-02 Thread Ionut G. Stan
On 7/2/2009 13:56, Hannes Magnusson wrote: Actually, I'd use an exception class which extends from the builtin ErrorException class, but that's not the point. Anyway, probably Kalle Sommer Nielsen is right, and the way PHP already behaves in that regard should be kept. At least for now.

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Giorgio Sironi
I'm an advocate for introducing optional type hinting as I write many assert('is_*($foo)') a day. On Thu, Jul 2, 2009 at 9:28 AM, Stanislav Malyshev wrote: > And there's only two ways to do it - either make absolutely all functions > and variables that interact with typehinted functions to be st

Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3

2009-07-02 Thread Hannes Magnusson
On Thu, Jul 2, 2009 at 11:24, Ionut G. Stan wrote: > Hi, > > I'm a userland developer with limited C skills, and while I don't yet have > an > opinion on the whole type enforcing issue, aside from a fear of libraries > abusing > it, I'd like to propose a little change in the patch. > > Is it possib

[PHP-DEV] Re: [PHP] Re: PHP 5.3.0 Released!

2009-07-02 Thread Michael A. Peters
Nick Cooper wrote: Does anyone have any further information on the PECL Binaries for 5.3, will they be released? I don't, but I suspect it is just a matter of compile + test. On Linux (CentOS) I've only done testing with i386 but none of the pecl modules I personally am using w/ 5.2.9 failed

Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3

2009-07-02 Thread Kalle Sommer Nielsen
Hi 2009/7/2 Ionut G. Stan : > Is it possible that instead of an E_RECOVERABLE_ERROR, an Exception to > be thrown? I don't know whether InvalidArgumentException satisfies the > semantics, > but it's a step in that direction. I don't think we should start changing the standard way of the engine to

[PHP-DEV] Tiny correction to type hinting patch

2009-07-02 Thread Gwynne Raskind
In Ilia's type hinting patch, on line 255, is the line: +"string"|"binary"|"unicode" { This failed for me. I fixed it by changing it to: +("string"|"binary"|"unicode") { Which matches all the other lexing rules for type hints. My understanding of the lexer is insufficient to understand why t

Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3

2009-07-02 Thread Ionut G. Stan
Hi, I'm a userland developer with limited C skills, and while I don't yet have an opinion on the whole type enforcing issue, aside from a fear of libraries abusing it, I'd like to propose a little change in the patch. Is it possible that instead of an E_RECOVERABLE_ERROR, an Exception to be t

[PHP-DEV] Re: [PHP] Re: PHP 5.3.0 Released!

2009-07-02 Thread Nick Cooper
Does anyone have any further information on the PECL Binaries for 5.3, will they be released? 2009/6/30 pan > Lukas Kahwe Smith wrote: > >> Hello! > >> > >> The PHP Development Team would like to announce the immediate release > >> of PHP 5.3.0. This release is a major improvement in the 5.X ser

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Lukas Kahwe Smith
On 02.07.2009, at 10:45, Paul Biggar wrote: to work in a future with a library/framework that is strict about its input or some far fetched idea that it will change the very nature of PHP. I don't think we are worried about it changing PHP, or about libraries using strict type hints. We are

[PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Paul Biggar
On Thu, Jul 2, 2009 at 5:26 AM, Ilia Alshanetsky wrote: > 1) Strict type hinting helps to solve bugs, both the ones made out of > careless/missing validation as well as subtle logic bugs that often take > hours to resolve. I can tell you that within a week of implementing type > hints we've been a

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Paul Biggar
On Thu, Jul 2, 2009 at 9:27 AM, Stanislav Malyshev wrote: > There is a functionality handling default values (or, more precisely, > optional arguments) with inheritance, etc. Are optional argument specifications inherited? I did not think they were, but its not clear if you are saying they are. M

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Stanislav Malyshev
Hi! I don't think we need to worry about this. Consider it to be the same as default values. So yes, yes, allowed but dont do anything since those functions are never called. There is a functionality handling default values (or, more precisely, optional arguments) with inheritance, etc. And i

Re: [PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Paul Biggar
On Thu, Jul 2, 2009 at 8:28 AM, Stanislav Malyshev wrote: > Also, looking at the patch I think it doesn't cover the matter of inheriting > the typehinted methods - i.e. if there's a typehinted method, could I > override it with non-typehinted version or vice versa? What about typehinted > interface

[PHP-DEV] SOAPClient authentication problem

2009-07-02 Thread Davide Romanini
I sent this message to the php.soap newsgroup, but noone answered me. Today I found a nasty problem with a simple php SOAP client. Never had problems before, but today I have the following error at SOAPClient constructor line: SoapClient::SoapClient(http://www.w3.org/2001/xml.xsd): failed to ope

[PHP-DEV] Re: Type hinting revisited for PHP 5.3

2009-07-02 Thread Peter Beverloo
Hello, For what it's worth, a large +1 from me. One concern I do have, however, is that the addition of scalar type hints will put more attention to the lack of method overloading. Right now methods can accept multiple values due to the type-lessness, and while it will remain a possibility, c

[PHP-DEV] Re: Flexible type hinting

2009-07-02 Thread Stanislav Malyshev
Hi! 2) Type hinting will not create a mess of cast to the right types in the code as Stas had suggested, in close to a million lines of PHP code we have, I've been able to find less then 1000 (just did a grep) instances of casts. There is a good reason for that once you get out of the input p