Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105631 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 88126 invoked from network); 7 May 2019 21:42:19 -0000 Received: from unknown (HELO mail-pg1-f175.google.com) (209.85.215.175) by pb1.pair.com with SMTP; 7 May 2019 21:42:19 -0000 Received: by mail-pg1-f175.google.com with SMTP id w22so7436860pgi.6 for ; Tue, 07 May 2019 11:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=I+622VpB7D4Yyn9E13YlKbw2uhXBoq/AoCK8FczBywY=; b=eMPaP1hL8LZGenak/bFPdj5C60ylh2CmlTt3G9T7WY1EEXNqpT9Kr/I7yqwFqHTlp5 WdELYqIjD4YXVeq7Sz82vH7xeUi3PDsJus8EyfjJbAMM9/Mka39f95/Qja4i3SsoO+yn 6B0Q/72BfN5TzSiFrd0QnCKuGdLx1i9OgaWWBkZU6bisv6bdc0tdvIFpF/Ml6OaMiujE B7GWg0enanJn40ryCvnx07asfw/Gk4jr2eFYzqYSETKiri6nlfWXMNsLrPQcbsNONtin 5mcvr8pJ3cxhRF0/eEjB94D6J95rgGX0EEV9Cq8qetuDGWFzP4iJlNzWP+PPZtgkflRx ULiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=I+622VpB7D4Yyn9E13YlKbw2uhXBoq/AoCK8FczBywY=; b=E8HCnXBeknJhCJiBjeBaphR42Sikc/ChkWE6CJqw59q/sa9Fu6aNtomMxlnLWe28BF go+osA7OlUd/5Cyr9tfUX0ELXDSOT9h84MPUuK5FXKDfgU/QC0b46SEF/PPigLmzbqMJ bLeKV97Rt8waB8zz88jdQl6YP+61PXxEap8FgXXgmgTDlc2m8lVTjuU7aDucK9AOQJ1+ uQQxG870UJJTen98p+5jEisoXbLVSTs4yXdyup7y/81gWmFw4wlK4nRaNoUmPNOeBqwG mdmd3ZElyf6hfPKxbcCDxkPMQaSiIRyTDOcGwVw5Uyk6als4mvgVvfuUcerQN9XyxXgR sEng== X-Gm-Message-State: APjAAAX7xL75mRkq1aD+ER81L2OOrjtdEHw/KAgirw5vpmu8k2mNhDvV dwfcqM/SReP33rL2EWKaUipjhwoXUQ== X-Google-Smtp-Source: APXvYqyxEqQQLkArG5jih14V/tiNwESAnbjMUOUGxQFkGkuh6PZdx3s9FNaxU6tOyYowUqBic/WQpw== X-Received: by 2002:a63:1d02:: with SMTP id d2mr14933624pgd.26.1557254775068; Tue, 07 May 2019 11:46:15 -0700 (PDT) Received: from Stas-Pro-2016.local (c-24-4-176-254.hsd1.ca.comcast.net. [24.4.176.254]) by smtp.gmail.com with ESMTPSA id s85sm25457433pfa.23.2019.05.07.11.46.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 May 2019 11:46:13 -0700 (PDT) To: Gert , PHP internals References: Openpgp: preference=signencrypt Autocrypt: addr=smalyshev@gmail.com; prefer-encrypt=mutual; keydata= mQMuBE9mqaARCACFSqcGmNunkjQQu3X+yXnTmFeEkvM4JXZTOBdR8aEevNGmmFEfyvjaDjWi 9hcwp4E/lYtC+P7VsVjM1OSX9eq0jC/lGL0ZyRXek+mNy0n5H1NSuTpf9Y18LMqhc4G+RU+L cNiZ9K0DJuOOvNLPxW7OHZguxb3wdKPXNVa2jyRfJAKm2uaJJMT1mTmFT9a0Q8SKr+mUrrJk uG0H2o6SzrKt8Wwoint1eh67zVsJaJtQFchnEZnlawIcqP2yC4nLGR3MkubowxoEBYCZet18 aHVVRbvpG2Qtob8Lu5xrsGbmXymTkHTdpvkfcJFADa8MzOL90zOxXwbGfbIZOlh5En8jAQCX lfnx2eQL3BSW/6XANa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QJwsgOrAh0Om3OePRn8Pr+++0LNS0EL8uX/YHeTOGOnnmTqYTey SBVFdov6L4mepddfjekicKQqhL7mZh/xuq29JijT0uNNX8v4vDWQDu5dlAcdd+uB3gcXMD/P ginD11zp+6wtrWCm/+yBqpvDwXQX5PGUnwvbRfl7Ay3MmwmoXiecZMg0dwTSc7e0lhB4HGRH ZdBMJB4rHUVGdzqujK/ctOvrAAMFB/0Utb76Qe6sCMlHxVAmeE/fbo7Pi05btZ/x01r67dHf aMSP0riCKJ7M0OW+jAXtu9+z/BVnYisW67WWfxl2cS5tZDgiHgJARXWUOO72+sScHP8KQmTl 1z16gyKbwY3SmyBkwcpOL35nhUWNLy93syPoY6sZUTikr2bZYukHDQ33XBPs4e6MbWKfsa9q aVmnlOF3k5UqChjutfHaEa4Q7VP4wBIpphHBi9MI16oJIzzBPbGl2uoedjwiZ6QeQZnSuOVY ZxU2d3lRA8PrtfFN1VSlpEm/VcAvtieHUYWHN0wOu+cp3Slr5XJVNjTjJhl28SlinMME54mK AGf2Ldr/dRwXiGEEGBEIAAkFAk9mqaACGwwACgkQL3lWvF2gS126EQD/VVd3FgjLKglClRQP zdfU847tqDK4zJjbmRv5vLLwoE0A+wbrQs7jVGU3NrS0AIl5vUmewpp2BKzSkepy23nWmejw Message-ID: <21c4345d-4044-edb9-ade2-545dfd6028ad@gmail.com> Date: Tue, 7 May 2019 11:46:12 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Error instead of returning false From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > My idea, extremely summarized, would be to take the functions that > return false/null when they 'error', and instead make them actually > throw an error. First of all, they definitely should not throw Error, because Errors are for very specific types of things that mean the engine does not know what to do - e.g. if you asked for an integer and you gave parameter that can not be converted to integer, or you tried to use a function which does not exist, and so on. Normal functionality should almost always use Exception unless you have a really great reason not to. Second, I don't see any point in such a huge BC break for people that are fine with current return values. Exceptions is not something you can ignore (even if you can easily ignore method returning false - sometimes you don't want to, but sometimes you do), it's something that breaks your application. In some APIs for some corner cases it might be OK, but in general it's probably not something we'd ever want to do on a global scale. Third, I think throwing exceptions for routine situations that are expected to happen (like file not being there, or data not being valid) is wrong and this is what makes Java exceptions, for example, annoying. They confuse "everything broken and world is on fire, head for the exits" with "there's some dirt on the floor, bring the mop and clean it up". I.e. situations which are expected to be handled and situations where things are just gone wrong and it's best for this code do give up immediately. Exceptions should be used for situations which are, well, exceptional - ones that the code surrounding the call is unlikely to be able to fix - e.g. trying to open file while giving the argument that can not be used as a filename. Of course, the question what is "normal" for a given API is very specific to the API - e.g. for a search API not finding any result would be normal, but for an authorization API not finding certain record in the database may be exceptional - but I think there should be a distinction between the two. Which should be used in each specific case depends a lot on API design and specifics of the case, but there should be an option for both behaviors. -- Stas Malyshev smalyshev@gmail.com