Add daily email for 2024-08-15
Docblocks or annotations?
This commit is contained in:
parent
7b9ce753f4
commit
5dcb21e533
34
source/_daily_emails/2024-08-15.md
Normal file
34
source/_daily_emails/2024-08-15.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
title: Docblocks or annotations?
|
||||
date: 2024-08-15
|
||||
permalink: daily/2024/08/15/docblocks-or-annotations
|
||||
tags:
|
||||
- software-development
|
||||
- php
|
||||
- automated-testing
|
||||
cta: ~
|
||||
snippet: |
|
||||
Docblocks or annotations. Which do you prefer?
|
||||
---
|
||||
|
||||
As #Drupal 11 uses #PHPUnit 10, we can now use the `#[Test]` attribute instead of the `/** @test */` annotation.
|
||||
|
||||
For example:
|
||||
|
||||
```php
|
||||
// Before.
|
||||
|
||||
/** @test */
|
||||
public function it_returns_the_endpoint()
|
||||
|
||||
// After.
|
||||
|
||||
#[Test]
|
||||
public function it_returns_the_endpoint()
|
||||
```
|
||||
|
||||
[Annotations have started to be replaced][0] in parts of Drupal since 10.2, so it's nice to be able to do it with tests, too.
|
||||
|
||||
Which do you prefer?
|
||||
|
||||
[0]: {{site.url}}/daily/2024/04/04/php-attributes--coming-soon-to-a-drupal-version-near-you
|
Loading…
Reference in a new issue