Skip to content

Commit e7ae81f

Browse files
committed
Impl PHP8 Attribute as vsemi (statement without semicolon)
refs #625
1 parent 4563b22 commit e7ae81f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

php-mode.el

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ reported, even if `c-report-syntactic-errors' is non-nil."
879879
(funcall 'c-indent-line)))))
880880

881881
(defun php-c-at-vsemi-p (&optional pos)
882-
"Return t on html lines (including php region border), otherwise nil.
882+
"Return T on HTML lines (including php tag) or PHP8 Attribute, otherwise NIL.
883883
POS is a position on the line in question.
884884
885885
This is was done due to the problem reported here:
@@ -892,6 +892,10 @@ This is was done due to the problem reported here:
892892
(setq pos (point)))
893893
(unless (php-in-string-or-comment-p)
894894
(or
895+
;; Detect PHP8 attribute: <<Attribute()>>
896+
(when (and (< 2 pos) (< 2 (- pos (c-point 'bol))))
897+
(backward-char 2)
898+
(looking-at-p ">>\\s-*\\(?:<<\\|$\\)"))
895899
;; Detect HTML/XML tag and PHP tag (<?php, <?=, ?>)
896900
(when php-mode-template-compatibility
897901
(beginning-of-line)

tests/8.0/attribute/function.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
<<ExampleAttribute>>
4+
function f1() { }
5+
6+
<<WithoutArgument>>
7+
<<SingleArgument(0)>>
8+
<<FewArguments('Hello', 'World')>>
9+
function foo() {}
10+
11+
<<WithoutArgument>><<SingleArgument(0)>><<FewArguments('Hello', 'World')>>
12+
function bar() {}

0 commit comments

Comments
 (0)