From 7be26febece16dfea8bb53a05ad488479ffd156d Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 23 Sep 2024 00:20:25 +0100 Subject: [PATCH] Add daily email for 2024-09-19 The two ways of writing PHP code --- source/_daily_emails/2024-09-19.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 source/_daily_emails/2024-09-19.md diff --git a/source/_daily_emails/2024-09-19.md b/source/_daily_emails/2024-09-19.md new file mode 100644 index 00000000..31405569 --- /dev/null +++ b/source/_daily_emails/2024-09-19.md @@ -0,0 +1,27 @@ +--- +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?