From 06466b6db7d7bc51e468a38aede1b3a70f359dca Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 8 Apr 2024 00:07:21 +0100 Subject: [PATCH] Add daily email for 2024-04-04 PHP attributes: coming soon to a Drupal version near you --- source/_daily_emails/2024-04-04.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 source/_daily_emails/2024-04-04.md diff --git a/source/_daily_emails/2024-04-04.md b/source/_daily_emails/2024-04-04.md new file mode 100644 index 00000000..483d0661 --- /dev/null +++ b/source/_daily_emails/2024-04-04.md @@ -0,0 +1,24 @@ +--- +title: "PHP attributes: coming soon to a Drupal version near you" +date: 2024-04-04 +permalink: archive/2024/04/04/php-attributes--coming-soon-to-a-drupal-version-near-you +tags: + - software-development + - drupal + - php +cta: ~ +snippet: | + Have you used PHP attributes in Drupal yet? They've started to be available for some plugin types since version 10.2. +--- + +Since Drupal 10.2, the framework has started to adopt PHP attributes - a new feature since PHP 8 - as an alternative to annotations when defining plugins, such as blocks and queues. + +From the 10.2 release notes: + +> Drupal core has started adopting PHP attributes, a modern PHP language feature, to provide better developer experience for plugin annotations. Contributed and custom code can begin adopting this improved API for their plugins, and Block and Action plugins can all be converted to the new API. + +It seems that what's been added so far is the first phase of converting the core's plugins, with more to follow in future versions. + +There are also discussions about supporting both attributes and annotations in Drupal 11. + +I love to see Drupal continuing to evolve and adopt new features from the PHP language and Symfony framework (such as autowiring and autoconfiguration), and I'm looking forward to using attributes in my projects.