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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 01 13:01:29 2024 UTC