php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #14404 scope notation
Submitted: 2001-12-10 10:32 UTC Modified: 2010-12-29 11:56 UTC
From: foobardotcom at poczta dot onet dot pl Assigned: jani (profile)
Status: Closed Package: *General Issues
PHP Version: 4.1.0 OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: foobardotcom at poczta dot onet dot pl
New email:
PHP Version: OS:

 

 [2001-12-10 10:32 UTC] foobardotcom at poczta dot onet dot pl
What are callbacks? I have created my callback system, and it is working like that:

class Foo {
  function sum($a, $b) {
    return $a + $b;
  }
}
$staticCB = new Callback("Foo", "sum");
echo $staticCB->execute(array(5, 3)); // should result '8'
$myFoo = new Foo();
$instanceCB = new Callback($myFoo, "sum");
echo $instanceCB->execute(array(2, 4)); // should result '6'
function mySum($a, $b) { return $a + $b;}
$funcCB = new Callback(null, "mySum");
echo $funcCB->execute(array(1, 2)); // should result '3'

I want, you make possible to specify SCOPES, without dummy walkarounds like strings or variables, so make this possible:

$staticCB = new Callback(Foo::sum);
$instanceCB = new Callback($myFoo->sum);
$funcCB = new Callback(mySum);

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-29 11:56 UTC] jani@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: jani
 [2010-12-29 11:56 UTC] jani@php.net
Use Closures for such. Available since 5.3.0: 

  http://php.net/manual/en/functions.anonymous.php
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 23:01:27 2025 UTC