Passed
Pull Request — 0.9.x (#308)
by Shinji
02:11
created

zend_mm_page_map::offsetGet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace FFI\PhpInternals;
3
4
use FFI\CArray;
5
use FFI\CData;
6
use FFI\CInteger;
7
use FFI\CPointer;
8
use Reli\Lib\Process\Pointer\Pointer;
9
10
/**
11
 * This file is part of the reliforp/reli-prof package.
12
 *
13
 * (c) sji <[email protected]>
14
 *
15
 * For the full copyright and license information, please view the LICENSE
16
 * file that was distributed with this source code.
17
 */
18
19
class zend_executor_globals extends CData
20
{
21
    public ?CPointer $current_execute_data;
22
    public ?CPointer $function_table;
23
    public ?CPointer $class_table;
24
    public ?CPointer $zend_constants;
25
    public zend_array $symbol_table;
26
    public ?CPointer $vm_stack;
27
    public zend_array $included_files;
28
    public ?CPointer $ini_directives;
29
    public ?CPointer $modified_ini_directives;
30
    public zend_objects_store $objects_store;
31
}
32
33
class zend_compiler_globals extends CData
34
{
35
    public ?CPointer $arena;
36
    public ?CPointer $ast_arena;
37
    public zend_array $interned_strings;
38
    public int $map_ptr_base;
39
}
40
41
class zend_arena extends CData
42
{
43
    public ?CPointer $ptr;
44
    public ?CPointer $end;
45
    public ?CPointer $prev;
46
}
47
48
class zend_closure extends CData
49
{
50
    public zend_object $std;
51
    public zend_function $func;
52
    public zval $this_ptr;
53
    public ?CPointer $called_scope;
54
}
55
56
class zend_constants extends CData
57
{
58
    public ?CPointer $name;
59
    public zval $value;
60
    public int $type;
61
    public int $flags;
62
    public ?CPointer $module;
63
    public ?CPointer $doc_comment;
64
}
65
66
class zend_execute_data extends CData
67
{
68
    public ?CPointer $opline;
69
    public ?CPointer $func;
70
    public ?CPointer $prev_execute_data;
71
    public zval $This;
72
    public ?CPointer $symbol_table;
73
    public ?CPointer $extra_named_params;
74
}
75
76
class zend_op extends CData
77
{
78
    public CInteger $op1;
79
    public CInteger $op2;
80
    public CInteger $result;
81
    public int $op1_type;
82
    public int $op2_type;
83
    public int $opcode;
84
    public int $result_type;
85
    public int $extended_value;
86
    public int $lineno;
87
}
88
89
class zend_fiber extends CData
90
{
91
}
92
93
class zend_fiber_context extends CData
94
{
95
}
96
97
class zend_function extends CData
98
{
99
    public int $type;
100
    public zend_function_common $common;
101
    public zend_op_array $op_array;
102
}
103
104
class zend_live_range extends CData
105
{
106
    public int $var;
107
    public int $start;
108
    public int $end;
109
}
110
111
class zend_mm_chunk extends CData
112
{
113
    public ?CPointer $heap;
114
    public ?CPointer $prev;
115
    public ?CPointer $next;
116
    public int $num;
117
    public zend_mm_heap $heap_slot;
118
    public int $free_pages;
119
    public zend_mm_page_map $map;
120
}
121
class zend_mm_heap extends CData
122
{
123
    public int $use_custom_heap;
124
    public int $size;
125
    public int $peak;
126
    public int $real_size;
127
    public int $real_peak;
128
    public int $limit;
129
    public int $overflow;
130
    public ?CPointer $huge_list;
131
    public ?CPointer $main_chunk;
132
    public int $chunks_count;
133
    public int $peak_chunks_count;
134
    public int $cached_chunks_count;
135
}
136
class zend_mm_huge_list extends CData
137
{
138
    public int $ptr;
139
    public int $size;
140
    public ?CPointer $next;
141
}
142
143
/** @implements \ArrayAccess<int, int> */
144
class zend_mm_page_map extends CData implements \ArrayAccess
145
{
146
    public function offsetExists($offset): bool
147
    {
148
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return boolean. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
149
    public function offsetGet($offset): int
150
    {
151
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return integer. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
152
}
153
154
class zend_object extends CData
155
{
156
    public zend_refcounted_h $gc;
157
    public int $handle;
158
    public ?CPointer $properties;
159
    public ?CPointer $ce;
160
    public ?CPointer $handlers;
161
    public array $properties_table;
162
}
163
class zend_objects_store extends CData
164
{
165
    public int $top;
166
    public int $size;
167
    public int $free_list_head;
168
    public ?CPointer $object_buckets;
169
}
170
171
class zend_op_array extends CData
172
{
173
    public int $fn_flags;
174
    public ?CPointer $filename;
175
    public int $num_args;
176
    public ?CPointer $arg_info;
177
    public ?CPointer $refcount;
178
    public int $this_var;
179
    public ?CPointer $scope;
180
    public ?CPointer $opcodes;
181
    public ?CPointer $prototype;
182
    public ?CPointer $doc_comment;
183
    public int $last_live_range;
184
    public ?CPointer $live_range;
185
    public int $num_dynamic_func_defs;
186
    public ?CPointer $dynamic_func_defs;
187
    public int $last;
188
    public int $last_var;
189
    public int $T;
190
    public ?CPointer $vars;
191
    public ?CPointer $literals;
192
    public ?CPointer $static_variables;
193
    public int $line_start;
194
    public int $line_end;
195
    public int $last_literal;
196
    public int $cache_size;
197
    public ?CPointer $run_time_cache;
198
    public ?CPointer $run_time_cache__ptr;
199
}
200
201
class zend_function_common extends CData
202
{
203
    public ?CPointer $function_name;
204
    public ?CPointer $scope;
205
    public int $fn_flags;
206
    public int $num_args;
207
}
208
209
class zend_string extends CData
210
{
211
    public zend_refcounted_h $gc;
212
213
    /** @var int */
214
    public int $h;
215
216
    /** @var int */
217
    public int $len;
218
219
    /** @var CPointer*/
220
    public CData $val;
221
}
222
223
class zend_property_info extends CData
224
{
225
    public int $offset;
226
    public int $flags;
227
    public ?CPointer $name;
228
    public ?CPointer $doc_comment;
229
}
230
231
class zend_refcounted_h extends CData
232
{
233
    public int $refcount;
234
235
    public zend_refcounted_h_u $u;
236
}
237
238
class zend_refcounted_h_u extends CData
239
{
240
    public int $type_info;
241
}
242
243
class zend_class_entry extends CData
244
{
245
    public string $type;
246
    public int $num_interfaces;
247
    public int $num_traits;
248
    public int $default_properties_count;
249
    public int $default_static_members_count;
250
    public ?CPointer $default_static_members_table;
251
    public ?CPointer $static_members_table;
252
    public ?CPointer $static_members_table__ptr;
253
    public ?CPointer $default_properties_table;
254
    public zend_array $function_table;
255
    public zend_array $constants_table;
256
    public zend_array $properties_info;
257
    public int $ce_flags;
258
    public CPointer $name;
259
    public zend_class_entry_info $info;
260
}
261
262
class zend_class_entry_info extends CData
263
{
264
    public zend_class_entry_info_user $user;
265
}
266
267
class zend_class_entry_info_user extends CData
268
{
269
    public ?CPointer $filename;
270
    public int $line_start;
271
    public int $line_end;
272
    public ?CPointer $doc_comment;
273
}
274
275
class zend_class_constant extends CData
276
{
277
    public zval $value;
278
    public ?CPointer $doc_comment;
279
    public ?CPointer $attributes;
280
    public ?CPointer $ce;
281
    public zend_type $type;
282
}
283
class zend_reference extends CData
284
{
285
    public zend_refcounted_h $gc;
286
    public zval $val;
287
}
288
289
class zend_resource extends CData
290
{
291
    public zend_refcounted_h $gc;
292
    public int $handle;
293
    public int $type;
294
}
295
class zend_type extends CData
296
{
297
    public int $ptr;
298
    public int $type_mask;
299
}
300
301
class zend_value_ww extends CData
302
{
303
    public int $w1;
304
    public int $w2;
305
}
306
307
class zend_value extends CData
308
{
309
    public int $lval;
310
    public float $dval;
311
    public ?CPointer $counted;
312
    public ?CPointer $arr;
313
    public ?CPointer $str;
314
    public ?CPointer $obj;
315
    public ?CPointer $res;
316
    public ?CPointer $ref;
317
    public ?CPointer $ast;
318
    public ?CPointer $zv;
319
    public ?CPointer $ptr;
320
    public ?CPointer $ce;
321
    public ?CPointer $func;
322
    public zend_value_ww $ww;
323
}
324
325
class zval_u1_u extends CData
326
{
327
    public int $extra;
328
}
329
330
class zval_u1_v extends CData
331
{
332
    public int $type;
333
    public int $type_flags;
334
    public zval_u1_u $u;
335
}
336
337
class zval_u1 extends CData
338
{
339
    public int $type_info;
340
    public zval_u1_v $v;
341
}
342
343
class zval_u2 extends CData
344
{
345
    public int $next;
346
    public int $opline_num;
347
    public int $lineno;
348
    public int $num_args;
349
    public int $fe_pos;
350
    public int $fe_iter_idx;
351
    public int $access_flags;
352
    public int $property_guard;
353
    public int $constant_flags;
354
    public int $extra;
355
}
356
357
class zend_vm_stack extends CData
358
{
359
    public ?CPointer $top;
360
    public ?CPointer $end;
361
    public ?CPointer $prev;
362
}
363
364
class zval extends CData
365
{
366
    public zend_value $value;
367
    public zval_u1 $u1;
368
    public zval_u2 $u2;
369
}
370
371
/** @implements \ArrayAccess<int, zval> */
372
class zval_array extends CData implements \ArrayAccess
373
{
374
    public function offsetExists($offset): bool
375
    {
376
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return boolean. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
377
    public function offsetGet($offset): zval
378
    {
379
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return FFI\PhpInternals\zval. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
380
}
381
382
class Bucket extends CData
383
{
384
    public zval $val;
385
    public int $h;
386
    public ?CPointer $key;
387
}
388
389
class zend_module_entry extends CData
390
{
391
    public int $zts;
392
    public ?CPointer $version;
393
}
394
395
class zend_hash_func_ffi extends \FFI
396
{
397
    public function zend_hash_func(string $str, int $len): int {}
0 ignored issues
show
Unused Code introduced by
The parameter $len is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

397
    public function zend_hash_func(string $str, /** @scrutinizer ignore-unused */ int $len): int {}

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $str is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

397
    public function zend_hash_func(/** @scrutinizer ignore-unused */ string $str, int $len): int {}

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return integer. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
398
}
399
400
class zend_array_v extends CData
401
{
402
    public int $flags;
403
    public int $nApplyCount;
404
    public int $nIteratorsCount;
405
    public int $consistency;
406
}
407
408
class zend_array_u extends CData
409
{
410
    public int $flags;
411
    public zend_array_v $v;
412
413
}
414
415
class zend_arg_info extends CData
416
{
417
    public ?CPointer $name;
418
    public ?CPointer $type;
419
}
420
421
class zend_array extends CData
422
{
423
    public zend_refcounted_h $gc;
424
    public zend_array_u $u;
425
    public int $nTableMask;
426
    public ?CPointer $arData;
427
    public ?CPointer $arPacked;
428
    public int $nNumUsed;
429
    public int $nNumOfElements;
430
    public int $nTableSize;
431
    public int $nInternalPointer;
432
    public int $nNextFreeElement;
433
}
434
435
class sapi_globals_struct extends CData
436
{
437
    public float $global_request_time;
438
}