php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #56618 Functionality to add code to the beginning/end of an existing function/method
Submitted: 2005-10-28 12:23 UTC Modified: 2011-10-27 07:17 UTC
From: sebastian@php.net Assigned: sebastian (profile)
Status: Closed Package: runkit (PECL)
PHP Version: 5_1 CVS-2005-10-28 (dev) OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
19 - 17 = ?
Subscribe to this entry?

 
 [2005-10-28 12:23 UTC] sebastian@php.net
Description:
------------
This is a request for a Runkit function that adds PHP code either at the beginning or at the end of an already defined function or method.

This can currently be achieved by the following

  runkit_method_rename('Foo', 'bar', '__bar');
  runkit_method_add('Foo', 'bar', '', "echo 'Hello '; Foo::__bar(); echo '!';");

but a convenience function for this would be nice.

Reproduce code:
---------------
<?php
class Foo {
  public function bar() {
    print 'World';
  }
}

runkit_method_prepend_code('Foo', 'bar', "print 'Hello ';");
runkit_method_append_code('Foo', 'bar', "print '!';");

$foo = new Foo;
$foo->bar();
?>

Expected result:
----------------
Hello World.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-10-27 07:17 UTC] sebastian@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: sebastian
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 10 16:01:32 2024 UTC