Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86384 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38504 invoked from network); 25 May 2015 18:02:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 May 2015 18:02:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.49 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 209.85.215.49 mail-la0-f49.google.com Received: from [209.85.215.49] ([209.85.215.49:35563] helo=mail-la0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 94/60-36604-2D363655 for ; Mon, 25 May 2015 14:02:59 -0400 Received: by labbd9 with SMTP id bd9so53321600lab.2 for ; Mon, 25 May 2015 11:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:to:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=HbIdArRZ5inIeIiq4Os9Muhf81GfL3HXQm/UmsmQyAg=; b=T+/uLYXgKGbTHYCfZCQkL9Im5LIdRt/3qNtafLWsUdC9sEX1EUI20vxIGRsYaW4e04 +JXktbEEAAIjqXsNN+k2VzBo8JWhvg0aP7UNnBD/BcMlsIWVwP6Nm3avmSS+WY9XFaC2 DTAxnCV03dtYcmub1J8E9969ZQNQi5wQctX3cOZtq+v6OUjhGrL4OWYIWMCv+qXLVEC8 DfAwy7LVeOLUdra/XlF/8Fd5eK5fNXpSmkYeyiDa1rXyb1hR84qDQRrzYw7i96qlMzjB u/VI1+ZVHdd9PwVUk77HJzu0tPMQ8OSachzL1OhfdsRPkU3h9X1K6bRPHCHwDGxw+Hpm 1ktg== X-Received: by 10.152.4.98 with SMTP id j2mr664853laj.42.1432576975065; Mon, 25 May 2015 11:02:55 -0700 (PDT) Received: from nikita-pc ([89.250.5.98]) by mx.google.com with ESMTPSA id m8sm2479150lbs.17.2015.05.25.11.02.53 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 25 May 2015 11:02:53 -0700 (PDT) Content-Type: text/plain; charset=koi8-r; format=flowed; delsp=yes To: internals@lists.php.net References: <55636034.6010003@mabe.berlin> Date: Mon, 25 May 2015 21:02:52 +0300 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: <55636034.6010003@mabe.berlin> User-Agent: Opera Mail/1.0 (Win32) Subject: Re: [PHP-DEV] ::class wrong case From: inefedor@gmail.com ("Nikita Nefedov") On Mon, 25 May 2015 20:47:32 +0300, Marc Bennewitz wrote: > Hi, > > I have noted that detecting a class name using "::class" it will return > the called case instead of the original case. > see http://3v4l.org/97K36 > > That's annoying as I like to check the right class case on autoload to > detect mistakes. > > Sure, class names in PHP are case-insensitive but filesystems aren't and > most autoloader using the FS to find the right file. To catch such kind > of mistakes I would like to implement a fast check in my autoloader to > get noted on development instead on production. It's currently only > possible with ReflectionClass but this will be much slower as with > ::class. > > Are there any reasons to get the called case of the class instead or the > original one? > > Marc > This happens because ::class construction is evaluated at compiled time, without triggering autoloader. That means compiler doesn't know what will be the actual name of a class, it just gives you what you asked for. > It's currently only possible with ReflectionClass but this will be much > slower as with ::class. It's only possible with ReflectionClass if this class was already loaded. There's one way for your autoloader to know if the class name has characters in a wrong case - build a class map and do a check based on this map.