php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #70666 Alias of int and bool not allowed in type hints
Submitted: 2015-10-08 04:54 UTC Modified: 2015-10-09 19:32 UTC
From: rl at nbsp dot io Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 7.0.0RC4 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rl at nbsp dot io
New email:
PHP Version: OS:

 

 [2015-10-08 04:54 UTC] rl at nbsp dot io
Description:
------------
With the new scalar type hints we cannot type hint with 'integer' or 'bool', it seems that this was deliberately removed, as the wiki says "aliases are removed (integer and boolean)". No reasons for the removal are given, so I hope it's not a big deal if I request that they are added again.

It mostly comes down to coding style, I've never used the abbreviated hand versions as why would I write 'bool' and yet 'string' or 'array'? The style doesn't match.

Also it doesn't help that the error message is nonsensical (see the script).

Test script:
---------------
<?php

// Uncaught TypeError: Argument 1 passed to {closure}() must be an instance of integer, integer given...
(function(integer $value) {
	var_dump($value);
})('1');



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-09 18:54 UTC] stas@php.net
-Package: PHP Language Specification +Package: Scripting Engine problem
 [2015-10-09 19:32 UTC] nikic@php.net
-Status: Open +Status: Wont fix
 [2015-10-09 19:32 UTC] nikic@php.net
As you already found, this is by design. We do not wish to provide multiple ways to write the same thing. It cannot be changed at this point anyway, because reserving the necessary class names would be a major BC break.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 10:01:29 2024 UTC