2017 © Pedro Peláez
 

library phpmethodreplacer

image

phpmethodreplacer/phpmethodreplacer

  • Thursday, October 10, 2013
  • by tototoshi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

PHP Method Replacer

Note: This project is experimental, so the API is subject to change., (*1)

Requirement

  • runkit 1.03 (https://github.com/zenovich/runkit)

Install

composer.json, (*2)

    "require-dev": {
        "phpmethodreplacer/phpmethodreplacer": "VERSION"
    }

See about the latest version -> https://packagist.org/packages/phpmethodreplacer/phpmethodreplacer, (*3)

Example

<?php
require 'vendor/autoload.php';

class Hoge
{

    public static function moge()
    {
        echo 'moge' . PHP_EOL;
    }

}

class Hige
{
    public static function mige()
    {
        $mock = new \MethodReplacer\ClassMethodReplacementGuard();
        $mock->override('hoge', 'moge', function () {
            echo 'mige' . PHP_EOL;
        });

        Hoge::moge();
    }
}

Hoge::moge(); //=> moge
Hige::mige(); //=> mige
Hoge::moge(); //=> moge

Dev

Running Test

$ wget http://getcomposer.org/composer.phar
$ php composer.phar install
$ ./vendor/bin/phpunit

The Versions