Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84005 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66821 invoked from network); 27 Feb 2015 14:15:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2015 14:15:47 -0000 Authentication-Results: pb1.pair.com header.from=kontakt@beberlei.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=kontakt@beberlei.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain beberlei.de from 74.125.82.169 cause and error) X-PHP-List-Original-Sender: kontakt@beberlei.de X-Host-Fingerprint: 74.125.82.169 mail-we0-f169.google.com Received: from [74.125.82.169] ([74.125.82.169:36833] helo=mail-we0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/41-32582-01C70F45 for ; Fri, 27 Feb 2015 09:15:45 -0500 Received: by wevk48 with SMTP id k48so20671593wev.3 for ; Fri, 27 Feb 2015 06:15:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=DAu+JveoeQPicojKr+D39Q/2STlz9X0Wb7PM63B76mk=; b=MwPTh/DJyQgGL0YQuRHbTij6su5hkSKA2okQO0YL10h4kHEnKxK4Bfj2W6jXMf6b5J SF8fz0jyHvdHExMkot9i2DJoPwceuaDPT3CU2yYXxklu12SoGBNy9g7KJAQw2xuSIvGF CwjgqLphNuveqNF1BfFVuWyhR05PInCYnxPNLcVKpztNc9Iuk/sehUryN7zanmrp9Kl4 Xwpv/zrKVMCK5l1QXN2d48VBpdr5pPTzF75HXvY2OGXkFT3WCzUDz5SL02TMP6geGE+w gNGMr+Yh1f2pmNDGilKLysKrFA7CtGxg6N/BJDnKEiKDJrqzF1pCXpZhn8C/i40NxQa2 KtfQ== X-Gm-Message-State: ALoCoQlOFvkmIi6jK9LeWpu+6PTgjjDTNiFDuYekpbRcm/dTbVB0TNB4MHj3wrq1DFQN3sO+HLC6 MIME-Version: 1.0 X-Received: by 10.180.208.103 with SMTP id md7mr545331wic.52.1425046541654; Fri, 27 Feb 2015 06:15:41 -0800 (PST) Received: by 10.194.192.202 with HTTP; Fri, 27 Feb 2015 06:15:41 -0800 (PST) X-Originating-IP: [87.139.115.236] In-Reply-To: <54F077B2.3020103@lsces.co.uk> References: <54F077B2.3020103@lsces.co.uk> Date: Fri, 27 Feb 2015 15:15:41 +0100 Message-ID: To: Lester Caine Cc: PHP Internals Content-Type: multipart/alternative; boundary=001a11c381c8e7766005101280cd Subject: Re: [PHP-DEV] Coercive STH - some real world tests and updated RFC From: kontakt@beberlei.de (Benjamin Eberlei) --001a11c381c8e7766005101280cd Content-Type: text/plain; charset=UTF-8 On Fri, Feb 27, 2015 at 2:57 PM, Lester Caine wrote: > On 27/02/15 13:45, Benjamin Eberlei wrote: > >>> Drupal admin interface (across the all pages): One new E_DEPRECATED > >>> > > warning, which again seems to catch a real bug - stripslsahes() > operating > >>> > > on a boolean. > >>> > > > >> > > >> > All those are due to a bug in substr(), that we see now only thanks to > >> > proper type identification. There is no reason for substr() to ever > return > >> > a boolean. It really needs to be fix to always return a string. > >> > > > Yes, weird behavior that substr("", 2, 2); for example returns false. But > > changing thatis just another evil BC break. > > Now I don' think that 'weird' ... Although the correct return should > perhaps be 'null', but it's long been practice that s there is no result > we get 'false' so how any places will have a sanity check based on the > 'false' return? > As an example i ported PDepend to work with coercive typehints, this is the quick and dirty patch: https://gist.github.com/beberlei/6a5a6b65839d35bb27f0 In longer chains of string handling, i just cast everything to (string) that could potentially return false here. Interestingly functions like is_infinite(), is_dir(), is_file() all expect correct types like float or string here although from the naming convention "is_something" i would expect it says just false on *anything* else (which it almost does right now). The patch also shows that this will lead to weird behavior when the PHP API is actually wrong like DOMNode::cloneNode() expecting an integer and not a boolean as argument, even though the PHP Documentation says it should be a boolean. I can literally forsee this is the way this kind of code will be fixed. Imho the problem is that the return values of php internal functions being string|false will lead to massive consecutive errors when passing this on to other internal unctions. > > -- > 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 > > --001a11c381c8e7766005101280cd--