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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 - 5 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Apr 19 01:01:28 2024 UTC