Bug #54684 [Opn->Csd]: SoapServer->handle() breaks type hinting

From: Date: Wed, 13 Jan 2021 11:23:23 +0000
Subject: Bug #54684 [Opn->Csd]: SoapServer->handle() breaks type hinting
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231531@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54684&edit=1

 ID:                 54684
 Updated by:         cmb@php.net
 Reported by:        luke at cywh dot com
 Summary:            SoapServer->handle() breaks type hinting
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            SOAP related
 Operating System:   Mac OS X 10.6
 PHP Version:        5.3.6
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

This has apparently been fixed in the meantime; at least I cannot
reproduce the reported behavior with PHP-7.3 nor PHP-7.4.


Previous Comments:
------------------------------------------------------------------------
[2011-09-15 15:29:14] henning dot panke at erento dot com

Can reproduce this issue on a gentoo system with php 5.2.17.

------------------------------------------------------------------------
[2011-05-07 02:55:44] 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"


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



--
Edit this bug report at https://bugs.php.net/bug.php?id=54684&edit=1


Thread (3 messages)

« previous php.bugs (#231531) next »