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