Skip to content
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

PHP 8.3 Support: Arbitrary static variable initializers #8085

Merged

Conversation

junichi11
Copy link
Member

Part 1

  • Fix the grammar file (parser)
  • Add unit tests for the parser

Example:

class Example {
    private int $field = 1;

    public function method(): int {
        return 1;
    }

    public function run(int $param1) : void {
        static $example1 = rand();
        static $example2 = $param1;
        static $example3 = $this->field;
        static $example4 = $this->method();
        static $example5 = new class() {};
        static $example6 = new stdClass(...[0]);
        static $example6 = new stdClass($param1);
        static $example7 = new (Test);
        static $example8 = new static;
        static $example9 = $param1 <= 100 ? run($param1 + 1) : "Test $param1";
        static $example10 = rand(), $example11 = rand();
    }
}

$variable = 1;
static $example1 = rand();
static $example2 = $variable;

Part 2

  • Fix the formatter
  • Add unit tests
    • Formatter
    • Code Completion
    • GotoDeclaration and MarkOccurrences

Part 3

  • Fix the PHP83UnhandledError
  • Fix the bracket barance for the ASTPHP5Scanner
  • Add unit tests for the scanner

PHP 8.2

nb-php83-arbitrary-static-variable-initializers_01
nb-php83-arbitrary-static-variable-initializers_02
nb-php83-arbitrary-static-variable-initializers_05
nb-php83-arbitrary-static-variable-initializers_06

PHP 8.3

nb-php83-arbitrary-static-variable-initializers_03
nb-php83-arbitrary-static-variable-initializers_04

- apache#6701
- apache#8073
- https://wiki.php.net/rfc/arbitrary_static_variable_initializers
- Fix the grammar file (parser)
- Add unit tests for the parser

Example:
```php
class Example {
    private int $field = 1;

    public function method(): int {
        return 1;
    }

    public function run(int $param1) : void {
        static $example1 = rand();
        static $example2 = $param1;
        static $example3 = $this->field;
        static $example4 = $this->method();
        static $example5 = new class() {};
        static $example6 = new stdClass(...[0]);
        static $example6 = new stdClass($param1);
        static $example7 = new (Test);
        static $example8 = new static;
        static $example9 = $param1 <= 100 ? run($param1 + 1) : "Test $param1";
        static $example10 = rand(), $example11 = rand();
    }
}

$variable = 1;
static $example1 = rand();
static $example2 = $variable;
```
- apache#6701
- apache#8073
- https://wiki.php.net/rfc/arbitrary_static_variable_initializers
- Fix the formatter
- Add unit tests
  - Formatter
  - Code Completion
  - GotoDeclaration and MarkOccurrences
- apache#6701
- apache#8073
- https://wiki.php.net/rfc/arbitrary_static_variable_initializers
- Fix the `PHP83UnhandledError`
- Fix the bracket barance for the `ASTPHP5Scanner`
- Add unit tests for the scanner
@junichi11 junichi11 added PHP [ci] enable extra PHP tests (php/php.editor) ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Dec 23, 2024
@junichi11 junichi11 added this to the NB25 milestone Dec 23, 2024
@junichi11 junichi11 linked an issue Dec 23, 2024 that may be closed by this pull request
@junichi11 junichi11 requested a review from tmysik December 23, 2024 02:08
Copy link
Member

@tmysik tmysik left a comment

Choose a reason for hiding this comment

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

Thanks for all the tests!

@junichi11 junichi11 merged commit be051eb into apache:master Dec 23, 2024
32 checks passed
@junichi11 junichi11 deleted the php83-arbitrary_static_variable_initializers branch December 23, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) PHP [ci] enable extra PHP tests (php/php.editor)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHP 8.3 Lazy static initialization for non constants
2 participants