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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 04:01:33 2025 UTC