Support for PHP 8.5
Description
Support for the latest version of Php 8.5
Use case/motivation
With the recent release of PHP 8.5 https://www.php.net/releases/8.5/en.php I think we can start preparing the support code for the new version.
I want to help with the development, but there are some parts for which I don't know the process.
- Ex: It looks like the parser compiler uses a library
parser.cutterfor which is not clear what is the source code.
I, also, know we would need to see the availability of junichi11 for this feature development.
Related issues
Possible evolution conflicts as there are some pull requests for PHP 8.4 which are in draft mode / work in progress.
https://github.com/apache/netbeans/pull/8227
Are you willing to submit a pull request?
Yes
Troubleshooting
it seems that by default the ant task for java cup loads the libraries from the installed java package Linux (usr/share/java). So it will use CUP v0.11b instead of the referenced classpath of CUP v0.11a. A solution is to move the jar : java-cup-0.11b.jar to temporary location.
parser.cutter is needed to split the generated huge parser class into smaller classes, such as EncodeActionTable1, EncodeActionTable2, and so on.
Somewhere in the mailing list archives, I found a discussion that parser.cutter wasn't donated by Oracle, so it's not in the repository.
But I found it in the old repositories at http://hg.netbeans.org/releases/. It seems that this repository is no longer available. If you need it, I can email it to you.
To generate the parser, java-cup-11a.jar is used, which can be found in /php/libs.javacup/external.
I hope @junichi11 will correct me if anything.
I slightly adjusted build.xml for the parser assembly,
and it looks like this:
<!-- add license and @SuppressWarnings for FindBugs in the generated ASTPHP5Parser & ASTPHP5Symbols files -->
<!-- parsercutter can be found in misc repository -->
<target name="gen-astparser">
<taskdef name="javacup"
classname="java_cup.anttask.CUPTask"
classpath="${nb_all}/php/libs.javacup/external/java-cup-11a.jar" />
<javacup srcfile="${nb_all}/php/php.editor/tools/ASTPHP5Parser.cup"
destdir="${nb_all}/php/php.editor/src"
parser="ASTPHP5Parser"
symbols="ASTPHP5Symbols"
interface="on"/>
<taskdef name="parsercutter"
classname="org.netbeans.modules.php.editor.cup.parser.cutter.ParserCutter"
classpath="/home/troizet/dev/parser.cutter/dist/parser.cutter.jar" />
<parsercutter parserpath="${nb_all}/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Parser.java" />
<replaceregexp match="[ \t]+$" replace="" byline="true" >
<fileset dir="${nb_all}/php/php.editor/src/org/netbeans/modules/php/editor/parser">
<include name="ASTPHP5Parser.java"/>
<include name="EncodedActionTable*.java"/>
</fileset>
</replaceregexp>
<replace file="src/org/netbeans/modules/php/editor/parser/ASTPHP5Parser.java">
<replacetoken>public class ASTPHP5Parser extends java_cup.runtime.lr_parser {</replacetoken>
<replacevalue><![CDATA[@org.netbeans.api.annotations.common.SuppressWarnings({"EI_EXPOSE_REP", "MS_PKGPROTECT", "BC_BAD_CAST_TO_CONCRETE_COLLECTION"})
public class ASTPHP5Parser extends java_cup.runtime.lr_parser {]]></replacevalue>
</replace>
<replace>
<fileset dir="src/org/netbeans/modules/php/editor/parser">
<include name="ASTPHP5Parser.java"/>
<include name="ASTPHP5Symbols.java"/>
</fileset>
<replacetoken>
//----------------------------------------------------
// The following code was generated by CUP v0.11a beta 20060608
</replacetoken>
<replacevalue>/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
//----------------------------------------------------
// The following code was generated by CUP v0.11a beta 20060608
</replacevalue>
</replace>
</target>
Thanks @troizet .
Yes, you can mail me if you can the jar for the parser.cutter at haidubogdan@gmail .
I found the issue with the parser on my machine. By default the ant task used the cup library 11b version from /usr/share/java ... so generated file was completely different. So, I'm able to generate the parser.
Hi @troizet , @junichi11 I want just to inform you that I started to work on the pipe operator support for Php 8.5 . https://github.com/apache/netbeans/compare/master...haidubogdan:netbeans:t_php85
I thought of naming the callable expression node as CompositionExpression based on this rfc : https://wiki.php.net/rfc/function-composition. But it's something to be discussed, I'm not that good at naming conventions :) .
I hope that by the start of the next year I will be able to prepare a valid pull request. The main remaining things to work on are : formatting, adapting the unit tests and create new unit tests.