@@ -1512,14 +1512,6 @@ private function getFramelessFunctionInfosName(): string {
15121512 }
15131513
15141514 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-
15231515 if (!empty ($ this ->framelessFunctionInfos )) {
15241516 if ($ this ->isMethod ()) {
15251517 throw new Exception ('Frameless methods are not supported yet ' );
@@ -1532,6 +1524,10 @@ public function getFunctionEntry(): string {
15321524 }
15331525 }
15341526
1527+ $ isVanillaEntry = $ this ->alias === null && !$ this ->supportsCompileTimeEval && $ this ->exposedDocComment === null && empty ($ this ->framelessFunctionInfos );
1528+ $ argInfoName = $ this ->getArgInfoName ();
1529+ $ flagsByPhpVersions = $ this ->getArginfoFlagsByPhpVersions ();
1530+
15351531 if ($ this ->isMethod ()) {
15361532 $ zendName = '" ' . $ this ->name ->methodName . '" ' ;
15371533 if ($ this ->alias ) {
@@ -1542,69 +1538,60 @@ public function getFunctionEntry(): string {
15421538 } else {
15431539 throw new Error ("Cannot happen " );
15441540 }
1541+ } elseif ($ this ->flags & Modifiers::ABSTRACT ) {
1542+ $ name = "NULL " ;
15451543 } 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 ;
15501545
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" ;
15591553 }
15601554 }
15611555 } else if ($ this ->name instanceof FunctionName) {
15621556 $ functionName = $ this ->name ->getFunctionName ();
15631557 $ declarationName = $ this ->alias ? $ this ->alias ->getNonNamespacedName () : $ this ->name ->getDeclarationName ();
1558+ $ name = "zif_ $ declarationName " ;
15641559
15651560 if ($ this ->name ->getNamespace ()) {
15661561 $ namespace = addslashes ($ this ->name ->getNamespace ());
15671562 $ zendName = "ZEND_NS_NAME( \"$ namespace \", \"$ functionName \") " ;
1568- $ name = "zif_ $ declarationName " ;
15691563 } else {
1570- $ zendName = '" ' . $ functionName . '" ' ;
1571- $ name = "zif_ $ declarationName " ;
1572-
15731564 // Can only use ZEND_FE() if we have no flags for *all* versions
15741565 if ($ isVanillaEntry && $ flagsByPhpVersions ->isEmpty ()) {
1575- $ functionEntryCode = "\tZEND_FE( $ declarationName, $ argInfoName) " ;
1566+ return "\tZEND_FE( $ declarationName, $ argInfoName) \n " ;
15761567 }
1568+ $ zendName = '" ' . $ functionName . '" ' ;
15771569 }
15781570 } else {
15791571 throw new Error ("Cannot happen " );
15801572 }
15811573
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 " ;
15881576
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" ;
15911587
15921588 $ 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
15951592 );
15961593
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" ;
16081595 }
16091596
16101597 return $ code ;
0 commit comments