php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71856 bug in webPhar and Closure::bind
Submitted: 2016-03-19 05:42 UTC Modified: 2016-03-19 06:03 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: tuadmin at gmail dot com Assigned:
Status: Open Package: PHAR related
PHP Version: 5.6.19 OS: linux,win32
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-03-19 05:42 UTC] tuadmin at gmail dot com
Description:
------------
<?php
class  myclass{
	public $x;
	public function __construct($string){
		$this->x=$string;
	}
	public function show(){
		echo "this message is {$this->x}";
	}
}
$func = function (){
	$this->show();
};
$class = new myclass('hi this is example for bug');
$x = Closure::bind($func,$class);
$x();

Test script:
---------------
<?php
class  myclass{
	public $x;
	public function __construct($string){
		$this->x=$string;
	}
	public function show(){
		echo "this message is {$this->x}";
	}
}
$func = function (){
	$this->show();
};
$class = new myclass('hi this is example for bug');
$x = Closure::bind($func,$class);
$x();

Expected result:
----------------
this message is hi this is example for bug

Actual result:
--------------
Warning: Cannot bind an instance to a static closure in phar://var/www/test.phar/web.php on line 15

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-19 06:03 UTC] tuadmin at gmail dot com
for semi-patch or temporal solution in stub-web embed use...

<?php
function __temporal__solution__(){
    require 'web.php';
}
__temporal__solution__();
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Oct 19 14:01:28 2019 UTC