@@ -1512,14 +1512,6 @@ private function getFramelessFunctionInfosName(): string {
1512
1512
}
1513
1513
1514
1514
public function getFunctionEntry (): string {
1515
- $ code = "" ;
1516
-
1517
- $ php84MinimumCompatibility = $ this ->minimumPhpVersionIdCompatibility === null || $ this ->minimumPhpVersionIdCompatibility >= PHP_84_VERSION_ID ;
1518
- $ isVanillaEntry = $ this ->alias === null && !$ this ->supportsCompileTimeEval && $ this ->exposedDocComment === null && empty ($ this ->framelessFunctionInfos );
1519
- $ argInfoName = $ this ->getArgInfoName ();
1520
- $ flagsByPhpVersions = $ this ->getArginfoFlagsByPhpVersions ();
1521
- $ functionEntryCode = null ;
1522
-
1523
1515
if (!empty ($ this ->framelessFunctionInfos )) {
1524
1516
if ($ this ->isMethod ()) {
1525
1517
throw new Exception ('Frameless methods are not supported yet ' );
@@ -1532,6 +1524,10 @@ public function getFunctionEntry(): string {
1532
1524
}
1533
1525
}
1534
1526
1527
+ $ isVanillaEntry = $ this ->alias === null && !$ this ->supportsCompileTimeEval && $ this ->exposedDocComment === null && empty ($ this ->framelessFunctionInfos );
1528
+ $ argInfoName = $ this ->getArgInfoName ();
1529
+ $ flagsByPhpVersions = $ this ->getArginfoFlagsByPhpVersions ();
1530
+
1535
1531
if ($ this ->isMethod ()) {
1536
1532
$ zendName = '" ' . $ this ->name ->methodName . '" ' ;
1537
1533
if ($ this ->alias ) {
@@ -1542,69 +1538,60 @@ public function getFunctionEntry(): string {
1542
1538
} else {
1543
1539
throw new Error ("Cannot happen " );
1544
1540
}
1541
+ } elseif ($ this ->flags & Modifiers::ABSTRACT ) {
1542
+ $ name = "NULL " ;
1545
1543
} else {
1546
- if ($ this ->flags & Modifiers::ABSTRACT ) {
1547
- $ name = "NULL " ;
1548
- } else {
1549
- $ name = "zim_ " . $ this ->name ->getDeclarationClassName () . "_ " . $ this ->name ->methodName ;
1544
+ $ name = "zim_ " . $ this ->name ->getDeclarationClassName () . "_ " . $ this ->name ->methodName ;
1550
1545
1551
- if ($ isVanillaEntry ) {
1552
- $ template = "\tZEND_ME( " . $ this ->name ->getDeclarationClassName () . ", " . $ this ->name ->methodName . ", $ argInfoName, %s) \n" ;
1553
- $ flagsCode = $ flagsByPhpVersions ->generateVersionDependentFlagCode (
1554
- $ template ,
1555
- $ this ->minimumPhpVersionIdCompatibility
1556
- );
1557
- $ functionEntryCode = rtrim ($ flagsCode );
1558
- }
1546
+ if ($ isVanillaEntry ) {
1547
+ $ template = "\tZEND_ME( " . $ this ->name ->getDeclarationClassName () . ", " . $ this ->name ->methodName . ", $ argInfoName, %s) \n" ;
1548
+ $ flagsCode = $ flagsByPhpVersions ->generateVersionDependentFlagCode (
1549
+ $ template ,
1550
+ $ this ->minimumPhpVersionIdCompatibility
1551
+ );
1552
+ return rtrim ($ flagsCode ) . "\n" ;
1559
1553
}
1560
1554
}
1561
1555
} else if ($ this ->name instanceof FunctionName) {
1562
1556
$ functionName = $ this ->name ->getFunctionName ();
1563
1557
$ declarationName = $ this ->alias ? $ this ->alias ->getNonNamespacedName () : $ this ->name ->getDeclarationName ();
1558
+ $ name = "zif_ $ declarationName " ;
1564
1559
1565
1560
if ($ this ->name ->getNamespace ()) {
1566
1561
$ namespace = addslashes ($ this ->name ->getNamespace ());
1567
1562
$ zendName = "ZEND_NS_NAME( \"$ namespace \", \"$ functionName \") " ;
1568
- $ name = "zif_ $ declarationName " ;
1569
1563
} else {
1570
- $ zendName = '" ' . $ functionName . '" ' ;
1571
- $ name = "zif_ $ declarationName " ;
1572
-
1573
1564
// Can only use ZEND_FE() if we have no flags for *all* versions
1574
1565
if ($ isVanillaEntry && $ flagsByPhpVersions ->isEmpty ()) {
1575
- $ functionEntryCode = "\tZEND_FE( $ declarationName, $ argInfoName) " ;
1566
+ return "\tZEND_FE( $ declarationName, $ argInfoName) \n " ;
1576
1567
}
1568
+ $ zendName = '" ' . $ functionName . '" ' ;
1577
1569
}
1578
1570
} else {
1579
1571
throw new Error ("Cannot happen " );
1580
1572
}
1581
1573
1582
- if ($ functionEntryCode !== null ) {
1583
- $ code .= "$ functionEntryCode \n" ;
1584
- } else {
1585
- if (!$ php84MinimumCompatibility ) {
1586
- $ code .= "#if (PHP_VERSION_ID >= " . PHP_84_VERSION_ID . ") \n" ;
1587
- }
1574
+ $ docComment = $ this ->exposedDocComment ? '" ' . $ this ->exposedDocComment ->escape () . '" ' : "NULL " ;
1575
+ $ framelessFuncInfosName = !empty ($ this ->framelessFunctionInfos ) ? $ this ->getFramelessFunctionInfosName () : "NULL " ;
1588
1576
1589
- $ docComment = $ this ->exposedDocComment ? '" ' . $ this ->exposedDocComment ->escape () . '" ' : "NULL " ;
1590
- $ framelessFuncInfosName = !empty ($ this ->framelessFunctionInfos ) ? $ this ->getFramelessFunctionInfosName () : "NULL " ;
1577
+ // Assume 8.4+ here, if older versions are supported this is conditional
1578
+ $ code = $ flagsByPhpVersions ->generateVersionDependentFlagCode (
1579
+ "\tZEND_RAW_FENTRY( $ zendName, $ name, $ argInfoName, %s, $ framelessFuncInfosName, $ docComment) \n" ,
1580
+ PHP_84_VERSION_ID
1581
+ );
1582
+
1583
+ $ php84MinimumCompatibility = $ this ->minimumPhpVersionIdCompatibility === null || $ this ->minimumPhpVersionIdCompatibility >= PHP_84_VERSION_ID ;
1584
+ if (!$ php84MinimumCompatibility ) {
1585
+ $ code = "#if (PHP_VERSION_ID >= " . PHP_84_VERSION_ID . ") \n$ code " ;
1586
+ $ code .= "#else \n" ;
1591
1587
1592
1588
$ code .= $ flagsByPhpVersions ->generateVersionDependentFlagCode (
1593
- "\tZEND_RAW_FENTRY( $ zendName, $ name, $ argInfoName, %s, $ framelessFuncInfosName, $ docComment) \n" ,
1594
- PHP_84_VERSION_ID
1589
+ "\tZEND_RAW_FENTRY( $ zendName, $ name, $ argInfoName, %s) \n" ,
1590
+ $ this ->minimumPhpVersionIdCompatibility ,
1591
+ PHP_83_VERSION_ID
1595
1592
);
1596
1593
1597
- if (!$ php84MinimumCompatibility ) {
1598
- $ code .= "#else \n" ;
1599
-
1600
- $ code .= $ flagsByPhpVersions ->generateVersionDependentFlagCode (
1601
- "\tZEND_RAW_FENTRY( $ zendName, $ name, $ argInfoName, %s) \n" ,
1602
- $ this ->minimumPhpVersionIdCompatibility ,
1603
- PHP_83_VERSION_ID
1604
- );
1605
-
1606
- $ code .= "#endif \n" ;
1607
- }
1594
+ $ code .= "#endif \n" ;
1608
1595
}
1609
1596
1610
1597
return $ code ;
0 commit comments