Re: [RFC-Discuss] Scalar Type Declarations v0.5
| From: | Anthony Ferrara | Date: | Fri, 20 Feb 2015 14:58:18 +0000 |
| Subject: | Re: [RFC-Discuss] Scalar Type Declarations v0.5 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-83308@lists.php.net to get a copy of this message | ||
Chris,
I'll edit in the proposal, but you can check the tests in the mean time:
https://github.com/ircmaxell/php-src/blob/c8590799622ddb801360664d08ac5d7f4fa342df/Zend/tests/typehints/scalar_strict_declaration_placement_002.phpt
https://github.com/ircmaxell/php-src/blob/c8590799622ddb801360664d08ac5d7f4fa342df/Zend/tests/typehints/scalar_strict_declaration_placement_004.phpt
https://github.com/ircmaxell/php-src/blob/c8590799622ddb801360664d08ac5d7f4fa342df/Zend/tests/typehints/scalar_strict_declaration_placement_005.phpt
So it needs to come before the namespace declaration (in fact, it
currently needs to be the first declaration in the file).
Though I am about to implement the block syntax, and that may alter
things slightly (though declare will be required to be outside the
namespace).
Anthony
On Fri, Feb 20, 2015 at 6:07 AM, Chris Harvey <chris@chrisnharvey.com> wrote:
> Hi Anthony,
>
> I have been interested in this proposal for a while now. I'm not on internals, but I have
> a question about your proposal.
>
>> 1. declare(strict_types=1) (if used) is required to be the first
>> instruction in the file only. No other usages allowed.
>
> How would this work with namespaces?
>
> declare(strict_types=1) namespace Foo;
>
> namespace Bar; declare(strict_types=1)
>
> strict namespace Baz;
>
> Really good proposal though. Really hope it passes vote and we finally get scalar type hints in
> PHP.
>
> Cheers,
>
> Chris