Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62167 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92479 invoked from network); 15 Aug 2012 08:15:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Aug 2012 08:15:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 209.85.215.170 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 209.85.215.170 mail-ey0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:65428] helo=mail-ey0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BE/F2-06007-F8A5B205 for ; Wed, 15 Aug 2012 04:15:12 -0400 Received: by eaao11 with SMTP id o11so368898eaa.29 for ; Wed, 15 Aug 2012 01:15:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:from:to:cc:references:subject:date:mime-version :content-type:content-transfer-encoding:x-priority:x-msmail-priority :x-mailer:x-mimeole:x-gm-message-state; bh=RgiYhAhuaTedj7ifozPp5ILed3ffu3R4wBf1ZfdU4y0=; b=AP+kzX7v2QrZU7rhQgh+UlrtNL55i/FRMp6Aeyt6f6YKWHe9QioEMj2GO8eAdZqlEo Gf2KVfBcnE1KwE98FV6x2NqrgB54ffUVhhBXGRLbfrRuNYjOCwoekfCf8tJ3eeIOf0dA 7NMZKfsx/NMwQSJi5/hll3Q7XWzq29wLdO0wTmK6cJJkrkK5Ibe20sLQE8WtVnxKfYTz vAWVbaM6glsll75t/ft7OBzoABnUfaS0gfbmOG+0IvHbnHAA2OUKzUFbvI2xPDw2sIs+ HYJKWt/8lhD6ZDbNJyvIf6jCu0UfaE3luHr4kTARVI+fSaHEoIKPSGphbc3TrNahlCQ3 IWkg== Received: by 10.14.175.7 with SMTP id y7mr23125910eel.29.1345018508936; Wed, 15 Aug 2012 01:15:08 -0700 (PDT) Received: from pc (95-42-66-13.btc-net.bg. [95.42.66.13]) by mx.google.com with ESMTPS id z6sm2056512eeo.6.2012.08.15.01.15.07 (version=SSLv3 cipher=OTHER); Wed, 15 Aug 2012 01:15:08 -0700 (PDT) Message-ID: To: "Stas Malyshev" Cc: References: <502A86AA.2030203@sugarcrm.com> <502B57AE.4070801@sugarcrm.com> Date: Wed, 15 Aug 2012 11:15:04 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Gm-Message-State: ALoCoQlQFSWihbNJyx4vjTaFvF8u8gEEkeqt5nKE/KZRgoslH3ziVHGdc9TB/nOuGhLgPfQwcOvT Subject: Re: [PHP-DEV] Inline typecasting / typehinting for classes and interfaces From: sv_forums@fmethod.com ("Stan Vass") > What's wrong with instanceof? You can then throw fatal error if you > want, it's just two lines: > if(!($foo instanceof Bar)) { > trigger_error(E_USER_ERROR, "Wrong foo!"); > } That's 3 lines on top of the line where you assign the value, and you forgot the 4th line for the IDE: ----- /* @var $foo Bar */ $foo = expression(); if(!($foo instanceof Bar)) { trigger_error(E_USER_ERROR, "Wrong foo!"); } ----- Versus this: ---- Bar $foo = expression(); ---- And assignment is a kinda common operation. So I hope you can see what's wrong with it now. Stan