Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38481 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27749 invoked from network); 20 Jun 2008 16:41:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2008 16:41:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 38.99.98.18 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 38.99.98.18 beast.bluga.net Linux 2.6 Received: from [38.99.98.18] ([38.99.98.18:41645] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 23/43-12821-FBDDB584 for ; Fri, 20 Jun 2008 12:41:36 -0400 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id 0F493C13B22; Fri, 20 Jun 2008 09:41:40 -0700 (MST) Received: from [192.168.0.106] (CPE-76-84-4-101.neb.res.rr.com [76.84.4.101]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 5B2C2C13B21; Fri, 20 Jun 2008 09:41:39 -0700 (MST) Message-ID: <485BDDFB.6090400@chiaraquartet.net> Date: Fri, 20 Jun 2008 11:42:35 -0500 User-Agent: Thunderbird 2.0.0.14 (X11/20080505) MIME-Version: 1.0 To: Dmitry Stogov CC: Andi Gutmans , Stanislav Malyshev , internals Mailing List References: <485BD1C0.8040302@chiaraquartet.net> <485BD681.5080309@zend.com> In-Reply-To: <485BD681.5080309@zend.com> X-Enigmail-Version: 0.95.0 Content-Type: multipart/mixed; boundary="------------030804000006040106080408" X-Virus-Scanned: ClamAV using ClamSMTP Subject: Re: simple solution to another namespace conundrum? From: greg@chiaraquartet.net (Gregory Beaver) --------------030804000006040106080408 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Dmitry Stogov wrote: > Looks fine, but probably we should emit error only if class declared in > the same source file. > > Thanks. Dmitry. > Great, didn't realize how easy this would be. Attached patch does this, but requires another test: 067.php.inc: --TEST-- 067: Name ambiguity (import name & userspace class name in another file) --FILE-- type == ZEND_USER_CLASS && !strcmp(pce[0]->filename, CG(compiled_filename))) { + char *tmp = zend_str_tolower_dup(Z_STRVAL_P(ns), Z_STRLEN_P(ns)); + + if (Z_STRLEN_P(ns) != Z_STRLEN_P(name) || + memcmp(tmp, lcname, Z_STRLEN_P(ns))) { + zend_error(E_COMPILE_ERROR, "Cannot use %s as %s because the name is already in use", Z_STRVAL_P(ns), Z_STRVAL_P(name)); + } + efree(tmp); } - efree(tmp); } if (zend_hash_add(CG(current_import), lcname, Z_STRLEN_P(name)+1, &ns, sizeof(zval*), NULL) != SUCCESS) { --------------030804000006040106080408--