Skip to content

Support php 8.1 readonly property modifier RFC #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 16, 2021

Conversation

TysonAndre
Copy link
Contributor

@TysonAndre TysonAndre force-pushed the readonly-properties branch 2 times, most recently from 19ccec9 to 64be11a Compare July 10, 2021 01:29
[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was all of this supposed to change?

Copy link
Contributor Author

@TysonAndre TysonAndre Jul 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the new expected result. Previously, a lot of syntax errors resulted from the additional modifier when only a single modifier was allowed

<?php
class X {
    // Starting in php 8.1, it is a compile error rather than a syntax error to have more than one visibility modifier
    public function __construct(
        public protected $var
    ) {}
}
» php --version
PHP 8.1.0-dev (cli) (built: Jul 11 2021 12:15:15) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.0-dev, Copyright (c), by Zend Technologies
» php tests/cases/parser/parameterPromotion2.php 
Fatal error: Multiple access type modifiers are not allowed in /mnt/DATA/ifwe_programming/tolerant-php-parser/tests/cases/parser/parameterPromotion2.php on line 5

Supports https://wiki.php.net/rfc/first_class_callable_syntax

It is possible that partial function application may allow mixing `...`
with other arguments in the future, if that passes.
See https://wiki.php.net/rfc/first_class_callable_syntax#syntax_choice

So modify the argument instead of replacing the entire argument list with the
token `...`
@TysonAndre TysonAndre force-pushed the readonly-properties branch from 64be11a to 190ebc0 Compare July 16, 2021 20:49
@TysonAndre TysonAndre force-pushed the readonly-properties branch from 414ae57 to 78a7744 Compare July 16, 2021 21:06
@roblourens roblourens merged commit 6a96561 into microsoft:main Jul 16, 2021
@TysonAndre TysonAndre deleted the readonly-properties branch August 19, 2022 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants