|
@@ -46,16 +46,16 @@ discard block |
|
|
block discarded – undo |
|
46
|
46
|
{ |
|
47
|
47
|
$argc = count($args); |
|
48
|
48
|
if ($argc < $required) { |
|
49
|
|
- throw new \InvalidArgumentException(get_called_class() . "::$method() expects at least $required parameters, $argc given"); |
|
|
49
|
+ throw new \InvalidArgumentException(get_called_class()."::$method() expects at least $required parameters, $argc given"); |
|
50
|
50
|
} |
|
51
|
51
|
if ($required === 2 and !is_string($args[0]) and !is_object($args[0]) || !method_exists($args[0], '__toString')) { |
|
52
|
|
- throw new \InvalidArgumentException(get_called_class() . "::$method() expects parameter 1 to be string, " . gettype($args[0]) . ' given'); |
|
|
52
|
+ throw new \InvalidArgumentException(get_called_class()."::$method() expects parameter 1 to be string, ".gettype($args[0]).' given'); |
|
53
|
53
|
} |
|
54
|
54
|
if (!is_callable($args[$required - 1])) { |
|
55
|
|
- throw new \InvalidArgumentException(get_called_class() . "::$method() expects parameter $required to be callable, " . gettype($args[$required - 1]) . ' given'); |
|
|
55
|
+ throw new \InvalidArgumentException(get_called_class()."::$method() expects parameter $required to be callable, ".gettype($args[$required - 1]).' given'); |
|
56
|
56
|
} |
|
57
|
57
|
if (isset($args[$required]) && !is_numeric($args[$required])) { |
|
58
|
|
- throw new \InvalidArgumentException(get_called_class() . "::$method() expects parameter " . ($required + 1) . ' to be integer, ' . gettype($args[$required]) . ' given'); |
|
|
58
|
+ throw new \InvalidArgumentException(get_called_class()."::$method() expects parameter ".($required + 1).' to be integer, '.gettype($args[$required]).' given'); |
|
59
|
59
|
} |
|
60
|
60
|
} |
|
61
|
61
|
|
|
@@ -67,27 +67,27 @@ discard block |
|
|
block discarded – undo |
|
67
|
67
|
public static function __callStatic($method, array $args) |
|
68
|
68
|
{ |
|
69
|
69
|
if (strtolower(substr($method, 0, 2)) !== 'to') { |
|
70
|
|
- throw new \BadMethodCallException('Call to undefined method ' . get_called_class() . "::$method()"); |
|
|
70
|
+ throw new \BadMethodCallException('Call to undefined method '.get_called_class()."::$method()"); |
|
71
|
71
|
} |
|
72
|
72
|
|
|
73
|
|
- $class = (string)substr($method, 2); |
|
|
73
|
+ $class = (string) substr($method, 2); |
|
74
|
74
|
$required = $class === '' ? 2 : 1; |
|
75
|
75
|
self::validateArgumentTypes($method, $args, $required); |
|
76
|
76
|
|
|
77
|
77
|
if ($class === '') { |
|
78
|
|
- $class = (string)array_shift($args); |
|
|
78
|
+ $class = (string) array_shift($args); |
|
79
|
79
|
} |
|
80
|
80
|
|
|
81
|
81
|
if (!class_exists($class) and !is_subclass_of($class, '\Exception') and \PHP_VERSION < 7 || !is_subclass_of($class, '\Throwable')) { |
|
82
|
82
|
throw new \DomainException("The class \"$class\" must be an instance of Exception or Throwable"); |
|
83
|
83
|
} |
|
84
|
84
|
|
|
85
|
|
- return Core::handle($args[0], function ($severity, $message, $file, $line) use ($class, $args) { |
|
|
85
|
+ return Core::handle($args[0], function($severity, $message, $file, $line) use ($class, $args) { |
|
86
|
86
|
if (!(error_reporting() & $severity)) { |
|
87
|
87
|
return; |
|
88
|
88
|
} |
|
89
|
89
|
throw Core::rewriteLocation(new $class($message), $file, $line); |
|
90
|
|
- }, isset($args[1]) ? (int)$args[1] : E_ALL | E_STRICT); |
|
|
90
|
+ }, isset($args[1]) ? (int) $args[1] : E_ALL | E_STRICT); |
|
91
|
91
|
} |
|
92
|
92
|
|
|
93
|
93
|
/** |
|
@@ -98,18 +98,18 @@ discard block |
|
|
block discarded – undo |
|
98
|
98
|
public static function toErrorException($callback, $types = E_ALL | E_STRICT) |
|
99
|
99
|
{ |
|
100
|
100
|
if (!is_callable($callback)) { |
|
101
|
|
- throw new \InvalidArgumentException(get_called_class() . '::' . __METHOD__ . '() expects parameter 1 to be callable, ' . gettype($callback) . ' given'); |
|
|
101
|
+ throw new \InvalidArgumentException(get_called_class().'::'.__METHOD__.'() expects parameter 1 to be callable, '.gettype($callback).' given'); |
|
102
|
102
|
} |
|
103
|
103
|
if ($types !== null && !is_numeric($types)) { |
|
104
|
|
- throw new \InvalidArgumentException(get_called_class() . '::' . __METHOD__ . '() expects parameter 2 to be integer, ' . gettype($types) . ' given'); |
|
|
104
|
+ throw new \InvalidArgumentException(get_called_class().'::'.__METHOD__.'() expects parameter 2 to be integer, '.gettype($types).' given'); |
|
105
|
105
|
} |
|
106
|
106
|
|
|
107
|
|
- return Core::handle($callback, function ($severity, $message, $file, $line) { |
|
|
107
|
+ return Core::handle($callback, function($severity, $message, $file, $line) { |
|
108
|
108
|
if (!(error_reporting() & $severity)) { |
|
109
|
109
|
return; |
|
110
|
110
|
} |
|
111
|
111
|
throw new \ErrorException($message, 0, $severity, $file, $line); |
|
112
|
|
- }, (int)$types); |
|
|
112
|
+ }, (int) $types); |
|
113
|
113
|
} |
|
114
|
114
|
|
|
115
|
115
|
/** |
|
@@ -120,20 +120,20 @@ discard block |
|
|
block discarded – undo |
|
120
|
120
|
public static function silent($callback, $types = E_ALL | E_STRICT) |
|
121
|
121
|
{ |
|
122
|
122
|
if (!is_callable($callback)) { |
|
123
|
|
- throw new \InvalidArgumentException(get_called_class() . '::' . __METHOD__ . '() expects parameter 1 to be callable, ' . gettype($callback) . ' given'); |
|
|
123
|
+ throw new \InvalidArgumentException(get_called_class().'::'.__METHOD__.'() expects parameter 1 to be callable, '.gettype($callback).' given'); |
|
124
|
124
|
} |
|
125
|
125
|
if ($types !== null && !is_numeric($types)) { |
|
126
|
|
- throw new \InvalidArgumentException(get_called_class() . '::' . __METHOD__ . '() expects parameter 2 to be integer, ' . gettype($types) . ' given'); |
|
|
126
|
+ throw new \InvalidArgumentException(get_called_class().'::'.__METHOD__.'() expects parameter 2 to be integer, '.gettype($types).' given'); |
|
127
|
127
|
} |
|
128
|
128
|
|
|
129
|
129
|
$e = new \Exception; |
|
130
|
130
|
try { |
|
131
|
|
- return Core::handle($callback, function ($severity) use ($e) { |
|
|
131
|
+ return Core::handle($callback, function($severity) use ($e) { |
|
132
|
132
|
if (!(error_reporting() & $severity)) { |
|
133
|
133
|
return; |
|
134
|
134
|
} |
|
135
|
135
|
throw $e; |
|
136
|
|
- }, (int)$types); |
|
|
136
|
+ }, (int) $types); |
|
137
|
137
|
} catch (\Exception $e) { |
|
138
|
138
|
} catch (\Throwable $e) { |
|
139
|
139
|
} |