Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion php/php.api.phpmodule/manifest.mf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Manifest-Version: 1.0
OpenIDE-Module: org.netbeans.modules.php.api.phpmodule
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/api/phpmodule/resources/Bundle.properties
OpenIDE-Module-Specification-Version: 2.105
OpenIDE-Module-Specification-Version: 2.106
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"PhpVersion.PHP_82=PHP 8.2",
"PhpVersion.PHP_83=PHP 8.3",
"PhpVersion.PHP_84=PHP 8.4",
"PhpVersion.PHP_85=PHP 8.5",
})
public enum PhpVersion {

Expand Down Expand Up @@ -115,6 +116,11 @@ public enum PhpVersion {
* @since 2.100
*/
PHP_84(Bundle.PhpVersion_PHP_84()),
/**
* PHP 8.5
* @since 2.106
*/
PHP_85(Bundle.PhpVersion_PHP_85()),
;

private final String displayName;
Expand Down Expand Up @@ -373,6 +379,7 @@ private enum Period {
PHP_82(LocalDate.of(2022, 12, 8), LocalDate.of(2024, 12, 31), LocalDate.of(2026, 12, 31)),
PHP_83(LocalDate.of(2023, 11, 23), LocalDate.of(2025, 12, 31), LocalDate.of(2027, 12, 31)),
PHP_84(LocalDate.of(2024, 11, 21), LocalDate.of(2026, 12, 31), LocalDate.of(2028, 12, 31)),
PHP_85(LocalDate.of(2025, 11, 20), LocalDate.of(2027, 12, 31), LocalDate.of(2029, 12, 31)),
;

private final LocalDate initialRelease;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public final class CodeUtils {
public static final String NEW_LINE = "\n"; // NOI18N
public static final String THIS_VARIABLE = "$this"; // NOI18N
public static final String NS_SEPARATOR = "\\"; // NOI18N
public static final String PIPE_OPERATOR = "|>"; // NOI18N

public static final Pattern WHITE_SPACES_PATTERN = Pattern.compile("\\s+"); // NOI18N
public static final Pattern SPLIT_TYPES_PATTERN = Pattern.compile("[()|&]+"); // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.netbeans.modules.csl.api.OffsetRange;
import org.netbeans.modules.csl.spi.GsfUtilities;
import org.netbeans.modules.php.editor.CodeUtils;
import static org.netbeans.modules.php.editor.CodeUtils.PIPE_OPERATOR;
import org.netbeans.modules.php.editor.indent.FormatToken.AssignmentAnchorToken;
import org.netbeans.modules.php.editor.indent.TokenFormatter.DocumentOptions;
import org.netbeans.modules.php.editor.lexer.LexUtilities;
Expand All @@ -59,6 +60,7 @@
import org.netbeans.modules.php.editor.parser.astnodes.ClassDeclaration;
import org.netbeans.modules.php.editor.parser.astnodes.ClassInstanceCreation;
import org.netbeans.modules.php.editor.parser.astnodes.ClassInstanceCreationVariable;
import org.netbeans.modules.php.editor.parser.astnodes.CompositionExpression;
import org.netbeans.modules.php.editor.parser.astnodes.ConditionalExpression;
import org.netbeans.modules.php.editor.parser.astnodes.ConstantDeclaration;
import org.netbeans.modules.php.editor.parser.astnodes.DeclareStatement;
Expand Down Expand Up @@ -1085,6 +1087,22 @@ private void visitConditionalExpression(ConditionalExpression node, boolean putC
}
}

//PHP 8.5 pipe operator composition expression
@Override
public void visit(CompositionExpression node) {
scan(node.getLeft());
while (ts.moveNext()
&& !(ts.token().id() == PHPTokenId.PHP_OPERATOR && TokenUtilities.textEquals(PIPE_OPERATOR, ts.token().text())) // NOI18N
&& lastIndex < ts.index()) {
addFormatToken(formatTokens);
}

formatTokens.add(new FormatToken(FormatToken.Kind.WHITESPACE_AROUND_KEY_VALUE_OP, ts.offset() + ts.token().length()));
formatTokens.add(new FormatToken(FormatToken.Kind.TEXT, ts.offset(), ts.token().text().toString()));
//todo implement a minimum space arround pipe operator (|>trim())
scan(node.getRight());
}

@Override
public void visit(ConstantDeclaration node) {
if (path.size() > 1 && path.get(1) instanceof Block) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.netbeans.editor.BaseDocument;
import org.netbeans.editor.Utilities;
import org.netbeans.modules.editor.indent.spi.Context;
import static org.netbeans.modules.php.editor.CodeUtils.PIPE_OPERATOR;
import org.netbeans.modules.php.editor.lexer.LexUtilities;
import org.netbeans.modules.php.editor.lexer.PHPTokenId;
import org.openide.util.Exceptions;
Expand Down Expand Up @@ -343,6 +344,13 @@ && isFirstCommaAfterDoubleArrow(startExpression, caretOffset, ts)) {
newIndent = Utilities.getRowIndent(doc, startExpression) + continuationSize;
break;
}
} else if (ts.token().id() == PHPTokenId.PHP_OPERATOR && TokenUtilities.textEquals(PIPE_OPERATOR, ts.token().text())) { // NOI18N
//PHP 8.5 align pipe operator chain expressions
int startExpression = LexUtilities.findStartTokenOfExpression(ts);
if (startExpression != -1) {
newIndent = Utilities.getRowIndent(doc, startExpression);
break;
}
}
}
previousTokenId = ts.token().id();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.netbeans.editor.BaseDocument;
import org.netbeans.editor.Utilities;
import org.netbeans.modules.csl.api.OffsetRange;
import static org.netbeans.modules.php.editor.CodeUtils.PIPE_OPERATOR;
import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataObject;
import org.openide.util.Exceptions;
Expand All @@ -47,7 +48,7 @@
* @author Petr Pisl
*/
public final class LexUtilities {

private LexUtilities() {
}

Expand Down Expand Up @@ -623,6 +624,10 @@ public static int findStartTokenOfExpression(TokenSequence ts) {
}
break;
}
} else if (token.id() == PHPTokenId.PHP_OPERATOR && TokenUtilities.textEquals(token.text(), PIPE_OPERATOR)) { // NOI18N
//PHP 8.5 pipe operator
start = ts.offset();
break;
} else if (balance == 1 && token.id() == PHPTokenId.PHP_STRING) {
// probably there is a function call insede the expression
start = ts.offset();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading