Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 31 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
OnErrorEventHandlerNonNull | |
0.00% |
0 / 31 |
|
0.00% |
0 / 4 |
90 | |
0.00% |
0 / 1 |
_getMissingProp | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 | |||
_setMissingProp | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
__invoke | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
cast | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | // AUTOMATICALLY GENERATED. DO NOT EDIT. |
4 | // Use `composer build` to regenerate. |
5 | |
6 | namespace Wikimedia\IDLeDOM\Helper; |
7 | |
8 | use Wikimedia\IDLeDOM\Event; |
9 | |
10 | trait OnErrorEventHandlerNonNull { |
11 | |
12 | // Underscore is used to avoid conflicts with DOM-reserved names |
13 | // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
14 | // phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName |
15 | |
16 | /** |
17 | * Handle an attempt to get a non-existing property on this |
18 | * object. The default implementation raises an exception |
19 | * but the implementor can choose a different behavior: |
20 | * return null (like JavaScript), dynamically create the |
21 | * property, etc. |
22 | * @param string $prop the name of the property requested |
23 | * @return mixed |
24 | */ |
25 | protected function _getMissingProp( string $prop ) { |
26 | $trace = debug_backtrace(); |
27 | while ( |
28 | count( $trace ) > 0 && |
29 | $trace[0]['function'] !== "__get" |
30 | ) { |
31 | array_shift( $trace ); |
32 | } |
33 | trigger_error( |
34 | 'Undefined property' . |
35 | ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $prop . |
36 | ' in ' . ( $trace[0]['file'] ?? '' ) . |
37 | ' on line ' . ( $trace[0]['line'] ?? '' ), |
38 | E_USER_NOTICE |
39 | ); |
40 | return null; |
41 | } |
42 | |
43 | /** |
44 | * Handle an attempt to set a non-existing property on this |
45 | * object. The default implementation raises an exception |
46 | * but the implementor can choose a different behavior: |
47 | * ignore the operation (like JavaScript), dynamically create |
48 | * the property, etc. |
49 | * @param string $prop the name of the property requested |
50 | * @param mixed $value the value to set |
51 | */ |
52 | protected function _setMissingProp( string $prop, $value ): void { |
53 | $trace = debug_backtrace(); |
54 | while ( |
55 | count( $trace ) > 0 && |
56 | $trace[0]['function'] !== "__set" |
57 | ) { |
58 | array_shift( $trace ); |
59 | } |
60 | trigger_error( |
61 | 'Undefined property' . |
62 | ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $prop . |
63 | ' in ' . ( $trace[0]['file'] ?? '' ) . |
64 | ' on line ' . ( $trace[0]['line'] ?? '' ), |
65 | E_USER_NOTICE |
66 | ); |
67 | } |
68 | |
69 | // phpcs:enable |
70 | |
71 | /** |
72 | * Make this callback interface callable. |
73 | * @param mixed ...$args |
74 | * @return mixed|null |
75 | */ |
76 | public function __invoke( ...$args ) { |
77 | '@phan-var \Wikimedia\IDLeDOM\OnErrorEventHandlerNonNull $this'; |
78 | // @var \Wikimedia\IDLeDOM\OnErrorEventHandlerNonNull $this |
79 | return $this->invoke( $args[0], $args[1] ?? null, $args[2] ?? null, $args[3] ?? null, $args[4] ?? null ); |
80 | } |
81 | |
82 | /** |
83 | * Create a OnErrorEventHandlerNonNull from a callable. |
84 | * |
85 | * @param callable|\Wikimedia\IDLeDOM\OnErrorEventHandlerNonNull $f |
86 | * @return \Wikimedia\IDLeDOM\OnErrorEventHandlerNonNull |
87 | */ |
88 | public static function cast( $f ) { |
89 | if ( $f instanceof \Wikimedia\IDLeDOM\OnErrorEventHandlerNonNull ) { |
90 | return $f; |
91 | } |
92 | return new class( $f ) implements \Wikimedia\IDLeDOM\OnErrorEventHandlerNonNull { |
93 | use OnErrorEventHandlerNonNull; |
94 | |
95 | /** @var callable */ |
96 | private $f; |
97 | |
98 | /** |
99 | * @param callable $f |
100 | */ |
101 | public function __construct( $f ) { |
102 | $this->f = $f; |
103 | } |
104 | |
105 | /** |
106 | * @param Event|string $event |
107 | * @param ?string $source |
108 | * @param ?int $lineno |
109 | * @param ?int $colno |
110 | * @param mixed|null $error |
111 | * @return mixed|null |
112 | */ |
113 | public function invoke( /* mixed */ $event, ?string $source = null, ?int $lineno = null, ?int $colno = null, /* any */ $error = null ) { |
114 | $f = $this->f; |
115 | return $f( $event, $source, $lineno, $colno, $error ); |
116 | } |
117 | }; |
118 | } |
119 | } |