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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 06:01:34 2025 UTC