Zeev,

>> With the current coercive proposal, you will still need to worry about the
>> types: https://wiki.php.net/rfc/coercive_sth#coercion_rules
>
> That's true, but a lot, lot less.

We apparently have a different definition of "less". Your proposal
requires you to worry about every type in every line of code that ever
existed. Yes, there are fewer dangerous type change errors, but you
need to look at every line of your application to find them.

In my dual-mode proposal, the only place you need to worry about this
is code that's explicitly opted-in to the rules via a per-file switch.
So by default, nobody gets any change. If you opt-in however, then you
get the full rules.

>> Passing boolean(false) where an integer is expected will generate an
>> error.
>> This is a common practice, specifically around internal functions.
>> Example:
>> https://github.com/sebastianbergmann/phpunit/blob/a4e23a10d4eeea5fd9f
>> e8916859a07430b94cf42/src/Util/ErrorHandler.php#L58
>
> It's actually not nearly as common as one might think, and arguably - it's
> may be hiding bug or at least some misunderstanding about the semantics of
> the argument (not always, but sometimes).  Warning about it (as deprecated)
> makes perfect sense.  I'm going to send some data from real world apps later
> today or early tomorrow.  Spoiler - not a lot of breakage at all, and
> coercive rules seem to have a remarkably good signal to noise ratio.

If Symfony or PHPUnit didn't error in these cases in more than one
place, I'd be inclined to agree with you (about not being as common as
one might think). But considering two of the best architected and
tested applications in the ecosystem both error in non-trivial
amounts, I think it's fair to say...

>> The difference is with the dual-mode RFC you can choose not to have to
>> cast
>> and keep everything as-is today (or more specifically, you need to
>> explicitly
>> choose strict mode). And you can have user-land behave identically to
>> internals **in both cases**.
>
> Put another way, coercive gets to keep a single, sensible conversion
> rule-set in PHP - with relatively minor updates needed over the course of
> several years.  And contrary to what might be implied here, it would require
> a LOT less casting - while still taking advantage of much better data
> sanitation.

I think you're REALLY downplaying the level of effort that's required
for the updates you're requiring users make. And that scares me.

Anthony

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

Reply via email to