Le mar. 10 mars 2015 à 21:04, Marcio Almada <marcio.w...@gmail.com> a
écrit :

>
>
> 2015-03-10 12:31 GMT-03:00 Patrick ALLAERT <patrickalla...@php.net>:
>
>> Hello,
>>
>> Le lun. 2 mars 2015 à 00:03, Marcio Almada <marcio.w...@gmail.com> a
>> écrit :
>>
>>
>>  I'm globally +0.5, however I have some concerns:
>>
>> What about constructors?
>>
>> Children classes may have a bigger number of arguments for their ctors
>> than their parents. Even if not very elegant, it is possible some are
>> passing a fixed number of arguments while constructing an object, whether
>> that object will take it into account or not.
>>
>> Something like:
>>
>> class A {
>>     function __construct($a)
>> }
>>
>> class B extends A {
>>     function __construct($a, $b)
>> }
>>
>> $kind = $bool ? "A" : "B";
>>
>> $object = new $kind($foo, $bar);
>>
>
> I think this is somehow covered here
> https://wiki.php.net/rfc/strict_argcount#hassle_factor, the example is
> not explicit to ctors but the same principles seem to apply. Not sure you
> have a deeper point on it though as PHP is a weirdo and allows constructors
> on interfaces.
>
> Also, FYI, before we reach discussion phase, there was an idea to ignore
> ctors and other magic methods but you are the first person to bring it up
> on the ML. I'm not very inclined to ignore any other magic methods other
> than *__call* and *__callStatic* for now.
>

No deep point, just wanted to bring your attention on it.

>
>
>> E_WARNING:
>> -1, IMHO, calling functions/methods with more arguments generally has
>> less impact than other aspects that currently generate E_NOTICES (e.g.
>> using undefined variables, constants,...). Using an error reporting level
>> stronger than for those cases looks inconsistent.
>>
>
> I disagree with the "looks inconsistent" part. The E_WARNING option would
> actually be the most consistent with current PHP behavior. Ex:
>
> function fn($a, $b){}
> fn(1);
> PHP warning:  Missing argument 2 for fn(), called in...
>
> If we choose E_WARNING both minimum and maximum argument count will have
> the same error level. BTW, in some cases an exceeding argument can be even
> more dangerous than a missing argument.
>

You have a (debatable) point :)

It depends according to what aspect of PHP your are comparing it with.
Greping zend_error(E_NOTICE,.*) in the code I had the feeling that already
many notices where the sign of a bigger problem than when passing extra
parameters, hence why I suggested E_NOTICE.

My consistency argument was therefore "severity based".


> I have no strong feelings regarding to the error level, the E_WARNING vs
> E_NOTICE seems legit so I'm waiting for more opinions.
>

I wouldn't -1 for E_WARNING because of your extra arguments (sorry for the
pun ;), someone had to do it!). Still in favor of E_NOTICE though.

Patrick

Reply via email to