Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57979 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93495 invoked from network); 23 Feb 2012 18:56:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Feb 2012 18:56:42 -0000 Authentication-Results: pb1.pair.com header.from=keisial@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=keisial@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.170 as permitted sender) X-PHP-List-Original-Sender: keisial@gmail.com X-Host-Fingerprint: 209.85.212.170 mail-wi0-f170.google.com Received: from [209.85.212.170] ([209.85.212.170:34260] helo=mail-wi0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CF/41-18992-9EB864F4 for ; Thu, 23 Feb 2012 13:56:41 -0500 Received: by wibhm4 with SMTP id hm4so1134263wib.29 for ; Thu, 23 Feb 2012 10:56:38 -0800 (PST) Received-SPF: pass (google.com: domain of keisial@gmail.com designates 10.180.86.134 as permitted sender) client-ip=10.180.86.134; Authentication-Results: mr.google.com; spf=pass (google.com: domain of keisial@gmail.com designates 10.180.86.134 as permitted sender) smtp.mail=keisial@gmail.com; dkim=pass header.i=keisial@gmail.com Received: from mr.google.com ([10.180.86.134]) by 10.180.86.134 with SMTP id p6mr5500134wiz.0.1330023398727 (num_hops = 1); Thu, 23 Feb 2012 10:56:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=TRTbfYb5uY7DLjbpPI5Icw8WwtBjG7VzRnWefXCzWBU=; b=ZLANfuXkVT5Nw1InyKAtF/O+JtmVECGK+bXL0v6yT1DkvpDOg5QIc2++ZY7Q00MTdB J2cGECiMYhWveBmDfV+lLRhCDR+eiHAuh8AsETjL7xCzC6nmKUyfCiWBOQsVc42L1XoZ pwy2T9Lq5+Vg0ufswn2PO8uXuX689YBzdKfvk= Received: by 10.180.86.134 with SMTP id p6mr4480540wiz.0.1330023398683; Thu, 23 Feb 2012 10:56:38 -0800 (PST) Received: from [192.168.1.26] ([80.28.66.11]) by mx.google.com with ESMTPS id cs4sm10440786wib.8.2012.02.23.10.56.36 (version=SSLv3 cipher=OTHER); Thu, 23 Feb 2012 10:56:37 -0800 (PST) Message-ID: <4F468D09.7070004@gmail.com> Date: Thu, 23 Feb 2012 20:01:29 +0100 User-Agent: Thunderbird MIME-Version: 1.0 To: Stas Malyshev CC: Sebastian Krebs , PHP internals list References: <4F455C96.50706@gmail.com> <4F455E91.2060408@googlemail.com> <4F4570D6.8040003@gmail.com> <4F457597.3060405@sugarcrm.com> In-Reply-To: <4F457597.3060405@sugarcrm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Enum proposal (yet another) From: keisial@gmail.com (=?ISO-8859-1?Q?=C1ngel_Gonz=E1lez?=) On 23/02/12 00:09, Stas Malyshev wrote: > Hi! > >>> Sidenote, according your examples above on how you want call >>> functions: Considered using normal constants? >> How can I do type hinting with them? > > You should not. PHP is not a strictly typed language, so if you want > strictly typed function you'll get in trouble, for the same reasons > why strict scalar typing wasn't a good idea - you may want to re-read > these discussions. I disagree. It is arguable whether having > enum Databases { MySQL, Postgres, Oracle } > enum Colors { Red, Green, Blue } > > database_select(Colors::Red, $sql); should give an error for a Databases type hint on the first parameter, as it can be converted (that's a soft vs strict typing issue). However, such typehint should avoid a call like: > database_select(1024, $sql); with which the function can't do anything sensible with (other than returning an error if it does its own checking). Best regards