Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99720 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64026 invoked from network); 3 Jul 2017 17:18:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jul 2017 17:18:57 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.220 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.220 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.220] ([81.169.146.220:28946] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/07-15131-18C7A595 for ; Mon, 03 Jul 2017 13:18:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1499102334; l=2999; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:References:In-Reply-To: MIME-Version; bh=exum3T2mKGcWCGRil5YDLh4yGXW8x4izgs3NyFfqGZ8=; b=UOOI+PQ3iIibKc/9aIhGyNahqt3NRMzceFjNoA95e1lw6kXg1aGasWnCcvWttLoK4u oy+/sSPAOYi4RF0C00dDi40aBWggauxT+q1VJtFzRFcHaV3dOMMCKRgANdyxhHgbAggK BNO8gP0ZkWJjRz927M/RfmeWlmeKo/Bx8Ua00= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLDup6E67mzuoNHBqT43Q== X-RZG-CLASS-ID: mo00 Received: by mail-oi0-f50.google.com with SMTP id l130so86543476oib.1 for ; Mon, 03 Jul 2017 10:18:54 -0700 (PDT) X-Gm-Message-State: AKS2vOzimx/FUX969tb2TKmtO/7dlfU60+cOSC9MOB4u7a0ahwMgkLdG oH3DgHN1qF6pdI645PaNrp9dNgiz/Q== X-Received: by 10.202.102.198 with SMTP id m67mr16505019oik.149.1499102333433; Mon, 03 Jul 2017 10:18:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.81.135 with HTTP; Mon, 3 Jul 2017 10:18:52 -0700 (PDT) In-Reply-To: <3d05652e-59ab-7072-a094-f4201b052f04@fleshgrinder.com> References: <3d05652e-59ab-7072-a094-f4201b052f04@fleshgrinder.com> Date: Mon, 3 Jul 2017 19:18:52 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Fleshgrinder Cc: php-internals , gmblar@gmail.com Content-Type: multipart/alternative; boundary="001a1140a92c11038105536cf6f6" Subject: Re: [PHP-DEV] Re: [RFC] [Discussion] Class Naming From: me@kelunik.com (Niklas Keller) --001a1140a92c11038105536cf6f6 Content-Type: text/plain; charset="UTF-8" 2017-07-03 17:53 GMT+02:00 Fleshgrinder : > On 7/3/2017 5:30 PM, Andreas Treichel wrote: > > With any exception from PascalCase you cannot e.g. generate class names > > from strings without a explicit mapping table: > > > > > > > function findParserByRootNode(DomDocument $document) > > { > > $tagName = $document->documentElement->tagName; > > $className = ucfirst($tagName) . 'Parser'; > > if (!class_exists($className)) { > > throw new RuntimeException('Parser not found for '.$tagName); > > } > > return new $className(); > > } > > > > $document = new DomDocument(); > > $document->loadXml($xml); > > > > $parser = findParserByRootNode($document); > > $parser->parse($document); > > > > > > > > acronyms in PascalCase looks strange, but consistent strange. > > > > > > Not true in PHP because class names are not case sensitive: While true, most applications actually depend on the case for class names because of autoloaders. Regards, Niklas --001a1140a92c11038105536cf6f6--