Completed
Push — master ( 5c5d8b...07962b )
by
unknown
04:03 queued 51s
created

Deferred::__destruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * Deferred
5
 *
6
 * Run callback when script execution is stopped.
7
 *
8
 * @package core
9
 * @author [email protected]
10
 * @copyright Caffeina srl - 2016 - http://caffeina.com
11
 */
12
13
class Deferred {
14
15
	protected 	$callback,
16
				$args;
17
18
	public function __construct( callable $callback ) {
19
		$this->args = array_slice( func_get_args(), 1 );
20
		$this->callback = $callback;
21
	}
22
23
	public function setArgs() {
24
		$this->args = func_get_args();
25
	}
26
27
	public function __destruct() {
28
		call_user_func( $this->callback, $this->$args );
0 ignored issues
show
Bug introduced by
The variable $args does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
29
	}
30
}