php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #75935 Allow usage of multiple type hints
Submitted: 2018-02-08 10:21 UTC Modified: 2018-02-08 10:24 UTC
From: francois5537 at gmail dot com Assigned: peehaa (profile)
Status: Closed Package: *Programming Data Structures
PHP Version: 7.2.2 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: francois5537 at gmail dot com
New email:
PHP Version: OS:

 

 [2018-02-08 10:21 UTC] francois5537 at gmail dot com
Description:
------------
I don't know if this already has been reported or already supported, sorry if this is the case.

Test script:
---------------
<?php
function canBeArrayOrString(string|array $route) {
  // Don't allow object, int, etc.!
}

Expected result:
----------------
Something like 'Must be string, array - object given!'

Actual result:
--------------
Valid when array or string has been given.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-08 10:24 UTC] peehaa@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: peehaa
 [2018-02-08 10:24 UTC] peehaa@php.net
This has already been proposed:

https://wiki.php.net/rfc/union_types

It may be revisited again later.
 [2018-02-08 10:26 UTC] peehaa@php.net
Also see the related discussion here: https://externals.io/message/92274
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 05:01:28 2024 UTC