Problem/Motivation

PHP now shipping #[Deprecated] native attribute - see RFC

Example

#[\Deprecated("use test() instead", since: "11.0")]
function test4() {
}

Steps to reproduce

# php -v
PHP 8.4.0RC1 (cli) (built: Sep 25 2024 10:17:43) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.0RC1, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.0RC1, Copyright (c), by Zend Technologies

# php --rc Deprecated
Class [ <internal:Core> final class Deprecated ] {

  - Constants [0] {
  }

  - Static properties [0] {
  }

  - Static methods [0] {
  }

  - Properties [2] {
    Property [ public protected(set) readonly ?string $message ]
    Property [ public protected(set) readonly ?string $since ]
  }

  - Methods [1] {
    Method [ <internal:Core, ctor> public method __construct ] {

      - Parameters [2] {
        Parameter #0 [ <optional> ?string $message = null ]
        Parameter #1 [ <optional> ?string $since = null ]
      }
    }
  }
}

Proposed resolution

Discuss it's usage and start use it (or SF polyfill v1.30.0) instead of doc-blocks

Polyfill added to core in #3523284: Update remaining Composer dependencies for 11.2.0

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

andypost created an issue. See original summary.

andypost’s picture

Title: Adopt #[Deprecated] attribute » Adopt #[\Deprecated] attribute
Issue summary: View changes

symfony/polyfill > 1.30.0 is required for PHP 8.4 and the attribute https://github.com/symfony/polyfill/commit/1bd9f75235a0324e599aef3df6deb...

mstrelan’s picture

andypost’s picture

Looks in PHP 8.5 this attribute can be applied to constants if RFC pass https://wiki.php.net/rfc/attributes-on-constants

andypost’s picture

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.