Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67908 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51514 invoked from network); 26 Jun 2013 20:59:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jun 2013 20:59:50 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.44 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.44 mail-la0-f44.google.com Received: from [209.85.215.44] ([209.85.215.44:56597] helo=mail-la0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 82/00-51393-4465BC15 for ; Wed, 26 Jun 2013 16:59:49 -0400 Received: by mail-la0-f44.google.com with SMTP id er20so14525964lab.31 for ; Wed, 26 Jun 2013 13:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=vw5XpYYnmZIIc5Ec4PTAHa61yxoFTZUUOarV3giM/qk=; b=v4mWdqKFZUUaslZuzL54ddFP9isvVGTu0wXURTYrqkhI1VsHvZ60YgkHIFSLN8kFQg YuGpuWr8zeWwsavwp/DjYckylS8O2112PqUp7uqOuUXS5+/2KQQlKG8hrN5e1tOHQqNy 9EWnwR9la3E1ZOB1oeQFIfivMTYw+fV+HPQTWifITzR3/nAh+/+F8TR5RzGGZ0N8HUmB +q/447LoPOcrnBcmuOOGXHWpNn4m4k6enwaUIY4g8UhTGx79PS/ekGhWFAUqkiSElYkx +tFHIelnLsiEeuO0LC6VqJTBcaGkCTpXKn4SDMWuT1s70uJ2N0qtMzcgTqYvFqsRjAOi WLQg== X-Received: by 10.152.19.131 with SMTP id f3mr2813800lae.9.1372280385912; Wed, 26 Jun 2013 13:59:45 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.4.233 with HTTP; Wed, 26 Jun 2013 13:59:05 -0700 (PDT) In-Reply-To: References: Date: Thu, 27 Jun 2013 05:59:05 +0900 X-Google-Sender-Auth: jUwuk7HqAb1M-YEEKHeNlgNGgZI Message-ID: To: Nikita Popov Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e013d1d54ef472104e014ec59 Subject: Re: [PHP-DEV] hex2bin: E_WARNING is too much for odd string? From: yohgaki@ohgaki.net (Yasuo Ohgaki) --089e013d1d54ef472104e014ec59 Content-Type: text/plain; charset=ISO-8859-1 Hi Nikita, 2013/6/27 Nikita Popov > Why is it easier? If you pass an odd length string to hex2bin you have > malformed input, which is usually a bug on the programmers side. Not having > a warning would make the issue harder to debug. It's good to have uniformed error handling. Therefore, E_WARNING for 'bad chars' is alternative. hex2bin('abcZ'); // E_WARNING for invalid char hex2bin('abc'); // E_WARNING for invalid length (Users can handle errors via custom error handler) or hex2bin('abcZ'); // return FALSE since there is invalid char hex2bin('abc'); // return FALSE since it has invalid length (Users should catch errors via their validation/error handling code) I think either raising error or returning false is OK, but it's not good have(mix) both for a function. It's not mandatory, though. It would be nice if there is error/exception handling guideline for module authors for uniform error/exception handling. IMHO. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --089e013d1d54ef472104e014ec59--