On 17/02/15 15:47, Anthony Ferrara wrote: > A static analyzer (one of the reasons people want strict) would error > there. The reason is that *at compile time* it can't reason about the > code well enough to determine if there's an error or not. You're > passing a string where you expect an int. Is that going to work? We > don't know. So the analyzer would need to throw a warning that the > cast is potentially unsafe because it can't guarantee that the runtime > won't throw an error. Which means that to remove the warning you'd > need to add an explicit cast.
This is what I do not get ... I have no idea what string will be provided, so either we get a valid number or we don't. Conversion of the string to a number needs to follow several rules such as thousand divider or decimal point, or perhaps even spelt out numbers. If the input string can't be converted to a number then we need the error message - explicit casting fixed nothing - you can't eliminate the error if the passed string can't be converted so you need an alternate escape route. A generic 'type fault' does not help since you want to return the fault to the inputting source? Static analysis only works if you assume there is no human involvement in the generation of the inputs? Now if you are handling the problem of mistakes in the input prior to the function call you already know that the data is good so why do you need 'strict' at all. You will process the string, decide if you want to tell the client that it must be a whole number, or if it exceeds some limit. That may even be done in javascript in the browser, so what is fed back has already been sanitised. It will come in as a string and you know it is a valid number ... -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php