ScopedCallback
Make a callback run when a dummy object leaves the scope.
Loading...
Searching...
No Matches
Wikimedia\ScopedCallback Class Reference

Make a callback run when a dummy object leaves the scope. More...

Public Member Functions

 __construct ( $callback, array $params=[])
 
 __destruct ()
 Trigger the callback when it leaves scope.
 
 __sleep ()
 Do not allow this class to be serialized.
 
 __wakeup ()
 Protect the caller against arbitrary code execution.
 

Static Public Member Functions

static consume (ScopedCallback &$sc=null)
 Trigger a scoped callback and destroy it.
 
static cancel (ScopedCallback &$sc=null)
 Destroy a scoped callback without triggering it.
 
static newScopedIgnoreUserAbort ()
 Make PHP ignore user aborts/disconnects until the returned value leaves scope.
 

Protected Attributes

 $callback
 
 $params
 

Detailed Description

Make a callback run when a dummy object leaves the scope.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\ScopedCallback::__construct (   $callback,
array  $params = [] 
)
Parameters
callable | null$callback
array$paramsCallback arguments (since 1.0.0, MediaWiki 1.25)

Member Function Documentation

◆ __sleep()

Wikimedia\ScopedCallback::__sleep ( )

Do not allow this class to be serialized.

Returns
never

◆ __wakeup()

Wikimedia\ScopedCallback::__wakeup ( )

Protect the caller against arbitrary code execution.

Returns
never

◆ cancel()

static Wikimedia\ScopedCallback::cancel ( ScopedCallback $sc = null)
static

Destroy a scoped callback without triggering it.

Parameters
ScopedCallback | null&$sc

◆ consume()

static Wikimedia\ScopedCallback::consume ( ScopedCallback $sc = null)
static

Trigger a scoped callback and destroy it.

This is the same as just setting it to null.

Parameters
ScopedCallback | null&$sc

◆ newScopedIgnoreUserAbort()

static Wikimedia\ScopedCallback::newScopedIgnoreUserAbort ( )
static

Make PHP ignore user aborts/disconnects until the returned value leaves scope.

This returns null and does nothing in CLI mode.

Since
3.0.0
Returns
ScopedCallback|null

Also no benefit testing a function just returns null.


The documentation for this class was generated from the following file: