php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54684 SoapServer->handle() breaks type hinting
Submitted: 2011-05-07 02:55 UTC Modified: 2021-01-13 11:23 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: luke at cywh dot com Assigned: cmb (profile)
Status: Closed Package: SOAP related
PHP Version: 5.3.6 OS: Mac OS X 10.6
Private report: No CVE-ID: None
 [2011-05-07 02:55 UTC] luke at cywh dot com
Description:
------------
SoapServer's handle() function breaks PHPs type-hinting for function parameters.

Note that if you remove "$server->handle()" you get the expected result. If you leave it there you get the actual result.

If this is intended it might have to do with SoapServer passing back stdClass as function arguments. But please note that this test code is not even used by SoapServer. I merely call the handle() function and every function call is effected, not just those invoked by SoapServer. Also for functions invoked by SoapServer, shouldn't a string fail because it's a non-object?

If this isn't going to be fixed because it's a "feature" then we have a documentation problem. There needs to be a warning on the handle() documentation that states type-hinting is broken globally.

If this was intended, I honestly don't think this should happen on a global scope. Only functions called by SoapServer should be effected, and even then the type should be at least restricted to an object.

Test script:
---------------
$server = new \SoapServer(NULL, array('uri' => 'http://localhost'));
$server->handle();

class test
{
	public function sayHello(Blah $one, $two)
	{
		return $one;
	}
}

$test = new test;
var_dump($test->sayHello('one', 'two'));

Expected result:
----------------
Catchable fatal error: Argument 1 passed to test::sayHello() must be an instance of Blah, string given

Actual result:
--------------
string(3) "one"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-15 15:29 UTC] henning dot panke at erento dot com
Can reproduce this issue on a gentoo system with php 5.2.17.
 [2021-01-13 11:23 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-01-13 11:23 UTC] cmb@php.net
This has apparently been fixed in the meantime; at least I cannot
reproduce the reported behavior with PHP-7.3 nor PHP-7.4.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 17:01:29 2024 UTC