uuid: - value: dfe4489a-7d64-4368-b86e-e35180377c15 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:06+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: 'The two ways of writing PHP code' created: - value: '2024-09-19T00:00:00+00:00' changed: - value: '2025-05-11T09:00:06+00:00' promote: - value: false sticky: - value: false default_langcode: - value: true revision_translation_affected: - value: true path: - alias: /daily/2024/09/19/the-two-ways-of-writing-php-code langcode: en body: - value: |
Something that came up in my discussion with Dave Liddament for the Beyond Blocks podcast was that there seem to be two ways of writing PHP code.
One is writing strict code by enabling strict typing, using parameter and return types, and leveraging tools like PHPStan at a high level to analyze code.
The other is no not use types and to use a more "duck typing" approach.
The term "visual debt" came from a video discussing the pros and cons of these approaches.
The same can be said for JavaScript and TypeScript, but PHP can do both and gives the Developer the choice of how they write their code.
I prefer writing strict code and for my code to be as explicit as possible, but I appreciate not everyone does and I like that PHP caters for both.
How do you write your PHP code?
format: full_html processed: |Something that came up in my discussion with Dave Liddament for the Beyond Blocks podcast was that there seem to be two ways of writing PHP code.
One is writing strict code by enabling strict typing, using parameter and return types, and leveraging tools like PHPStan at a high level to analyze code.
The other is no not use types and to use a more "duck typing" approach.
The term "visual debt" came from a video discussing the pros and cons of these approaches.
The same can be said for JavaScript and TypeScript, but PHP can do both and gives the Developer the choice of how they write their code.
I prefer writing strict code and for my code to be as explicit as possible, but I appreciate not everyone does and I like that PHP caters for both.
How do you write your PHP code?
summary: null field_daily_email_cta: { }