# Add another php syntax for simplify code

- Thread: https://externals.io/message/117607
- Original archive: https://news-web.php.net/php.internals/117607
- Started by chopins xiao on 2022-04-26T04:02:30+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #117607 — chopins xiao — 2022-04-26T04:02:30+00:00

URL: https://externals.io/message/117607#117607

0. when dot object opeator is enable, use small sign and add sign [<+]  be equivalent to [.] for string concat mark.
     compatibility is achieved through configuration switches.
     syntax ：
> > […]
          the concat equal sign[.=] not change

1. use dot mark[.] same with [->]
     syntax:
> > […]

2. colon [:] same with [=>] in array declaration statement
     syntax:
> > […]

3. another class declaration statement,  cant not use [extends] and [implement] keyword
     syntax:
> > […]
          same with
> > […]

         anonymous class
> > […]
         same with
> > […]

5. another class method declaration statement,  omit [function] keyword is allowable
     syntax:   
> > […]
          same with
> > […]

6. restriction public magic method synax sugar, omit [public][function] keywords and duoble underline[__] is allowable, only __get()  __set() __call() __callStatic() __toString()  __sleep()  __wakeup()  __serialize()  __unserialize() is availabled
          syntax:
> > […]
          same with:
> > […]

The implement and syntax see:
 https://github.com/chopins/php-src/blob/fast_grammar/FastSyntax.md


Regards

Chopin Xiao

---

## #117613 — Christoph M. Becker — 2022-04-26T11:36:06+00:00

URL: https://externals.io/message/117607#117613 · In reply to: #117607

> 0. when dot object opeator is enable, use small sign and add sign [<+]  be equivalent to [.] for string concat mark.
>      compatibility is achieved through configuration switches.
>      syntax ：
> > […]
>           the concat equal sign[.=] not change
>
> 1. use dot mark[.] same with [->]
>      syntax:
> > […]
>
> 2. colon [:] same with [=>] in array declaration statement
>      syntax:
> > […]
>
> 3. another class declaration statement,  cant not use [extends] and [implement] keyword
>      syntax:
> > […]
>           same with
> > […]
>
>          anonymous class
> > […]
>          same with
> > […]
>
> 5. another class method declaration statement,  omit [function] keyword is allowable
>      syntax:
> > […]
>           same with
> > […]
>
> 6. restriction public magic method synax sugar, omit [public][function] keywords and duoble underline[__] is allowable, only __get()  __set() __call() __callStatic() __toString()  __sleep()  __wakeup()  __serialize()  __unserialize() is availabled
>           syntax:
> > […]
>           same with:
> > […]
>
> The implement and syntax see:
>  https://github.com/chopins/php-src/blob/fast_grammar/FastSyntax.md

In my opinion, it is generally a bad idea to support different syntax
based on an INI setting.  This easily leads to confusion for those
reading the code.

I don't see much point in these "simplifications" anyway, except maybe
for the shorter array literals.  Note though, that there has been RFC[1]
about a similar syntax, but that had been declined.

[1] <https://wiki.php.net/rfc/bare_name_array_literal>

--
Christoph M. Becker
