php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #73204 Wrong runtime type error raised.
Submitted: 2016-09-29 22:25 UTC Modified: 2016-09-30 00:37 UTC
From: tomasyorke at hotmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.0.11 OS: Irrelevant
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: tomasyorke at hotmail dot com
New email:
PHP Version: OS:

 

 [2016-09-29 22:25 UTC] tomasyorke at hotmail dot com
Description:
------------
myFunction()
returns an array.

myFunction($i)->Data();

Returns the error:
 Fatal error: Uncaught Error: Call to a member function Data() on array



Test script:
---------------
function myFunction(){
return Array(new A,new A);
}
class A {
    public $foo = 1;
    function Data(){
        return 5;
    }
}  

five = myFunction(1)->Data()


Expected result:
----------------
It should Return that myFunction takes no parameters.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-30 00:37 UTC] yohgaki@php.net
-Status: Open +Status: Not a bug
 [2016-09-30 00:37 UTC] yohgaki@php.net
It seems this is what you want.
https://3v4l.org/baMcl
If you still see issue, please reopen.
 [2016-10-01 06:46 UTC] a at b dot c dot de
And passing a function more arguments than it has parameters is legal (see http://www.php.net/manual/functions.arguments.php#functions.variable-arg-list "variadic functions" for why).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 06:01:31 2024 UTC