php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69124 Method name must be a string ... triggered by a string
Submitted: 2015-02-26 09:14 UTC Modified: -
From: narf at devilix dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: master-Git-2015-02-26 (Git) OS: Linux
Private report: No CVE-ID: None
 [2015-02-26 09:14 UTC] narf at devilix dot net
Description:
------------
$this->{$method}() calls fail with a "Method name must be a string" error, even if $method is a string (and an existing method too).

I've encountered this after assigning $method via sscanf(), so it might be a sscanf() issue, but it doesn't look like it ...

Test script:
---------------
<?php
class Foo {

	public function test()
	{
		sscanf('bar', '%s', $method);
		var_dump($method);
		$this->{$method}();
	}

	public function bar() {}

}

$bar = new Foo();
$bar->test();

Expected result:
----------------
string(3) "bar"

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

Fatal error: Method name must be a string in %s on line 8

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-26 13:22 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4b861bde47a4e1294512ba025cf6f1795bb9a1a5
Log: Fixed bug #69124 (method name could not be used when by ref)
 [2015-02-26 13:22 UTC] bwoebi@php.net
-Status: Open +Status: Closed
 [2016-07-20 11:39 UTC] davey@php.net
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4b861bde47a4e1294512ba025cf6f1795bb9a1a5
Log: Fixed bug #69124 (method name could not be used when by ref)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 20:01:29 2024 UTC