Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80157 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36376 invoked from network); 4 Jan 2015 19:02:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jan 2015 19:02:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=sbj.ml.read@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=sbj.ml.read@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.172 as permitted sender) X-PHP-List-Original-Sender: sbj.ml.read@gmail.com X-Host-Fingerprint: 209.85.223.172 mail-ie0-f172.google.com Received: from [209.85.223.172] ([209.85.223.172:44292] helo=mail-ie0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/F3-02442-94E89A45 for ; Sun, 04 Jan 2015 14:02:33 -0500 Received: by mail-ie0-f172.google.com with SMTP id tr6so18612352ieb.31 for ; Sun, 04 Jan 2015 11:02:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=wyM+HvLzTbYazas+1JqBRoTHqyS9dKN77ZDvfmuMMis=; b=QU0smolMclD8ZmB6h942zKDdN+/4nUgUM4MwGK2BL4Of3aZSg5SfYnAA/h5jsxjg/M IwAMcB9nlNhYwjwC2Ha+KZKwsU63iADbo0fs/nYbBHkZYRStmkFOoUJBzW40HviXF1n+ wxLI0FwiCweqxC1dnyHWOtdT4K7352n8+ayMf+FglDjEOZnzvXtAGsxlZQrLn2DgBwRz mz1pNgn1I6SjTVeIiPUFCFqj5c12HfWJ4ejrFQy0ntNclkuz6RMtnG7M2vYOuttnbndP liO5IaUuYH1uUAHjPjI6F5dbEcFxrQ7Sl/JgH9QRLHn4+5GCnouiWbtIgxC0cZwoDqA0 jh3A== MIME-Version: 1.0 X-Received: by 10.43.75.69 with SMTP id yz5mr64977347icb.90.1420398149967; Sun, 04 Jan 2015 11:02:29 -0800 (PST) Received: by 10.107.44.82 with HTTP; Sun, 4 Jan 2015 11:02:29 -0800 (PST) In-Reply-To: References: <41D5BB0B-73AF-488E-968D-90B2878E3178@ajf.me> <54A466CB.9020400@gmail.com> Date: Sun, 4 Jan 2015 20:02:29 +0100 Message-ID: To: Derick Rethans Cc: Stanislav Malyshev , Andrea Faulds , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints From: sbj.ml.read@gmail.com ("Sebastian B.-Hagensen") 2015-01-04 18:31 GMT+01:00 Derick Rethans : > On Wed, 31 Dec 2014, Stanislav Malyshev wrote: > >> >> The issue is the class names though. E.g. see: >> https://github.com/ralphschindler/zf2-db/blob/master/research/ColumnType/Integer.php > > That's in a namespace, so it's not actually Integer, but > Zend\Db\Metadata\Type\Integer It might add some value to forbid importing of unaliased type named classes via use, so that no ambiguous type annotation exists. Example: use My\Lib\string as UserString; // fine, no error use My\Lib\int; // Compile error: Forbidden to import scalar type. Use `as` to create an alias function test (int $a, UserString $b); // what is int? Most libraries should be able to resolve such issues in a minor release to stay compatible with PHP 7. If a user doesn't use PHP 7 he won't be affected as the old import still works and the name of the class (if namespaced) hasn't changed, if he switches to PHP7 the updates can probably be automated. Namespaced classes can still be named whatever they want as the following(typehint an alias of the own class, using FQN) is already valid and the signature of the method would not change(no major release of a library required).: namspace abc; use abc\int as MyInt; class int { function a(MyInt $a, \abc\int $b) ;} > "PHP owns the top-level namespace but tries to find decent descriptive > names and avoid any obvious clashes." I don't think to many people wrap types in a class in the global namespace. Those people who care about the possible benefits are likely to use namespaces, pseudo/pear namespaces or more specialized classes anyway.