php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #55476 Method doesn't exist with magic method for soap
Submitted: 2011-08-22 12:16 UTC Modified: 2021-07-22 09:19 UTC
From: donaldinou at gmail dot com Assigned:
Status: Verified Package: Reflection related
PHP Version: 5.3.7 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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
46 - 4 = ?
Subscribe to this entry?

 
 [2011-08-22 12:16 UTC] donaldinou at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/reflectionmethod.invokeargs%23Description
---

There is differences between call_user_func_array and Reflection::invokeArgs 
method. Some magic methods are correctly called by call_user_func_array, but not 
in Reflection Object

Test script:
---------------
if I do this:
// Example: $clientSoap->runTransaction($arguments)

// call_user_func_array
$result = call_user_func_array( array($clientSoap, 'runTransaction'), $arguments );
if (!is_soap_fault($result)) {
    echo 'The method __doRequest from SoapClient object is called (This is what we want).';
}

// with reflection
$reflectionMethod = new ReflectionMethod('SoapClient', 'runTransaction');
try {
    $result = $reflectionMethod->invokeArgs( $clientSoap, $arguments );
    if (!is_soap_fault($result)) {
    echo 'The method __doRequest from SoapClient object is called (This is what we want).';
    }
} catch (ReflectionException  $r) {
    echo 'The method __doRequest is never called because the methode invokeArgs throw a ReflectionException.';
}

Expected result:
----------------
This should be display:
The method __doRequest from SoapClient object is called (This is what we want).
The method __doRequest from SoapClient object is called (This is what we want).

Actual result:
--------------
The method __doRequest from SoapClient object is called (This is what we want).
The method __doRequest is never called because the methode invokeArgs throw a 
ReflectionException.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-22 13:51 UTC] kalle@php.net
-Status: Open +Status: Feedback
 [2011-08-22 13:51 UTC] kalle@php.net
And the error from $r is? Please be more verbose
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 [2015-02-24 09:23 UTC] donaldinou at gmail dot com
-Status: No Feedback +Status: Closed -Package: *General Issues +Package: Reflection related
 [2015-02-24 09:23 UTC] donaldinou at gmail dot com
I cannot "re-open" this one
 [2015-02-24 09:24 UTC] donaldinou at gmail dot com
-Status: Closed +Status: Open
 [2015-02-24 09:24 UTC] donaldinou at gmail dot com
This is old, but I gave the code. How to be more verbose?
Anyway, you can copy/paste code below, it is an example more explicit

<?php

$clientSoap = new SoapClient('http://www.webservicex.net/geoipservice.asmx?WSDL');
$arguments = array('IPAddress' => '8.8.8.8');

// classic call
$result = $clientSoap->GetGeoIP($arguments);
//var_dump($result); // $result is ok

// call_user_func_array
$result = call_user_func_array( array($clientSoap, 'GetGeoIP'), array($arguments) );
if (!is_soap_fault($result)) {
    echo 'OK not a problem.'.PHP_EOL;
}

// with reflection
$reflectionMethod = new ReflectionMethod($clientSoap, 'GetGeoIP');
try {
    $result = $reflectionMethod->invokeArgs( $clientSoap, array($arguments) );
    if (!is_soap_fault($result)) {
        echo 'Ok not a problem.'.PHP_EOL;
    }
} catch (ReflectionException  $r) {
    print_r($r); // Method SoapClient::GetGeoIP() does not exist
}

-------------------------------------------

The error raise is:
"Uncaught exception 'ReflectionException' with message 'Method SoapClient::GetGeoIP() does not exist' in [...]"

This is because $clientSoap is an instanceof SoapClient and the Reflection object does not try to use __getFunctions methods.
Why? Because the call is like this:
ReflectionMethod->__construct(Object(SoapClient), 'GetGeoIP')
 [2021-07-22 09:19 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Feature/Change Request +Type: Documentation Problem
 [2021-07-22 09:19 UTC] cmb@php.net
Right, Reflection does not know about any methods implemented via
__call[1] or similar mechanisms.  This should be documented.

[1] <https://3v4l.org/jqXe6>
 [2021-07-22 09:19 UTC] cmb@php.net
Right, Reflection does not know about any methods implemented via
__call[1] or similar mechanisms.  This should be documented.

[1] <https://3v4l.org/jqXe6>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 06:01:29 2024 UTC