function size($x)
    return count($x);

size(array(1, 2)); # => 2

1. Define a function

use Patchwork as p;

p\replace("size", function($x)
    return "huge";

size(array(1, 2)); # => "huge"

2. Replace its definition


size(array(1, 2)); # => 2

# Note that all of these steps
# occur at the same runtime!

3. Undo the redefinition

We make the assumption of a responsible developer, of one that will continue writing maintainable code despite the hurdle of testability being lowered, meaning that a major motivator for maintainablity is eliminated.

As of now, it is strongly recommended to limit the use of Patchwork to testing and development environments only.

Further Reading

Patchwork's documentation can be navigated using the top menu. If you have a question about Patchwork that the documentation doesn't answer, please don't hesitate to leave a comment on the documentation pages.

Reporting Issues

If you encounter any Patchwork-related problems on which the documentation is of no help, please review the currently open issues on Patchwork's GitHub site, and if you find none that would explain your problem, please open a new one.