Repository navigation
Expand file tree
/
Copy pathInitializerExprTypeResolver.cpp
More file actions
6101 lines (5488 loc) · 243 KB
/
Copy pathInitializerExprTypeResolver.cpp
File metadata and controls
6101 lines (5488 loc) · 243 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* PHPStanTurbo\InitializerExprTypeResolver — native implementation of
* PHPStan\Reflection\InitializerExprTypeResolver.
*
* A DI service (#[AutowiredService]): the constructor keeps the twin's
* arginfo so Nette autowires it (including the #[AutowiredParameter] bool).
* The class is final, so the direct entries (pt_initializer_expr_type_resolver_*)
* take the native body for exactly the native class and call the method by
* name on any other receiver.
*
* The twin's `callable(Expr): Type $getTypeCallback` parameters are a
* pt_ietr_get_type in C++: a function pointer plus its data, so a native
* caller hands the resolver its operand reader without allocating a closure
* (the twin only ever calls the callback synchronously). A PHP callable
* passed to the registered methods becomes such a callback over the value;
* where a PHP collaborator needs a real callable it may keep
* (OversizedArrayBuilder, a PHP receiver of an entry), the callback's
* toCallable() builds one that owns what it reads — the caller's NativeClosure
* over copies of its captures, never a pointer into a stack frame. The
* twin's own `fn (Expr $expr): Type => $this->getType($expr, $context)`
* closures are callbacks over the resolver and the context.
*
* The arithmetic runs on the engine's own operator functions
* (add_function(), mod_function(), bitwise_and_function(), zend_compare(),
* zval_get_long(), ...) and the internal min() / max(), so int overflow into
* float, float-to-int truncation and the mixed-type comparisons behave
* exactly like the twin's PHP operators.
*
* TypeCombinator, ConstantArrayTypeBuilder, ConstantTypeHelper, TypeResult,
* TypeUtils and the Type kernel are native (direct entries / TypeOps); the
* collaborators that stay PHP — ConstantResolver, ReflectionProviderProvider,
* PhpVersion (its versionId read in place), the operator extension
* registries, OversizedArrayBuilder, InitializerExprContext,
* ParserNodeTypeToPHPStanType, CallableAssertionsHelper, TemplateTag,
* SimpleThrowPoint and the php-parser node classes — go through cached
* method sites and the class map.
*/
#include "support.h"
#include "generated/InitializerExprTypeResolver.h"
#include "zv.h"
#include "TypeTraits.h"
#include "TypeOps.h"
#include "Engine.h"
#include "ParserVisitors.h"
#include <cmath>
#include <limits>
#include <vector>
zend_class_entry *pt_ce_initializer_expr_type_resolver = nullptr;
namespace slots = ptdecl::InitializerExprTypeResolver::slot;
namespace sigs = ptdecl::InitializerExprTypeResolver::sig;
namespace {
using phpstanturbo::NullableLong;
using phpstanturbo::visitors::NodeProp;
/* the twin's CALCULATE_SCALARS_LIMIT and its private IS_* codes */
constexpr zend_long PT_IETR_CALCULATE_SCALARS_LIMIT = PT_INITIALIZER_EXPR_TYPE_RESOLVER_CALCULATE_SCALARS_LIMIT;
constexpr zend_long PT_IETR_IS_SCALAR_TYPE = 1;
constexpr zend_long PT_IETR_IS_UNKNOWN = 2;
#define IETR_VAL(name, expr) \
zv::Val name = (expr); \
if (UNEXPECTED(name.isUndef())) return zv::Val()
#define IETR_TRI(name, expr) \
zend_long name = (expr); \
if (UNEXPECTED(name < 0)) return zv::Val()
/* {{{ Type method calls */
/* a Type method the resolver calls: its name as written (the engine's Error
* for a non-object receiver names it), lowercased at compile time for the
* by-name lookup, and its TypeOps id when it has one */
struct Method
{
const char *name;
char lc[48];
uint8_t len;
pt_type_op_id op;
constexpr Method(const char *n, pt_type_op_id o = PT_OP_COUNT) : name(n), lc{}, len(0), op(o)
{
while (n[len] != '\0') {
char c = n[len];
lc[len] = (c >= 'A' && c <= 'Z') ? (char) (c + ('a' - 'A')) : c;
len++;
}
}
};
constexpr Method mToNumber{"toNumber"};
constexpr Method mToString{"toString"};
constexpr Method mToInteger{"toInteger"};
constexpr Method mToBoolean{"toBoolean"};
constexpr Method mToFloat{"toFloat"};
constexpr Method mToArray{"toArray"};
constexpr Method mToBitwiseNotType{"toBitwiseNotType"};
constexpr Method mToBooleanType{"toBooleanType"};
constexpr Method mToClassConstantType{"toClassConstantType"};
constexpr Method mGetConstantScalarTypes{"getConstantScalarTypes"};
constexpr Method mGetConstantScalarValues{"getConstantScalarValues", PT_OP_GET_CONSTANT_SCALAR_VALUES};
constexpr Method mGetFiniteTypes{"getFiniteTypes"};
constexpr Method mGetConstantStrings{"getConstantStrings"};
constexpr Method mGetConstantArrays{"getConstantArrays", PT_OP_GET_CONSTANT_ARRAYS};
constexpr Method mIsInteger{"isInteger", PT_OP_IS_INTEGER};
constexpr Method mIsString{"isString", PT_OP_IS_STRING};
constexpr Method mIsFloat{"isFloat", PT_OP_IS_FLOAT};
constexpr Method mIsNull{"isNull", PT_OP_IS_NULL};
constexpr Method mIsArray{"isArray", PT_OP_IS_ARRAY};
constexpr Method mIsList{"isList", PT_OP_IS_LIST};
constexpr Method mIsVoid{"isVoid", PT_OP_IS_VOID};
constexpr Method mIsObject{"isObject"};
constexpr Method mIsEnum{"isEnum"};
constexpr Method mIsTrue{"isTrue"};
constexpr Method mIsFalse{"isFalse"};
constexpr Method mIsConstantArray{"isConstantArray", PT_OP_IS_CONSTANT_ARRAY};
constexpr Method mIsConstantScalarValue{"isConstantScalarValue", PT_OP_IS_CONSTANT_SCALAR_VALUE};
constexpr Method mIsClassString{"isClassString"};
constexpr Method mIsIterableAtLeastOnce{"isIterableAtLeastOnce", PT_OP_IS_ITERABLE_AT_LEAST_ONCE};
constexpr Method mIsNonEmptyString{"isNonEmptyString"};
constexpr Method mIsNonFalsyString{"isNonFalsyString"};
constexpr Method mIsLiteralString{"isLiteralString"};
constexpr Method mIsLowercaseString{"isLowercaseString"};
constexpr Method mIsUppercaseString{"isUppercaseString"};
constexpr Method mIsNumericString{"isNumericString"};
constexpr Method mIsUnsealed{"isUnsealed", PT_OP_IS_UNSEALED};
constexpr Method mGetUnsealedTypes{"getUnsealedTypes"};
constexpr Method mGetIterableKeyType{"getIterableKeyType", PT_OP_GET_ITERABLE_KEY_TYPE};
constexpr Method mGetIterableValueType{"getIterableValueType", PT_OP_GET_ITERABLE_VALUE_TYPE};
constexpr Method mIsSuperTypeOf{"isSuperTypeOf", PT_OP_IS_SUPER_TYPE_OF};
constexpr Method mEquals{"equals", PT_OP_EQUALS};
constexpr Method mGetValue{"getValue", PT_OP_GET_VALUE};
constexpr Method mGetTypes{"getTypes", PT_OP_GET_TYPES};
constexpr Method mGetKeyTypes{"getKeyTypes", PT_OP_GET_KEY_TYPES};
constexpr Method mGetValueTypes{"getValueTypes", PT_OP_GET_VALUE_TYPES};
constexpr Method mIsOptionalKey{"isOptionalKey"};
constexpr Method mHasOffsetValueType{"hasOffsetValueType", PT_OP_HAS_OFFSET_VALUE_TYPE};
constexpr Method mGetOffsetValueType{"getOffsetValueType", PT_OP_GET_OFFSET_VALUE_TYPE};
constexpr Method mAppend{"append"};
constexpr Method mExponentiate{"exponentiate"};
constexpr Method mLooseCompare{"looseCompare"};
constexpr Method mGetReasons{"getReasons"};
constexpr Method mIsSmallerThan{"isSmallerThan"};
constexpr Method mIsSmallerThanOrEqual{"isSmallerThanOrEqual"};
constexpr Method mGetValueType{"getValueType"};
constexpr Method mGetParentClass{"getParentClass", PT_OP_GET_PARENT_CLASS};
constexpr Method mGetName{"getName", PT_OP_GET_NAME};
constexpr Method mIsFinal{"isFinal", PT_OP_IS_FINAL};
constexpr Method mHasConstant{"hasConstant"};
constexpr Method mHasEnumCase{"hasEnumCase"};
constexpr Method mGetNativeReflection{"getNativeReflection"};
constexpr Method mGetReflectionConstant{"getReflectionConstant"};
constexpr Method mGetDeclaringClass{"getDeclaringClass"};
constexpr Method mGetFileName{"getFileName", PT_OP_GET_FILE_NAME};
constexpr Method mGetValueExpression{"getValueExpression"};
constexpr Method mGetType{"getType", PT_OP_GET_TYPE};
constexpr Method mGetConstantPhpDocType{"getConstantPhpDocType"};
constexpr Method mGetConstant{"getConstant"};
constexpr Method mHasPhpDocType{"hasPhpDocType"};
constexpr Method mHasNativeType{"hasNativeType"};
constexpr Method mGetValueExpr{"getValueExpr"};
constexpr Method mGetNativeType{"getNativeType"};
constexpr Method mGetVariants{"getVariants"};
constexpr Method mGetReturnType{"getReturnType"};
constexpr Method mGetNativeReturnType{"getNativeReturnType"};
constexpr Method mGetTemplateTypeMap{"getTemplateTypeMap", PT_OP_GET_TEMPLATE_TYPE_MAP};
constexpr Method mGetBound{"getBound"};
constexpr Method mGetDefault{"getDefault"};
constexpr Method mGetVariance{"getVariance"};
constexpr Method mGetThrowPoints{"getThrowPoints"};
constexpr Method mGetImpurePoints{"getImpurePoints"};
constexpr Method mAcceptsNamedArguments{"acceptsNamedArguments"};
constexpr Method mMustUseReturnValue{"mustUseReturnValue"};
constexpr Method mIsStaticClosure{"isStaticClosure"};
constexpr Method mGetThrowType{"getThrowType"};
constexpr Method mGetParameters{"getParameters"};
constexpr Method mGetAsserts{"getAsserts"};
constexpr Method mIsVariadic{"isVariadic", PT_OP_IS_VARIADIC};
constexpr Method mGetResolvedTemplateTypeMap{"getResolvedTemplateTypeMap"};
constexpr Method mGetCallSiteVarianceMap{"getCallSiteVarianceMap", PT_OP_GET_CALL_SITE_VARIANCE_MAP};
constexpr Method mHasMethod{"hasMethod", PT_OP_HAS_METHOD};
constexpr Method mGetMethod{"getMethod", PT_OP_GET_METHOD};
constexpr Method mIsStatic{"isStatic"};
constexpr Method mGetStaticObjectType{"getStaticObjectType"};
constexpr Method mChangeBaseClass{"changeBaseClass", PT_OP_CHANGE_BASE_CLASS};
constexpr Method mGetClassReflection{"getClassReflection", PT_OP_GET_CLASS_REFLECTION};
constexpr Method mGetObjectClassReflections{"getObjectClassReflections", PT_OP_GET_OBJECT_CLASS_REFLECTIONS};
constexpr Method mGetAncestorWithClassName{"getAncestorWithClassName", PT_OP_GET_ANCESTOR_WITH_CLASS_NAME};
constexpr Method mGetClassName{"getClassName"};
constexpr Method mGetClassStringObjectType{"getClassStringObjectType"};
constexpr Method mGetObjectClassNames{"getObjectClassNames", PT_OP_GET_OBJECT_CLASS_NAMES};
constexpr Method mHasInstanceProperty{"hasInstanceProperty", PT_OP_HAS_INSTANCE_PROPERTY};
constexpr Method mGetInstanceProperty{"getInstanceProperty", PT_OP_GET_INSTANCE_PROPERTY};
constexpr Method mGetReadableType{"getReadableType"};
constexpr Method mGetExprType{"getExprType"};
constexpr Method mGeneralize{"generalize"};
constexpr Method mGetStartLine{"getStartLine"};
/* the engine's Error for a method call on a non-object */
inline void throwCallOnNonObject(const Method &m, zval *receiver)
{
zend_throw_error(NULL, "Call to a member function %s() on %s", m.name, zend_zval_value_name(receiver));
}
/* $receiver->method(...$argv); UNDEF = pending exception */
inline zv::Val callOn(zval *receiver, const Method &m, uint32_t argc = 0, zval *argv = NULL)
{
if (UNEXPECTED(Z_TYPE_P(receiver) != IS_OBJECT)) {
throwCallOnNonObject(m, receiver);
return zv::Val();
}
if (m.op != PT_OP_COUNT) return pt_type_op(Z_OBJ_P(receiver), m.op, argc, argv);
return pt_type_call(Z_OBJ_P(receiver), m.lc, m.len, argc, argv);
}
/* the PT_TRI_* value of a TrinaryLogic / result object's ->yes()/->no()
* family (a TrinaryLogic or an IsSuperTypeOfResult / AcceptsResult); -1 =
* pending exception */
inline zend_long trinaryOf(zval *value)
{
if (EXPECTED(Z_TYPE_P(value) == IS_OBJECT)) {
zend_class_entry *ce = Z_OBJCE_P(value);
if (EXPECTED(ce == pt_ce_trinary)) return pt_trinary_value(Z_OBJ_P(value));
if (ce == pt_ce_is_super_type_of_result || ce == pt_ce_accepts_result) return pt_type_result_trinary(value);
zv::Val yes = pt_type_call(Z_OBJ_P(value), PT_LC("yes"), 0, NULL);
if (UNEXPECTED(yes.isUndef())) return -1;
if (zend_is_true(yes.raw())) return PT_TRI_YES;
zv::Val no = pt_type_call(Z_OBJ_P(value), PT_LC("no"), 0, NULL);
if (UNEXPECTED(no.isUndef())) return -1;
return zend_is_true(no.raw()) ? PT_TRI_NO : PT_TRI_MAYBE;
}
zend_throw_error(NULL, "Call to a member function yes() on %s", zend_zval_value_name(value));
return -1;
}
/* $receiver->method(...$argv) of a method returning TrinaryLogic (or a
* result object): the PT_TRI_* value, -1 = pending exception */
inline zend_long triOn(zval *receiver, const Method &m, uint32_t argc = 0, zval *argv = NULL)
{
zv::Val result = callOn(receiver, m, argc, argv);
if (UNEXPECTED(result.isUndef())) return -1;
return trinaryOf(result.raw());
}
/* $value instanceof <native class> */
inline bool isA(zval *value, zend_class_entry *ce)
{
return Z_TYPE_P(value) == IS_OBJECT && instanceof_function(Z_OBJCE_P(value), ce);
}
/* $value instanceof <class-map class>; -1 = pending exception */
inline int isAClass(zval *value, int classIdx)
{
zend_class_entry *ce = pt_class(classIdx);
if (UNEXPECTED(ce == NULL)) return -1;
return Z_TYPE_P(value) == IS_OBJECT && instanceof_function(Z_OBJCE_P(value), ce) ? 1 : 0;
}
/* }}} */
/* {{{ Type construction */
inline zv::Val adopted(bool ok, zval &value)
{
if (UNEXPECTED(!ok)) return zv::Val();
return zv::Val::adopt(value);
}
zv::Val newErrorType()
{
zval z;
return adopted(pt_error_type_new(&z), z);
}
zv::Val newMixedType(bool isExplicitMixed = false)
{
zval z;
return adopted(pt_mixed_type_new(&z, isExplicitMixed), z);
}
zv::Val newNeverType()
{
zval z;
return adopted(pt_never_type_new(&z), z);
}
zv::Val newIntegerType()
{
zval z;
return adopted(pt_integer_type_new(&z), z);
}
zv::Val newFloatType()
{
zval z;
return adopted(pt_float_type_new(&z), z);
}
zv::Val newStringType()
{
zval z;
return adopted(pt_string_type_new(&z), z);
}
zv::Val newNullType()
{
zval z;
return adopted(pt_null_type_new(&z), z);
}
zv::Val newBooleanType()
{
zval z;
return adopted(pt_boolean_type_new(&z), z);
}
zv::Val newConstantBooleanType(bool value)
{
zval z;
return adopted(pt_constant_boolean_type_new(&z, value), z);
}
zv::Val newConstantIntegerType(zend_long value)
{
zval z;
return adopted(pt_constant_integer_type_new(&z, value), z);
}
zv::Val newConstantFloatType(double value)
{
zval z;
return adopted(pt_constant_float_type_new(&z, value), z);
}
zv::Val newConstantStringType(zend_string *value, bool isClassString = false)
{
zval z;
return adopted(pt_constant_string_type_new(&z, value, isClassString), z);
}
zv::Val newClassStringType()
{
zval z;
return adopted(pt_class_string_type_new(&z), z);
}
zv::Val newObjectType(zend_string *className)
{
zval z;
return adopted(pt_object_type_new(&z, className), z);
}
zv::Val newObjectTypeLiteral(const char *className, size_t len)
{
zend_string *name = zend_string_init(className, len, 0);
zv::Val type = newObjectType(name);
zend_string_release(name);
return type;
}
zv::Val newArrayType(zval *keyType, zval *itemType)
{
zval z;
return adopted(pt_array_type_new(&z, keyType, itemType), z);
}
zv::Val newUnionType(zv::Arr &types)
{
zval z;
return adopted(pt_union_type_new(&z, types.raw()), z);
}
zv::Val newBenevolentUnionType(zv::Arr &types)
{
zval z;
return adopted(pt_benevolent_union_type_new(&z, types.raw()), z);
}
zv::Val newIntersectionType(zv::Arr &types)
{
zval z;
return adopted(pt_intersection_type_new(&z, types.raw()), z);
}
/* new BenevolentUnionType([new IntegerType(), new FloatType()]) (the order
* the twin spells: first, second) */
zv::Val newIntFloatUnion(bool benevolent, bool floatFirst = false)
{
IETR_VAL(integerType, newIntegerType());
IETR_VAL(floatType, newFloatType());
zv::Arr types = zv::Arr::create(2);
if (floatFirst) {
types.push(std::move(floatType));
types.push(std::move(integerType));
} else {
types.push(std::move(integerType));
types.push(std::move(floatType));
}
return benevolent ? newBenevolentUnionType(types) : newUnionType(types);
}
/* new TypeResult($type, []) */
zv::Val newTypeResult(zv::Val type)
{
if (UNEXPECTED(type.isUndef())) return zv::Val();
zval reasons;
ZVAL_EMPTY_ARRAY(&reasons);
return pt_type_result_new(type.raw(), &reasons);
}
/* TypeCombinator::union(...$types) of a list the resolver built */
zv::Val unionOf(zv::Arr &types)
{
HashTable *ht = types.table();
uint32_t count = zend_hash_num_elements(ht);
if (count == 0) return pt_type_combinator_union(0, NULL);
if (EXPECTED(HT_IS_PACKED(ht) && HT_IS_WITHOUT_HOLES(ht))) return pt_type_combinator_union(count, ht->arPacked);
return pt_type_combinator_call_spread(PT_LC("union"), ht);
}
/* TypeCombinator::union($a, $b) */
zv::Val union2(zval *a, zval *b)
{
zv::Args argv{a, b};
return pt_type_combinator_union(2, argv);
}
/* ConstantTypeHelper::getTypeFromValue($value) */
zv::Val typeFromValue(zval *value)
{
return pt_constant_type_helper_get_type_from_value(value);
}
/* IntegerRangeType::fromInterval($min, $max) of int|null zvals; a float (the
* twin's arithmetic overflowed) raises the TypeError of the twin's
* strict-types call */
zv::Val fromIntervalZv(zval *min, zval *max)
{
bool minOk = Z_TYPE_P(min) == IS_LONG || Z_TYPE_P(min) == IS_NULL;
bool maxOk = Z_TYPE_P(max) == IS_LONG || Z_TYPE_P(max) == IS_NULL;
if (EXPECTED(minOk && maxOk)) return pt_integer_range_from_interval(NullableLong::from(min), NullableLong::from(max), 0);
zend_type_error("PHPStan\\Type\\IntegerRangeType::fromInterval(): Argument #%d ($%s) must be of type ?int, %s given", minOk ? 2 : 1, minOk ? "max" : "min", zend_zval_value_name(minOk ? max : min));
return zv::Val();
}
zv::Val fromInterval(NullableLong min, NullableLong max)
{
return pt_integer_range_from_interval(min, max, 0);
}
/* TypeUtils::toBenevolentUnion($type) */
zv::Val toBenevolentUnion(zval *type)
{
return pt_type_call_static_ce(pt_ce_type_utils, PT_LC("tobenevolentunion"), 1, type);
}
/* }}} */
/* {{{ PHP value arithmetic (the twin's operators, on the engine's functions) */
typedef zend_result (ZEND_FASTCALL *pt_ietr_binary_op)(zval *result, zval *op1, zval *op2);
/* $a <op> $b; UNDEF = pending exception */
zv::Val phpOp(pt_ietr_binary_op fn, zval *a, zval *b)
{
zval result;
ZVAL_UNDEF(&result);
if (UNEXPECTED(fn(&result, a, b) != SUCCESS || EG(exception) != NULL)) {
zval_ptr_dtor(&result);
return zv::Val();
}
return zv::Val::adopt(result);
}
/* an internal function of the engine's function table called directly
* (the function the twin calls: min(), max(), dirname()), its lookup cached
* in `cache`; UNDEF = pending exception */
zv::Val callInternalFunction(zend_function *&cache, const char *name, size_t len, uint32_t argc, zval *argv)
{
if (UNEXPECTED(cache == NULL)) {
cache = (zend_function *) zend_hash_str_find_ptr(CG(function_table), name, len);
if (UNEXPECTED(cache == NULL)) {
zend_throw_error(NULL, "Call to undefined function %s()", name);
return zv::Val();
}
}
zval result;
ZVAL_UNDEF(&result);
zend_call_known_function(cache, NULL, NULL, &result, argc, argv, NULL);
if (UNEXPECTED(EG(exception) != NULL)) {
zval_ptr_dtor(&result);
return zv::Val();
}
return zv::Val::adopt(result);
}
/* min(...$argv) / max(...$argv) */
zv::Val phpMinMax(bool max, uint32_t argc, zval *argv)
{
static zend_function *minFn = NULL;
static zend_function *maxFn = NULL;
return max ? callInternalFunction(maxFn, PT_LC("max"), argc, argv) : callInternalFunction(minFn, PT_LC("min"), argc, argv);
}
/* dirname($path) */
zv::Val phpDirname(zval *path)
{
static zend_function *dirnameFn = NULL;
return callInternalFunction(dirnameFn, PT_LC("dirname"), 1, path);
}
/* $value === 0 || $value === 0.0 — in_array($value, [0, 0.0], true) */
inline bool isZeroNumber(zval *value)
{
return (Z_TYPE_P(value) == IS_LONG && Z_LVAL_P(value) == 0) || (Z_TYPE_P(value) == IS_DOUBLE && Z_DVAL_P(value) == 0.0);
}
/* $a === $b for scalars */
inline bool identical(zval *a, zval *b)
{
return zend_is_identical(a, b);
}
/* $a > $b / $a < $b (zend_compare, as the VM's IS_SMALLER) */
inline bool greaterThan(zval *a, zval *b)
{
return zend_compare(b, a) < 0;
}
inline bool lessThan(zval *a, zval *b)
{
return zend_compare(a, b) < 0;
}
/* }}} */
/* {{{ php-parser nodes */
NodeProp pt_ietr_name_name = PT_NAME_PROP;
NodeProp pt_ietr_identifier_name = PT_NODE_PROP(PT_CLASS_IDENTIFIER, "name");
/* new <BinaryOp class>($left, $right) through the class map */
zv::Val newBinaryOpNode(int classIdx, zval *left, zval *right)
{
zv::Args argv{left, right};
return pt_type_new(classIdx, 2, argv);
}
/* }}} */
/* {{{ the PHP collaborators (one site each; switch to their direct entries
* once they are ported) */
pt_method_site pt_ietr_call_operator_site;
pt_method_site pt_ietr_call_unary_operator_site;
/* $registry->callOperatorTypeSpecifyingExtensions($expr, $leftType, $rightType) */
zv::Val callOperatorTypeSpecifyingExtensions(zval *registry, zval *expr, zval *leftType, zval *rightType)
{
zv::Args argv{expr, leftType, rightType};
return pt_call_method_cached(pt_ietr_call_operator_site, Z_OBJ_P(registry), PT_LC("calloperatortypespecifyingextensions"), 3, argv);
}
/* $registry->callUnaryOperatorTypeSpecifyingExtensions($sigil, $operandType) */
zv::Val callUnaryOperatorTypeSpecifyingExtensions(zval *registry, const char *sigil, zval *operandType)
{
zval sigilZv;
ZVAL_CHAR(&sigilZv, sigil[0]);
zv::Args argv{&sigilZv, operandType};
return pt_call_method_cached(pt_ietr_call_unary_operator_site, Z_OBJ_P(registry), PT_LC("callunaryoperatortypespecifyingextensions"), 2, argv);
}
/* $phpVersion->versionId >= $minimum (the final PhpVersion's supports*()
* one-liners), the method on anything else; -1 = pending exception */
int phpVersionAtLeast(zval *phpVersion, zend_long minimum, const char *lcname, size_t len)
{
if (EXPECTED(Z_TYPE_P(phpVersion) == IS_OBJECT)) {
zend_class_entry *phpVersionCe = pt_class(PT_CLASS_PHP_VERSION);
if (UNEXPECTED(phpVersionCe == NULL)) return -1;
if (EXPECTED(Z_OBJCE_P(phpVersion) == phpVersionCe)) {
static int32_t offset = -2;
static zend_class_entry *offsetFor = NULL;
if (UNEXPECTED(offsetFor != phpVersionCe)) {
offsetFor = phpVersionCe;
offset = pt_instance_prop_offset(phpVersionCe, PT_LC("versionId"));
}
if (EXPECTED(offset >= 0)) {
zval *versionId = OBJ_PROP(Z_OBJ_P(phpVersion), (uint32_t) offset);
if (EXPECTED(Z_TYPE_P(versionId) == IS_LONG)) return Z_LVAL_P(versionId) >= minimum ? 1 : 0;
}
}
zv::Val result = pt_type_call(Z_OBJ_P(phpVersion), lcname, len, 0, NULL);
if (UNEXPECTED(result.isUndef())) return -1;
return zend_is_true(result.raw()) ? 1 : 0;
}
zend_throw_error(NULL, "Call to a member function %s() on %s", lcname, zend_zval_value_name(phpVersion));
return -1;
}
/* }}} */
/* {{{ more php-parser node properties */
NodeProp pt_ietr_array_items = PT_NODE_PROP(PT_CLASS_ARRAY_EXPR, "items");
NodeProp pt_ietr_array_item_value = PT_NODE_PROP(PT_CLASS_ARRAY_ITEM, "value");
NodeProp pt_ietr_array_item_key = PT_NODE_PROP(PT_CLASS_ARRAY_ITEM, "key");
NodeProp pt_ietr_array_item_unpack = PT_NODE_PROP(PT_CLASS_ARRAY_ITEM, "unpack");
NodeProp pt_ietr_cast_expr = PT_NODE_PROP(PT_CLASS_CAST_EXPR, "expr");
NodeProp pt_ietr_func_call_name = PT_NODE_PROP(PT_CLASS_FUNC_CALL, "name");
NodeProp pt_ietr_func_call_args = PT_NODE_PROP(PT_CLASS_FUNC_CALL, "args");
NodeProp pt_ietr_static_call_class = PT_NODE_PROP(PT_CLASS_STATIC_CALL, "class");
NodeProp pt_ietr_static_call_name = PT_NODE_PROP(PT_CLASS_STATIC_CALL, "name");
NodeProp pt_ietr_param_default = PT_NODE_PROP(PT_CLASS_PARAM, "default");
NodeProp pt_ietr_param_var = PT_NODE_PROP(PT_CLASS_PARAM, "var");
NodeProp pt_ietr_param_variadic = PT_NODE_PROP(PT_CLASS_PARAM, "variadic");
NodeProp pt_ietr_param_by_ref = PT_NODE_PROP(PT_CLASS_PARAM, "byRef");
NodeProp pt_ietr_param_type = PT_NODE_PROP(PT_CLASS_PARAM, "type");
NodeProp pt_ietr_const_fetch_name = PT_NODE_PROP(PT_CLASS_CONST_FETCH, "name");
NodeProp pt_ietr_variable_name = PT_NODE_PROP(PT_CLASS_VARIABLE, "name");
NodeProp pt_ietr_closure_params = PT_NODE_PROP(PT_CLASS_CLOSURE_EXPR, "params");
NodeProp pt_ietr_closure_static = PT_NODE_PROP(PT_CLASS_CLOSURE_EXPR, "static");
NodeProp pt_ietr_closure_return_type = PT_NODE_PROP(PT_CLASS_CLOSURE_EXPR, "returnType");
NodeProp pt_ietr_new_class = PT_NODE_PROP(PT_CLASS_NEW, "class");
NodeProp pt_ietr_array_dim_fetch_var = PT_NODE_PROP(PT_CLASS_ARRAY_DIM_FETCH, "var");
NodeProp pt_ietr_array_dim_fetch_dim = PT_NODE_PROP(PT_CLASS_ARRAY_DIM_FETCH, "dim");
NodeProp pt_ietr_class_const_fetch_class = PT_NODE_PROP(PT_CLASS_CLASS_CONST_FETCH, "class");
NodeProp pt_ietr_class_const_fetch_name = PT_NODE_PROP(PT_CLASS_CLASS_CONST_FETCH, "name");
NodeProp pt_ietr_unary_plus_expr = PT_NODE_PROP(PT_CLASS_UNARY_PLUS, "expr");
NodeProp pt_ietr_unary_minus_expr = PT_NODE_PROP(PT_CLASS_UNARY_MINUS, "expr");
NodeProp pt_ietr_boolean_not_expr = PT_NODE_PROP(PT_CLASS_BOOLEAN_NOT_EXPR, "expr");
NodeProp pt_ietr_bitwise_not_expr = PT_NODE_PROP(PT_CLASS_BITWISE_NOT, "expr");
NodeProp pt_ietr_binary_op_left = PT_NODE_PROP(PT_CLASS_BINARY_OP_EXPR, "left");
NodeProp pt_ietr_binary_op_right = PT_NODE_PROP(PT_CLASS_BINARY_OP_EXPR, "right");
NodeProp pt_ietr_ternary_cond = PT_NODE_PROP(PT_CLASS_TERNARY_EXPR, "cond");
NodeProp pt_ietr_ternary_if = PT_NODE_PROP(PT_CLASS_TERNARY_EXPR, "if");
NodeProp pt_ietr_ternary_else = PT_NODE_PROP(PT_CLASS_TERNARY_EXPR, "else");
NodeProp pt_ietr_arg_value = PT_NODE_PROP(PT_CLASS_ARG, "value");
NodeProp pt_ietr_scalar_string_value = PT_NODE_PROP(PT_CLASS_SCALAR_STRING, "value");
NodeProp pt_ietr_scalar_int_value = PT_NODE_PROP(PT_CLASS_SCALAR_INT, "value");
NodeProp pt_ietr_scalar_float_value = PT_NODE_PROP(PT_CLASS_SCALAR_FLOAT, "value");
NodeProp pt_ietr_property_fetch_var = PT_NODE_PROP(PT_CLASS_PROPERTY_FETCH, "var");
NodeProp pt_ietr_property_fetch_name = PT_NODE_PROP(PT_CLASS_PROPERTY_FETCH, "name");
/* $node->$name of a node the dispatch guarantees to be an instance of the
* property's class (dereferenced); NULL with the engine's Error pending (an
* uninitialized typed property, or the class map failing) */
zval *nodeProp(NodeProp &prop, zval *node)
{
zval *value = prop.of(Z_OBJ_P(node));
if (EXPECTED(value != NULL && Z_TYPE_P(value) != IS_UNDEF)) return value;
if (EG(exception) != NULL) return NULL;
if (value == NULL) {
zend_throw_error(NULL, "Undefined property: %s::$%s", ZSTR_VAL(Z_OBJCE_P(node)->name), prop.name);
return NULL;
}
zend_throw_error(NULL, "Typed property %s::$%s must not be accessed before initialization", ZSTR_VAL(Z_OBJCE_P(node)->name), prop.name);
return NULL;
}
/* (string) $name of a Name node: its $name string (NULL with an exception
* pending) */
zend_string *nameString(zval *name)
{
zval *value = nodeProp(pt_ietr_name_name, name);
if (UNEXPECTED(value == NULL)) return NULL;
if (UNEXPECTED(Z_TYPE_P(value) != IS_STRING)) {
pt_throw_should_not_happen();
return NULL;
}
return Z_STR_P(value);
}
/* (string) $identifier / $identifier->toString() of an Identifier node */
zend_string *identifierString(zval *identifier)
{
zval *value = nodeProp(pt_ietr_identifier_name, identifier);
if (UNEXPECTED(value == NULL)) return NULL;
if (UNEXPECTED(Z_TYPE_P(value) != IS_STRING)) {
pt_throw_should_not_happen();
return NULL;
}
return Z_STR_P(value);
}
/* }}} */
/* {{{ the PHP collaborators of the reflection and constant-expression paths */
pt_method_site pt_ietr_get_reflection_provider_site;
pt_method_site pt_ietr_resolve_constant_site;
pt_method_site pt_ietr_resolve_predefined_constant_site;
pt_method_site pt_ietr_resolve_class_constant_type_site;
pt_method_site pt_ietr_oversized_build_site;
pt_method_site pt_ietr_parser_node_type_resolve_site;
pt_method_site pt_ietr_with_conditional_return_predicate_site;
pt_method_site pt_ietr_simple_throw_point_create_explicit_site;
pt_method_site pt_ietr_simple_throw_point_create_implicit_site;
pt_method_site pt_ietr_generalize_precision_more_specific_site;
/* $reflectionProviderProvider->getReflectionProvider() */
zv::Val reflectionProviderOf(zval *reflectionProviderProvider)
{
return pt_call_method_cached(pt_ietr_get_reflection_provider_site, Z_OBJ_P(reflectionProviderProvider), PT_LC("getreflectionprovider"), 0, NULL);
}
/* $constantResolver->resolveConstant($name, $context) */
zv::Val resolveConstant(zval *constantResolver, zval *name, zval *context)
{
zv::Args argv{name, context};
return pt_call_method_cached(pt_ietr_resolve_constant_site, Z_OBJ_P(constantResolver), PT_LC("resolveconstant"), 2, argv);
}
/* $constantResolver->resolvePredefinedConstant($name) */
zv::Val resolvePredefinedConstant(zval *constantResolver, zval *name)
{
return pt_call_method_cached(pt_ietr_resolve_predefined_constant_site, Z_OBJ_P(constantResolver), PT_LC("resolvepredefinedconstant"), 1, name);
}
/* $constantResolver->resolveClassConstantType($className, $constantName,
* $constantType, $nativeType, $phpDocType) */
zv::Val resolveClassConstantType(zval *constantResolver, zval *className, zval *constantName, zval *constantType, zval *nativeType, zval *phpDocType)
{
zv::Args argv{className, constantName, constantType, nativeType, phpDocType};
return pt_call_method_cached(pt_ietr_resolve_class_constant_type_site, Z_OBJ_P(constantResolver), PT_LC("resolveclassconstanttype"), 5, argv);
}
/* $oversizedArrayBuilder->build($expr, $getTypeCallback) */
zv::Val oversizedArrayBuild(zval *builder, zval *expr, zval *getTypeCallback)
{
zv::Args argv{expr, getTypeCallback};
return pt_call_method_cached(pt_ietr_oversized_build_site, Z_OBJ_P(builder), PT_LC("build"), 2, argv);
}
/* ParserNodeTypeToPHPStanType::resolve($type, $classReflection) */
zv::Val parserNodeTypeResolve(zval *type, zval *classReflection)
{
zv::Args argv{type, classReflection};
return pt_call_static_cached(pt_ietr_parser_node_type_resolve_site, PT_CLASS_PARSER_NODE_TYPE_TO_PHPSTAN_TYPE, PT_LC("resolve"), 2, argv);
}
/* CallableAssertionsHelper::withConditionalReturnPredicate($assertions, $variant) */
zv::Val withConditionalReturnPredicate(zval *assertions, zval *variant)
{
zv::Args argv{assertions, variant};
return pt_call_static_cached(pt_ietr_with_conditional_return_predicate_site, PT_CLASS_CALLABLE_ASSERTIONS_HELPER, PT_LC("withconditionalreturnpredicate"), 2, argv);
}
/* SimpleThrowPoint::createExplicit($type, $canContainAnyThrowable) */
zv::Val simpleThrowPointCreateExplicit(zval *type, bool canContainAnyThrowable)
{
zval flag = {};
ZVAL_BOOL(&flag, canContainAnyThrowable);
zv::Args argv{type, &flag};
return pt_call_static_cached(pt_ietr_simple_throw_point_create_explicit_site, PT_CLASS_SIMPLE_THROW_POINT, PT_LC("createexplicit"), 2, argv);
}
/* SimpleThrowPoint::createImplicit() */
zv::Val simpleThrowPointCreateImplicit()
{
return pt_call_static_cached(pt_ietr_simple_throw_point_create_implicit_site, PT_CLASS_SIMPLE_THROW_POINT, PT_LC("createimplicit"), 0, NULL);
}
/* InitializerExprContext::fromClass($className, $fileName) */
zv::Val contextFromClass(zval *className, zval *fileName)
{
return pt_initializer_expr_context_from_class(className, fileName);
}
/* InitializerExprContext::fromClassReflection($classReflection) */
zv::Val contextFromClassReflection(zval *classReflection)
{
return pt_initializer_expr_context_from_class_reflection(classReflection);
}
/* GeneralizePrecision::moreSpecific() */
zv::Val generalizePrecisionMoreSpecific()
{
return pt_call_static_cached(pt_ietr_generalize_precision_more_specific_site, PT_CLASS_GENERALIZE_PRECISION, PT_LC("morespecific"), 0, NULL);
}
/* $context->getFile() / getClassName() / getNamespace() / getTraitName() /
* getFunction() / getMethod() / getProperty() (a ?string): the slot readers
* of the native InitializerExprContext (AnalyserValues.h) */
zv::Val contextGetter(zval *context, zval *(*reader)(zval *, zv::Val &), const char *name)
{
if (UNEXPECTED(Z_TYPE_P(context) != IS_OBJECT)) {
zend_throw_error(NULL, "Call to a member function %s() on %s", name, zend_zval_value_name(context));
return zv::Val();
}
zv::Val hold;
zval *value = reader(context, hold);
if (UNEXPECTED(value == NULL)) return zv::Val();
return zv::Val::copyOf(zv::Ref(value));
}
inline zv::Val contextGetFile(zval *context) { return contextGetter(context, pt_initializer_expr_context_file, "getFile"); }
inline zv::Val contextGetClassName(zval *context) { return contextGetter(context, pt_initializer_expr_context_class_name, "getClassName"); }
inline zv::Val contextGetNamespace(zval *context) { return contextGetter(context, pt_initializer_expr_context_namespace, "getNamespace"); }
inline zv::Val contextGetTraitName(zval *context) { return contextGetter(context, pt_initializer_expr_context_trait_name, "getTraitName"); }
inline zv::Val contextGetFunction(zval *context) { return contextGetter(context, pt_initializer_expr_context_function, "getFunction"); }
inline zv::Val contextGetMethod(zval *context) { return contextGetter(context, pt_initializer_expr_context_method, "getMethod"); }
inline zv::Val contextGetProperty(zval *context) { return contextGetter(context, pt_initializer_expr_context_property, "getProperty"); }
/* }}} */
/* {{{ the getTypeCallback */
/* $callback($expr) of a PHP callable handed to a registered method; the
* callable itself (another reference to it) where it escapes */
zv::Val callableGetType(void *data, zval *expr)
{
return pt_type_call_callable(static_cast<zval *>(data), 1, expr);
}
zv::Val callableToCallable(void *data)
{
return zv::Val::copyOf(zv::Ref(static_cast<zval *>(data)));
}
inline pt_ietr_get_type callableCallback(zval *callable)
{
return { &callableGetType, callable, &callableToCallable };
}
inline zv::Val getTypeOf(const pt_ietr_get_type &callback, zval *expr)
{
return callback.fn(callback.data, expr);
}
/* the callback as a PHP callable for a collaborator that may keep it: the
* caller's owning callable (pt_ietr_get_type::toCallable) */
inline zv::Val callbackCallable(const pt_ietr_get_type &callback)
{
return callback.toCallable(callback.data);
}
/* }}} */
} // namespace
namespace phpstanturbo {
/* the binary operators whose type the resolver computes */
enum IetrBinaryKind : uint8_t
{
IETR_PLUS,
IETR_MINUS,
IETR_MUL,
IETR_DIV,
IETR_MOD,
IETR_POW,
IETR_SHIFT_LEFT,
IETR_SHIFT_RIGHT,
IETR_BITWISE_AND,
IETR_BITWISE_OR,
IETR_BITWISE_XOR,
IETR_OTHER,
};
inline constexpr int ietrBinaryKindClasses[IETR_OTHER] = {
PT_CLASS_BINARY_OP_PLUS,
PT_CLASS_BINARY_OP_MINUS,
PT_CLASS_MUL_EXPR,
PT_CLASS_DIV_EXPR,
PT_CLASS_MOD_EXPR,
PT_CLASS_POW_EXPR,
PT_CLASS_SHIFT_LEFT_EXPR,
PT_CLASS_SHIFT_RIGHT_EXPR,
PT_CLASS_BITWISE_AND_EXPR,
PT_CLASS_BITWISE_OR_EXPR,
PT_CLASS_BITWISE_XOR_EXPR,
};
/* {{{ getType()'s instanceof chain: the arms in the twin's order */
enum IetrGetTypeArm : uint8_t
{
ARM_TYPE_EXPR,
ARM_INT,
ARM_FLOAT,
ARM_STRING,
ARM_CONST_FETCH,
ARM_FILE,
ARM_DIR,
ARM_LINE,
ARM_NEW,
ARM_ARRAY,
ARM_CAST,
ARM_CALL_LIKE,
ARM_CLOSURE,
ARM_ARRAY_DIM_FETCH,
ARM_CLASS_CONST_FETCH,
ARM_UNARY_PLUS,
ARM_UNARY_MINUS,
ARM_COALESCE,
ARM_TERNARY,
ARM_FUNC_CALL,
ARM_BOOLEAN_NOT,
ARM_BITWISE_NOT,
ARM_CONCAT,
ARM_BITWISE_AND,
ARM_BITWISE_OR,
ARM_BITWISE_XOR,
ARM_SPACESHIP,
ARM_BOOLEAN_AND,
ARM_LOGICAL_AND,
ARM_BOOLEAN_OR,
ARM_LOGICAL_OR,
ARM_DIV,
ARM_MOD,
ARM_PLUS,
ARM_MINUS,
ARM_MUL,
ARM_POW,
ARM_SHIFT_LEFT,
ARM_SHIFT_RIGHT,
ARM_IDENTICAL,
ARM_NOT_IDENTICAL,
ARM_EQUAL,
ARM_NOT_EQUAL,
ARM_SMALLER,
ARM_SMALLER_OR_EQUAL,
ARM_GREATER,
ARM_GREATER_OR_EQUAL,
ARM_LOGICAL_XOR,
ARM_MAGIC_CLASS,
ARM_MAGIC_NAMESPACE,
ARM_MAGIC_METHOD,
ARM_MAGIC_FUNCTION,
ARM_MAGIC_TRAIT,
ARM_MAGIC_PROPERTY,
ARM_PROPERTY_FETCH,
ARM_COUNT,
};
inline constexpr int ietrArmClasses[ARM_COUNT] = {
PT_CLASS_TYPE_EXPR,
PT_CLASS_SCALAR_INT,
PT_CLASS_SCALAR_FLOAT,
PT_CLASS_SCALAR_STRING,
PT_CLASS_CONST_FETCH,
PT_CLASS_MAGIC_CONST_FILE,
PT_CLASS_MAGIC_CONST_DIR,
PT_CLASS_MAGIC_CONST_LINE,
PT_CLASS_NEW,
PT_CLASS_ARRAY_EXPR,
PT_CLASS_CAST_EXPR,
PT_CLASS_CALL_LIKE,
PT_CLASS_CLOSURE_EXPR,
PT_CLASS_ARRAY_DIM_FETCH,
PT_CLASS_CLASS_CONST_FETCH,
PT_CLASS_UNARY_PLUS,
PT_CLASS_UNARY_MINUS,
PT_CLASS_COALESCE_EXPR,
PT_CLASS_TERNARY_EXPR,
PT_CLASS_FUNC_CALL,
PT_CLASS_BOOLEAN_NOT_EXPR,
PT_CLASS_BITWISE_NOT,
PT_CLASS_CONCAT_EXPR,
PT_CLASS_BITWISE_AND_EXPR,
PT_CLASS_BITWISE_OR_EXPR,
PT_CLASS_BITWISE_XOR_EXPR,
PT_CLASS_SPACESHIP_EXPR,
PT_CLASS_BOOLEAN_AND_EXPR,
PT_CLASS_LOGICAL_AND_EXPR,
PT_CLASS_BOOLEAN_OR_EXPR,
PT_CLASS_LOGICAL_OR_EXPR,
PT_CLASS_DIV_EXPR,
PT_CLASS_MOD_EXPR,
PT_CLASS_BINARY_OP_PLUS,
PT_CLASS_BINARY_OP_MINUS,
PT_CLASS_MUL_EXPR,
PT_CLASS_POW_EXPR,
PT_CLASS_SHIFT_LEFT_EXPR,
PT_CLASS_SHIFT_RIGHT_EXPR,
PT_CLASS_IDENTICAL_EXPR,
PT_CLASS_BINARY_OP_NOT_IDENTICAL,
PT_CLASS_EQUAL_EXPR,
PT_CLASS_NOT_EQUAL_EXPR,
PT_CLASS_SMALLER_EXPR,
PT_CLASS_SMALLER_OR_EQUAL_EXPR,
PT_CLASS_GREATER_EXPR,
PT_CLASS_GREATER_OR_EQUAL_EXPR,
PT_CLASS_LOGICAL_XOR_EXPR,
PT_CLASS_MAGIC_CONST_CLASS,
PT_CLASS_MAGIC_CONST_NAMESPACE,
PT_CLASS_MAGIC_CONST_METHOD,
PT_CLASS_MAGIC_CONST_FUNCTION,
PT_CLASS_MAGIC_CONST_TRAIT,
PT_CLASS_MAGIC_CONST_PROPERTY,
PT_CLASS_PROPERTY_FETCH,
};
/* the class entry -> matching arms memo: direct-mapped, a collision