php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71167 Missing documentation, that type declaration doesn't support aliases
Submitted: 2015-12-19 11:33 UTC Modified: 2015-12-19 20:02 UTC
From: daniel dot korner at tu-dortmund dot de Assigned: tpunt (profile)
Status: Closed Package: Documentation problem
PHP Version: 7.0.1 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: daniel dot korner at tu-dortmund dot de
New email:
PHP Version: OS:

 

 [2015-12-19 11:33 UTC] daniel dot korner at tu-dortmund dot de
Description:
------------
Just recently I found out that type declaration does not support aliases[1]. This is a piece of information that is currently missing in the documentation[2]. Therefore, I propose to add this information to the documentation. Maybe together with my test script and a detailed explanation of what the error means.

[1]
http://marc.info/?l=php-general&m=145030898711430&w=2
[2]
http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration

Test script:
---------------
<?php 
	function bar(boolean $foo): boolean{return $foo;}
	var_dump(bar((bool)true));
?>

Expected result:
----------------
bool(true)

Actual result:
--------------
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to bar() must be an instance of boolean, boolean given, called in ./example4.php:2
Stack trace:
#0 ./example4.php(3): bar(true)
#1 {main}
  thrown in ./example4.php on line 2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-19 18:21 UTC] tpunt@php.net
-Assigned To: +Assigned To: tpunt
 [2015-12-19 20:00 UTC] tpunt@php.net
Automatic comment from SVN on behalf of tpunt
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=338328
Log: Resolve doc bug #71167
 [2015-12-19 20:01 UTC] tpunt@php.net
Resolved with commit: https://svn.php.net/viewvc?view=revision&revision=338328

I decided to make it a warning since I can see this being a common issue.
 [2015-12-19 20:02 UTC] tpunt@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 02:01:31 2024 UTC