oliverdavies.uk/content/node.165bf925-8dd9-4e03-9b65-7fa0e64c646d.yml
2025-07-16 23:48:03 +01:00

77 lines
3.2 KiB
YAML

uuid:
- value: 165bf925-8dd9-4e03-9b65-7fa0e64c646d
langcode:
- value: en
type:
- target_id: daily_email
target_type: node_type
target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7
revision_timestamp:
- value: '2025-07-16T22:47:46+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: 'PHP compatibility checking with phpcs'
created:
- value: '2025-07-15T22:45:58+00:00'
changed:
- value: '2025-07-16T22:47:46+00:00'
promote:
- value: false
sticky:
- value: false
default_langcode:
- value: true
revision_translation_affected:
- value: true
path:
- alias: ''
pid: null
langcode: en
body:
- value: |-
PHP 8.5 will be the next version of PHP, scheduled for release this November.
There are new features being added, including the `|>` pipe operator, that I'll look forward to using.
Once it's released, how can you tell if your application code is compatible?
Or, if you're stuck on an older version of PHP, how do you know if you can upgrade?
Running your automated tests is a great first step.
Another check is to use PHP CodeSniffer, aka (`phpcs`).
As well as coding standards, it can also run PHP compatibility checks.
With the [PHP Compatibility Coding Standard][0] installed, running `phpcs -p . --standard=PHPCompatibility` will perform the compatibility check and show any errors.
To specify a version of PHP to test against, add `--runtime-set testVersion 8.5` using the desired version.
If you need to make changes, I recommend [using Rector][1] and have it make the changes automatically.
[0]: https://github.com/PHPCompatibility/PHPCompatibility
[1]: /daily/2025/01/31/rector
format: markdown
processed: |
<p>PHP 8.5 will be the next version of PHP, scheduled for release this November.</p>
<p>There are new features being added, including the <code>|&gt;</code> pipe operator, that I'll look forward to using.</p>
<p>Once it's released, how can you tell if your application code is compatible?</p>
<p>Or, if you're stuck on an older version of PHP, how do you know if you can upgrade?</p>
<p>Running your automated tests is a great first step.</p>
<p>Another check is to use PHP CodeSniffer, aka (<code>phpcs</code>).</p>
<p>As well as coding standards, it can also run PHP compatibility checks.</p>
<p>With the <a href="https://github.com/PHPCompatibility/PHPCompatibility">PHP Compatibility Coding Standard</a> installed, running <code>phpcs -p . --standard=PHPCompatibility</code> will perform the compatibility check and show any errors.</p>
<p>To specify a version of PHP to test against, add <code>--runtime-set testVersion 8.5</code> using the desired version.</p>
<p>If you need to make changes, I recommend <a href="http://localhost:8888/daily/2025/01/31/rector">using Rector</a> and have it make the changes automatically.</p>
summary: ''
field_daily_email_cta:
- target_type: node
target_uuid: 2a6bc8bd-a1e0-4f62-8112-47c3107020c5