2017 © Pedro Peláez
 

library scoped-callback

Class for asserting that a callback happens when a dummy object leaves scope

image

wikimedia/scoped-callback

Class for asserting that a callback happens when a dummy object leaves scope

  • Saturday, July 28, 2018
  • by mediawiki
  • Repository
  • 10 Watchers
  • 0 Stars
  • 79,968 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 12 % Grown

The README.md

![Latest Stable Version] ![License], (*1)

ScopedCallback

The ScopedCallback class allows for running a function after the instance goes out of scope. It can be useful for making sure teardown or cleanup functions run even if exceptions are thrown. It also makes for a cleaner API for developers, by not requiring the callback to be called manually each time., (*2)

Additional documentation about the library can be found on MediaWiki.org., (*3)

Usage

use Wikimedia\ScopedCallback;
$sc = new ScopedCallback( [ $this, 'teardown' ] );
// Even if this throws an exception, the callback will run
// or it'll run at the end of the function
$this->fooBar();
// If you want to manually call the callback
ScopedCallback::consume( $sc );
// or
unset( $sc );
// If you want to prevent it from being called
ScopedCallback::cancel( $sc );

Running tests

composer install --prefer-dist
composer test

The Versions

28/07 2018

dev-master

9999999-dev https://www.mediawiki.org/wiki/ScopedCallback

Class for asserting that a callback happens when a dummy object leaves scope

  Sources   Download

GPL-2.0+ GPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

by Aaron Schulz

09/05 2018
29/09 2016

v1.0.0

1.0.0.0 https://www.mediawiki.org/wiki/ScopedCallback

Class for asserting that a callback happens when a dummy object leaves scope

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.5.9

 

The Development Requires

by Aaron Schulz