Skip to content

Annotations-related syntax errors in the minified WordPress build #985

@adamziel

Description

@adamziel

Loading WordPress on PHP 7.4 yields the following error:

Parse error: syntax error, unexpected 'has' (T_STRING) in /wordpress/wp-includes/class-wp-recovery-mode-email-service.php on line 4

This is caused by the minification of PHP files via php -w.

PHP 8.0, which is currently used, outputs:

<?php
 #[AllowDynamicProperties] final class WP_Recovery_Mode_Email_Service {  /* ... code ... */ $message = __( 'Howdy!', '

WordPress has a built-in feature ...

The class declaration is treated as a comment by PHP 7.4.

However, PHP 7.4 outputs:

<?php
final class WP_Recovery_Mode_Email_Service {  /* ... code ... */ $message = __( 'Howdy!', '

WordPress has a built-in feature ...

Note the missing annotation.

Proposed solution

I have two ideas:

  1. Postprocess the minified files and insert newline after each annotation
  2. Produce two separate minified WordPress builds for PHP >= 8.0 and PHP < 8.0

I'll explore the first one

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions