28 lines
1 KiB
Markdown
28 lines
1 KiB
Markdown
|
---
|
||
|
title: The two ways of writing PHP code
|
||
|
date: 2024-09-19
|
||
|
permalink: daily/2024/09/19/the-two-ways-of-writing-php-code
|
||
|
tags:
|
||
|
- software-development
|
||
|
- drupal
|
||
|
- php
|
||
|
cta: ~
|
||
|
snippet: |
|
||
|
How do you write your PHP code?
|
||
|
drupal_planet: true
|
||
|
---
|
||
|
|
||
|
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?
|