@@ -361,79 +361,51 @@ public function isMixed(): bool {
361
361
return $ this ->isBuiltin && $ this ->name === 'mixed ' ;
362
362
}
363
363
364
- public function toTypeCode (): string {
365
- assert ($ this ->isBuiltin );
366
- switch ($ this ->name ) {
367
- case "bool " :
368
- return "_IS_BOOL " ;
369
- case "int " :
370
- return "IS_LONG " ;
371
- case "float " :
372
- return "IS_DOUBLE " ;
373
- case "string " :
374
- return "IS_STRING " ;
375
- case "array " :
376
- return "IS_ARRAY " ;
377
- case "object " :
378
- return "IS_OBJECT " ;
379
- case "void " :
380
- return "IS_VOID " ;
381
- case "callable " :
382
- return "IS_CALLABLE " ;
383
- case "mixed " :
384
- return "IS_MIXED " ;
385
- case "static " :
386
- return "IS_STATIC " ;
387
- case "never " :
388
- return "IS_NEVER " ;
389
- case "null " :
390
- return "IS_NULL " ;
391
- case "false " :
392
- return "IS_FALSE " ;
393
- case "true " :
394
- return "IS_TRUE " ;
395
- default :
396
- throw new Exception ("Not implemented: $ this ->name " );
397
- }
398
- }
399
-
400
- public function toTypeMask (): string {
364
+ private function toTypeInfo (): array {
401
365
assert ($ this ->isBuiltin );
402
366
403
367
switch ($ this ->name ) {
404
368
case "null " :
405
- return " MAY_BE_NULL " ;
369
+ return [ " IS_NULL " , " MAY_BE_NULL "] ;
406
370
case "false " :
407
- return " MAY_BE_FALSE " ;
371
+ return [ " IS_FALSE " , " MAY_BE_FALSE "] ;
408
372
case "true " :
409
- return " MAY_BE_TRUE " ;
373
+ return [ " IS_TRUE " , " MAY_BE_TRUE "] ;
410
374
case "bool " :
411
- return " MAY_BE_BOOL " ;
375
+ return [ " _IS_BOOL " , " MAY_BE_BOOL "] ;
412
376
case "int " :
413
- return " MAY_BE_LONG " ;
377
+ return [ " IS_LONG " , " MAY_BE_LONG "] ;
414
378
case "float " :
415
- return " MAY_BE_DOUBLE " ;
379
+ return [ " IS_DOUBLE " , " MAY_BE_DOUBLE "] ;
416
380
case "string " :
417
- return " MAY_BE_STRING " ;
381
+ return [ " IS_STRING " , " MAY_BE_STRING "] ;
418
382
case "array " :
419
- return " MAY_BE_ARRAY " ;
383
+ return [ " IS_ARRAY " , " MAY_BE_ARRAY "] ;
420
384
case "object " :
421
- return " MAY_BE_OBJECT " ;
385
+ return [ " IS_OBJECT " , " MAY_BE_OBJECT "] ;
422
386
case "callable " :
423
- return " MAY_BE_CALLABLE " ;
387
+ return [ " IS_CALLABLE " , " MAY_BE_CALLABLE "] ;
424
388
case "mixed " :
425
- return " MAY_BE_ANY " ;
389
+ return [ " IS_MIXED " , " MAY_BE_ANY "] ;
426
390
case "void " :
427
- return " MAY_BE_VOID " ;
391
+ return [ " IS_VOID " , " MAY_BE_VOID "] ;
428
392
case "static " :
429
- return " MAY_BE_STATIC " ;
393
+ return [ " IS_STATIC " , " MAY_BE_STATIC "] ;
430
394
case "never " :
431
- return " MAY_BE_NEVER " ;
395
+ return [ " IS_NEVER " , " MAY_BE_NEVER "] ;
432
396
default :
433
397
throw new Exception ("Not implemented: $ this ->name " );
434
398
}
435
399
}
436
400
401
+ public function toTypeCode (): string {
402
+ return $ this ->toTypeInfo ()[0 ];
403
+ }
404
+
405
+ public function toTypeMask (): string {
406
+ return $ this ->toTypeInfo ()[1 ];
407
+ }
408
+
437
409
public function toOptimizerTypeMaskForArrayKey (): string {
438
410
assert ($ this ->isBuiltin );
439
411
0 commit comments