Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59996 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91100 invoked from network); 16 Apr 2012 12:55:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Apr 2012 12:55:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=ralph@ralphschindler.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ralph@ralphschindler.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain ralphschindler.com from 209.85.214.170 cause and error) X-PHP-List-Original-Sender: ralph@ralphschindler.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:59505] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B9/24-05733-AB61C8F4 for ; Mon, 16 Apr 2012 08:55:23 -0400 Received: by obbta17 with SMTP id ta17so6697251obb.29 for ; Mon, 16 Apr 2012 05:55:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=SaptXpByY2HYVeVFoT54p2nS7hqAusNSFpf0eQT2USc=; b=Ti9DvdOuDl8J1aUDyNVx6M2B9Hwu4PrETSsZGVENd+U7mjBFLJ1vXPNxQNxXV89p80 WGLwBkPpAuQ9KloC0mgr+jmhG6khsbGgZGQ7yZnHA1baYwhkhgHucuv9eA4ThN7zl8Hm RNn6i8Z07Z3rK3pnM2CL5LYSmKm1LVO08+FTZJ1utboHDnAICORx8BEpL832hsC1+qzs /oG8zs4f/PSIwBmRLhlWHfhorxQ1w2o5kM/JynFoYKeGqeSFhGemEJErKMLTe93m2qt1 yFfrYLPKXympQhHAWhqsxwY6gXvWidozm5JOnDWzPOl9YgKCLbaAnOnQoWU0NTGZXMJm d+hA== Received: by 10.60.11.166 with SMTP id r6mr15626010oeb.2.1334580919730; Mon, 16 Apr 2012 05:55:19 -0700 (PDT) Received: from ralph-macbook.local (ip174-73-14-247.no.no.cox.net. [174.73.14.247]) by mx.google.com with ESMTPS id s8sm15347105oec.1.2012.04.16.05.55.18 (version=SSLv3 cipher=OTHER); Mon, 16 Apr 2012 05:55:18 -0700 (PDT) Message-ID: <4F8C16B5.7000103@ralphschindler.com> Date: Mon, 16 Apr 2012 07:55:17 -0500 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061207 Thunderbird/1.5.0.9 Mnenhy/0.7.4.666 MIME-Version: 1.0 To: Simon Schick CC: internals References: <4F89D4F1.8070009@ralphschindler.com> <4F8B766F.3000702@ralphschindler.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQn2LTHdYCA/J9tClkg/H2WN0q+871VmOz8ErrqDLN+FFvNcECm+iqVYpMrK0dqgz3z3Qqth Subject: Re: [PHP-DEV] New Feature: Fully qualified class name resolution as scalar with class keyword From: ralph@ralphschindler.com (Ralph Schindler) Hey Simon, > As the class-definition for Moo is missing, I think it's an empty > class (like Baz) on the root-level defined somewhere else, right? > Otherwise this should do something else than guessing the class-name. If you look at the patch, this feature is not doing anything PHP doesn't already do in other circumstances - demonstrated by the fact that its only about 4 lines of code ;) In PHP, in situations like (instanceof): if ($foo instanceof Bar) or (catch) } catch (SomeException $e) { or (method signature) public function setFoo(FooInterface $foo) ... PHP does not invoke the autoloader to determine if the class name actually exists as a declaration somewhere, it simply resolves it according to some very specific rules (in the case of this patch, carried out by zend_resolve_class_name()). If I am within a namespace and am using a short name without a preceding "\", it means the class I am referencing exists in the current namespace. Whether or not that class exists is irrelevant as my short name can only mean "a class by this name in the current namespace". In this code: namespace Foo\Bar { global $foo; if ($foo && $foo instance Bar) { // ... } } ... that you, the developer, intend that your reference to Baz actually means "Foo\Bar\Baz", it can never mean anything else. So, in a nutshell, there is no guessing going on ;) -ralph