1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Part of the InputSanitizer package. |
5
|
|
|
* |
6
|
|
|
* @package InputSanitizer |
7
|
|
|
* @version 1.0.2 |
8
|
|
|
* @author Arthur Lorent <[email protected]>, Daniel Lucas <[email protected]> |
9
|
|
|
* @license MIT |
10
|
|
|
* @copyright (c) 2006-2017, ACID-Solutions SARL |
11
|
|
|
* @link https://acid.fr |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace AcidSolutions\InputSanitizer\Native\Facades; |
15
|
|
|
|
16
|
|
|
use AcidSolutions\InputSanitizer\Native\InputSanitizerBootstrapper; |
17
|
|
|
|
18
|
|
|
class InputSanitizer |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* The InputSanitizer instance. |
22
|
|
|
* |
23
|
|
|
* @var \AcidSolutions\InputSanitizer\InputSanitizer |
24
|
|
|
*/ |
25
|
|
|
protected $inputSanitizer; |
26
|
|
|
/** |
27
|
|
|
* The Native BootStrapper instance. |
28
|
|
|
* |
29
|
|
|
* @var InputSanitizerBootstrapper |
30
|
|
|
*/ |
31
|
|
|
protected static $instance; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Constructor. |
35
|
|
|
* |
36
|
|
|
* @param InputSanitizerBootstrapper $bootstrapper |
37
|
|
|
*/ |
38
|
8 |
|
public function __construct(InputSanitizerBootstrapper $bootstrapper = null) |
39
|
|
|
{ |
40
|
8 |
|
if ($bootstrapper === null) { |
41
|
6 |
|
$bootstrapper = new InputSanitizerBootstrapper; |
42
|
6 |
|
} |
43
|
|
|
|
44
|
8 |
|
$this->inputSanitizer = $bootstrapper->createInputSanitizer(); |
45
|
8 |
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Returns the InputSanitizer instance. |
49
|
|
|
* |
50
|
|
|
* @return \AcidSolutions\InputSanitizer\InputSanitizer |
51
|
|
|
*/ |
52
|
6 |
|
public function getInputSanitizer() |
53
|
|
|
{ |
54
|
6 |
|
return $this->inputSanitizer; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Creates a new Native Bootstrapper instance. |
59
|
|
|
* |
60
|
|
|
* @param InputSanitizerBootstrapper $bootstrapper |
61
|
|
|
* |
62
|
|
|
* @return void |
63
|
|
|
*/ |
64
|
4 |
|
public static function instance(InputSanitizerBootstrapper $bootstrapper = null) |
65
|
|
|
{ |
66
|
4 |
|
if (static::$instance === null) { |
67
|
2 |
|
static::$instance = new static($bootstrapper); |
|
|
|
|
68
|
2 |
|
} |
69
|
|
|
|
70
|
4 |
|
return static::$instance; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Handle dynamic, static calls to the object. |
75
|
|
|
* |
76
|
|
|
* @param string $method |
77
|
|
|
* @param array $args |
78
|
|
|
* |
79
|
|
|
* @return mixed |
80
|
|
|
*/ |
81
|
2 |
|
public static function __callStatic($method, $args) |
82
|
|
|
{ |
83
|
2 |
|
$instance = static::instance()->getInputSanitizer(); |
|
|
|
|
84
|
2 |
|
switch (count($args)) { |
85
|
2 |
|
case 1: |
86
|
2 |
|
return $instance->{$method}($args[0]); |
87
|
|
|
|
88
|
2 |
|
case 2: |
89
|
2 |
|
return $instance->{$method}($args[0], $args[1]); |
90
|
|
|
|
91
|
2 |
|
case 3: |
92
|
2 |
|
return $instance->{$method}($args[0], $args[1], $args[2]); |
93
|
|
|
|
94
|
2 |
|
default: |
95
|
2 |
|
return call_user_func_array([$instance, $method], $args); |
96
|
2 |
|
} |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..