Re: [RFC] [Discussion] Class Naming

From: Date: Mon, 03 Jul 2017 15:30:07 +0000
Subject: Re: [RFC] [Discussion] Class Naming
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-99707@lists.php.net to get a copy of this message
With any exception from PascalCase you cannot e.g. generate class names from strings without a explicit mapping table: <?php 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.

« previous php.internals (#99707) next »