124 lines
4.2 KiB
YAML
124 lines
4.2 KiB
YAML
uuid:
|
|
- value: 1aa7a4d1-08a8-4cb0-99ba-62e279517b4b
|
|
langcode:
|
|
- value: en
|
|
type:
|
|
- target_id: daily_email
|
|
target_type: node_type
|
|
target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7
|
|
revision_timestamp:
|
|
- value: '2025-05-11T09:00:00+00:00'
|
|
revision_uid:
|
|
- target_type: user
|
|
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
|
|
revision_log: { }
|
|
status:
|
|
- value: true
|
|
uid:
|
|
- target_type: user
|
|
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
|
|
title:
|
|
- value: 'Extra PHPDoc types with PHPStan'
|
|
created:
|
|
- value: '2025-03-21T00:00:00+00:00'
|
|
changed:
|
|
- value: '2025-05-11T09:00:00+00:00'
|
|
promote:
|
|
- value: false
|
|
sticky:
|
|
- value: false
|
|
default_langcode:
|
|
- value: true
|
|
revision_translation_affected:
|
|
- value: true
|
|
path:
|
|
- alias: /daily/2025/03/21/phpdoc
|
|
langcode: en
|
|
body:
|
|
- value: |
|
|
<p>Here are some examples of PHP code from Drupal core:</p>
|
|
|
|
<pre><code class="php">/**
|
|
* The weight of this role in administrative listings.
|
|
*
|
|
* @var int
|
|
*/
|
|
protected $weight;
|
|
</code></pre>
|
|
|
|
<pre><code class="php">/**
|
|
* Path of the image file.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $source = '';
|
|
</code></pre>
|
|
|
|
<pre><code class="php">/**
|
|
* Alter the list of mail backend plugin definitions.
|
|
*
|
|
* @param array $info
|
|
* The mail backend plugin definitions to be altered.
|
|
*/
|
|
</code></pre>
|
|
|
|
<p>These use some of the standard PHPDoc types of <code>int</code>, <code>string</code> and <code>array</code>.</p>
|
|
|
|
<p>Although they are comments, docblocks are checked by static analysis tools like PHPStan to parse the code and report any potential errors.</p>
|
|
|
|
<p>If you want to go deeper, PHPStan has <a href="https://phpstan.org/writing-php-code/phpdoc-types">its own PHPDoc types</a> that you can use to add more information and context.</p>
|
|
|
|
<p>Instead of specifying an argument must be a <code>string</code>, you can specify it's a <code>non-empty-string</code> or a <code>class-string</code>.</p>
|
|
|
|
<p>You can specify whether an integer is a <code>positive-int</code> or <code>negative-int</code>, or within a certain range.</p>
|
|
|
|
<p>You can define the shape of an array or object, whether an array is empty, or the types of keys and values in an array.</p>
|
|
|
|
<p>All of this is used by PHPStan when analysing the code and will give better results and find more potential bugs before anyone else does.</p>
|
|
|
|
|
|
format: full_html
|
|
processed: |
|
|
<p>Here are some examples of PHP code from Drupal core:</p>
|
|
|
|
<pre><code class="php">/**
|
|
* The weight of this role in administrative listings.
|
|
*
|
|
* @var int
|
|
*/
|
|
protected $weight;
|
|
</code></pre>
|
|
|
|
<pre><code class="php">/**
|
|
* Path of the image file.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $source = '';
|
|
</code></pre>
|
|
|
|
<pre><code class="php">/**
|
|
* Alter the list of mail backend plugin definitions.
|
|
*
|
|
* @param array $info
|
|
* The mail backend plugin definitions to be altered.
|
|
*/
|
|
</code></pre>
|
|
|
|
<p>These use some of the standard PHPDoc types of <code>int</code>, <code>string</code> and <code>array</code>.</p>
|
|
|
|
<p>Although they are comments, docblocks are checked by static analysis tools like PHPStan to parse the code and report any potential errors.</p>
|
|
|
|
<p>If you want to go deeper, PHPStan has <a href="https://phpstan.org/writing-php-code/phpdoc-types">its own PHPDoc types</a> that you can use to add more information and context.</p>
|
|
|
|
<p>Instead of specifying an argument must be a <code>string</code>, you can specify it's a <code>non-empty-string</code> or a <code>class-string</code>.</p>
|
|
|
|
<p>You can specify whether an integer is a <code>positive-int</code> or <code>negative-int</code>, or within a certain range.</p>
|
|
|
|
<p>You can define the shape of an array or object, whether an array is empty, or the types of keys and values in an array.</p>
|
|
|
|
<p>All of this is used by PHPStan when analysing the code and will give better results and find more potential bugs before anyone else does.</p>
|
|
|
|
|
|
summary: null
|
|
field_daily_email_cta: { }
|