<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Oliver Davies</title>
    <description>The latest articles on DEV Community by Oliver Davies (@opdavies).</description>
    <link>https://dev.to/opdavies</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F48043%2F756d4e6d-b157-4f70-a9c8-49d0cc408f05.jpg</url>
      <title>DEV Community: Oliver Davies</title>
      <link>https://dev.to/opdavies</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/opdavies"/>
    <language>en</language>
    <item>
      <title>Experimenting with web components</title>
      <dc:creator>Oliver Davies</dc:creator>
      <pubDate>Thu, 29 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/opdavies/experimenting-with-web-components-425c</link>
      <guid>https://dev.to/opdavies/experimenting-with-web-components-425c</guid>
      <description>&lt;p&gt;After my Beyond Blocks episode with Mark Conroy, I've spent some time this week experimenting with web components.&lt;/p&gt;

&lt;p&gt;The team and I are building a new design system in Fractal and, as Drupal is our main application, we're using Twig as our templating language within Fractal so the changes are easier to port between systems.&lt;/p&gt;

&lt;p&gt;Web components are agnostic, so they work within different languages and frameworks.&lt;/p&gt;

&lt;p&gt;We also use other technologies, such as Vue.js, and third-party suppliers, so having an agnostic web component would reduce the time and effort needed to implement the design system across different technologies and applications.&lt;/p&gt;

&lt;p&gt;If we can make self-contained web components that include their own styling and behaviour, that also improves re-usability and reduces the maintenance overhead as there would be one canonical version for everyone to use - not just a reference implementation everyone would need to recreate.&lt;/p&gt;

&lt;p&gt;After this spike, I'm intrigued to see how we could use web components and what potential issues we can solve with them whilst reducing our implementation and maintenance efforts.&lt;/p&gt;

&lt;p&gt;Are you interested in web components, too? &lt;a href="https://www.oliverdavies.uk/podcast/11-mark-conroy"&gt;Listen to the podcast episode with Mark Conroy&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;P.S. Do you need immediate access to an expert Drupal Developer? With my &lt;a href="https://www.oliverdavies.uk/subscription"&gt;Drupal development subscription&lt;/a&gt;, make unlimited requests for a fixed monthly price in less time than posting to a job board!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why I don't branch</title>
      <dc:creator>Oliver Davies</dc:creator>
      <pubDate>Wed, 28 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/opdavies/why-i-dont-branch-5bgn</link>
      <guid>https://dev.to/opdavies/why-i-dont-branch-5bgn</guid>
      <description>&lt;p&gt;A few days ago, I asked &lt;a href="https://www.oliverdavies.uk/archive/2024/02/25/why-do-people-still-use-git-flow"&gt;why people are still using Git Flow in 2024&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I moved to trunk-based development two years ago and haven't looked back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why did I do that?
&lt;/h2&gt;

&lt;p&gt;Only having a single branch instead of separate &lt;code&gt;main&lt;/code&gt; and &lt;code&gt;develop&lt;/code&gt; branches and branches for each feature and fix is much simpler.&lt;/p&gt;

&lt;p&gt;I don't get merge conflicts when trying to merge branches together, as everything is on a single branch.&lt;/p&gt;

&lt;p&gt;A couple of years ago, I was working on two features for a project. I was demoing them to a client and broke my local environment when switching branches from feature A to feature B.&lt;/p&gt;

&lt;p&gt;It was embarrassing, and it took me time to resolve the issues before I could continue working.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here's the thing
&lt;/h2&gt;

&lt;p&gt;Working mostly on a single branch avoids merge conflicts, saves time, and simplifies my workflow.&lt;/p&gt;

&lt;p&gt;No more confusion, merge conflicts or broken demos.&lt;/p&gt;

&lt;p&gt;P.S. There's less than a year until Drupal 7's end-of-life date. &lt;a href="https://www.oliverdavies.uk/drupal-upgrade"&gt;Plan your upgrade to Drupal 10 now!&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building a design system in a few hours with Symfony</title>
      <dc:creator>Oliver Davies</dc:creator>
      <pubDate>Tue, 27 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/opdavies/building-a-design-system-in-a-few-hours-with-symfony-2db9</link>
      <guid>https://dev.to/opdavies/building-a-design-system-in-a-few-hours-with-symfony-2db9</guid>
      <description>&lt;p&gt;&lt;a href="https://www.oliverdavies.uk/podcast/11-mark-conroy"&gt;I recently spoke with Mark Conroy&lt;/a&gt;, Director of Development at Annertech, on the Beyond Blocks podcast. We discussed building something useful in a day and building design systems with web components.&lt;/p&gt;

&lt;p&gt;Inspired by that conversation, I spent this afternoon experimenting with web components and seeing how I could use them within a design system we're building, as I think they can solve a particular need we have.&lt;/p&gt;

&lt;p&gt;Following that, I thought I'd see how I could build my own design system and decided to do it with Symfony and see what I could achieve within a few hours.&lt;/p&gt;

&lt;p&gt;It was a great opportunity to take Symfony 7 for a spin and explore and test some things that &lt;a href="https://www.oliverdavies.uk/podcast/10-ryan-weaver-symfonycasts"&gt;Ryan Weaver and I discussed in our episode&lt;/a&gt;, such as Symfony UX and Twig components.&lt;/p&gt;

&lt;p&gt;Each component is a Twig component with its own PHP class and Twig template, which is rendered when I visit its URL, and I can use the HTML-like &lt;code&gt;&amp;lt;twig:Logo /&amp;gt;&lt;/code&gt; syntax to include child components.&lt;/p&gt;

&lt;p&gt;You can &lt;a href="https://github.com/opdavies/symfony-design-system"&gt;view the code on GitHub&lt;/a&gt;, and it may be something I use and work on in the future.&lt;/p&gt;

&lt;p&gt;P.S. There's less than a year until Drupal 7's end-of-life date. &lt;a href="https://www.oliverdavies.uk/drupal-upgrade"&gt;Plan your upgrade to Drupal 10 now!&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Docker and content creation with Nick Janetakis</title>
      <dc:creator>Oliver Davies</dc:creator>
      <pubDate>Mon, 26 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/opdavies/docker-and-content-creation-with-nick-janetakis-b38</link>
      <guid>https://dev.to/opdavies/docker-and-content-creation-with-nick-janetakis-b38</guid>
      <description>&lt;p&gt;This week's guest on the Beyond Blocks podcast is Nick Janetakis - a Software Developer, Docker Captain and Teacher who focuses on building and deploying web apps.&lt;/p&gt;

&lt;p&gt;I'm a long-time consumer of Nick's content via his blog, YouTube channel and courses, so it was great to discuss Docker, content creation and more with him.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.oliverdavies.uk/podcast/12-nick-janetakis-docker"&gt;Listen to the episode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;P.S. Are you still using Drupal 7 and don’t know what’s involved to upgrade to Drupal 10? &lt;a href="https://www.oliverdavies.uk/call"&gt;Book a Drupal 7 upgrade consultation call&lt;/a&gt; or &lt;a href="https://www.oliverdavies.uk/drupal-upgrade"&gt;an upgrade roadmap&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why do people still use Git Flow?</title>
      <dc:creator>Oliver Davies</dc:creator>
      <pubDate>Sun, 25 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/opdavies/why-do-people-still-use-git-flow-4h36</link>
      <guid>https://dev.to/opdavies/why-do-people-still-use-git-flow-4h36</guid>
      <description>&lt;p&gt;&lt;a href="https://www.oliverdavies.uk/talks/git-flow"&gt;The first conference talk I gave&lt;/a&gt; was at DrupalCamp London 2014.&lt;/p&gt;

&lt;p&gt;The talk was about Git Flow - a popular branching scheme I was using to manage a project, where there are different branches for development and production versions of the software and separate branches for features, releases and hotfixes.&lt;/p&gt;

&lt;p&gt;It's been a standard approach as I've worked on different projects and teams, usually with pull or merge requests and code reviews.&lt;/p&gt;

&lt;p&gt;But why do people still use it?&lt;/p&gt;

&lt;p&gt;I was conducting technical interviews recently and every candidate explained how they used Git Flow or something inspired by it, and GitHub and GitLab have their own simplified versions.&lt;/p&gt;

&lt;p&gt;Vincent Driessen wrote the original Git Flow blog post in January 2010, though he updated it in March 2020 to add this note of reflection:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This model was conceived in 2010, now more than 10 years ago, and not very long after Git itself came into being. In those 10 years, git-flow (the branching model laid out in this article) has become hugely popular in many a software team to the point where people have started treating it like a standard of sorts — but unfortunately also as a dogma or panacea.&lt;/p&gt;

&lt;p&gt;During those 10 years, Git itself has taken the world by a storm, and the most popular type of software that is being developed with Git is shifting more towards web apps — at least in my filter bubble. Web apps are typically continuously delivered, not rolled back, and you don't have to support multiple versions of the software running in the wild.&lt;/p&gt;

&lt;p&gt;This is not the class of software that I had in mind when I wrote the blog post 10 years ago. If your team is doing continuous delivery of software, I would suggest to adopt a much simpler workflow (like GitHub flow) instead of trying to shoehorn git-flow into your team.&lt;/p&gt;

&lt;p&gt;If, however, you are building software that is explicitly versioned, or if you need to support multiple versions of your software in the wild, then git-flow may still be as good of a fit to your team as it has been to people in the last 10 years. In that case, please read on.&lt;/p&gt;

&lt;p&gt;To conclude, always remember that panaceas don't exist. Consider your own context. Don't be hating. Decide for yourself.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since adopting trunk-based development and continuous integration and delivery, I've worked faster and avoided merge conflicts, which wasn't the case before, even when I was the only one working on a codebase.&lt;/p&gt;

&lt;p&gt;It's a simpler workflow.&lt;/p&gt;

&lt;p&gt;I don't need to think about whether this branch is a feature or a hotfix, and I've rarely seen release and hotfix branches used as described in the original blog post.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here's the thing
&lt;/h2&gt;

&lt;p&gt;Do what works best for you and your team, but don't adopt something because it's the "standard" approach.&lt;/p&gt;

&lt;p&gt;P.S. There's less than a year until Drupal 7's end-of-life date. &lt;a href="https://www.oliverdavies.uk/drupal-upgrade"&gt;Plan your upgrade to Drupal 10 now!&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>When should you start writing tests?</title>
      <dc:creator>Oliver Davies</dc:creator>
      <pubDate>Sat, 24 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/opdavies/when-should-you-start-writing-tests-44l1</link>
      <guid>https://dev.to/opdavies/when-should-you-start-writing-tests-44l1</guid>
      <description>&lt;p&gt;When you start a new project, when should you start writing tests and doing test-driven development?&lt;/p&gt;

&lt;p&gt;Is it before you write any code, or is it something you can start later?&lt;/p&gt;

&lt;p&gt;When starting &lt;a href="https://www.oliverdavies.uk/archive/2024/02/19/introducing-versa"&gt;versa&lt;/a&gt;, I was only scaffolding the console commands and running some basic commands such as "composer install" and "phpunit".&lt;/p&gt;

&lt;p&gt;At that point, there wasn't any business logic to test.&lt;/p&gt;

&lt;p&gt;The first versions only supported PHP, so there was no complexity around which language the project used.&lt;/p&gt;

&lt;p&gt;There was no logic to determine which language or package manager was used.&lt;/p&gt;

&lt;p&gt;Now I've started to add this functionality - such as determining the project type from its composer.json or package.json file - there is logic to test, and I've started to write tests and do test-driven development.&lt;/p&gt;

&lt;p&gt;At this phase, I can see the value, which I couldn't when setting up the application to begin with, and different have any logic worth testing.&lt;/p&gt;

&lt;p&gt;P.S. Do you need immediate access to an expert Drupal Developer? With my &lt;a href="https://www.oliverdavies.uk/subscription"&gt;Drupal development subscription&lt;/a&gt;, make unlimited requests for a fixed monthly price in less time than posting to a job board!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Slow down to go fast</title>
      <dc:creator>Oliver Davies</dc:creator>
      <pubDate>Fri, 23 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/opdavies/slow-down-to-go-fast-5ckm</link>
      <guid>https://dev.to/opdavies/slow-down-to-go-fast-5ckm</guid>
      <description>&lt;p&gt;I've recently been improving my typing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eopHuKaS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://oliverdavies-uk.s3.eu-west-2.amazonaws.com/assets/images/daily-emails/typing.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eopHuKaS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://oliverdavies-uk.s3.eu-west-2.amazonaws.com/assets/images/daily-emails/typing.png" alt="A screenshot of a typing test." width="783" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My speed is usually good, but my accuracy is not where I'd like it to be (it's usually around 95%, and I'd like it to be nearer 99%).&lt;/p&gt;

&lt;p&gt;It may seem counterintuitive, but I need to slow down to get faster.&lt;/p&gt;

&lt;p&gt;But not focusing on the speed and prioritising accuracy, I'll still get faster as I'm not mistyping as many keys.&lt;/p&gt;

&lt;p&gt;It's the same when I run.&lt;/p&gt;

&lt;p&gt;My first few kilometres are slower as I get into the run, find my pace, focus on breathing, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here's the thing
&lt;/h2&gt;

&lt;p&gt;The same can also be said for automation and automated testing.&lt;/p&gt;

&lt;p&gt;They require some time investment initially but will save time as a project evolves and becomes more complex.&lt;/p&gt;

&lt;p&gt;You need to slow down initially to go faster later.&lt;/p&gt;

&lt;p&gt;P.S. Do you need immediate access to an expert Drupal Developer? With my &lt;a href="https://www.oliverdavies.uk/subscription"&gt;Drupal development subscription&lt;/a&gt;, make unlimited requests for a fixed monthly price in less time than posting to a job board!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Diffy and visual regression testing</title>
      <dc:creator>Oliver Davies</dc:creator>
      <pubDate>Thu, 22 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/opdavies/diffy-and-visual-regression-testing-73p</link>
      <guid>https://dev.to/opdavies/diffy-and-visual-regression-testing-73p</guid>
      <description>&lt;p&gt;I recently recorded an episode of &lt;a href="https://www.oliverdavies.uk/podcast"&gt;Beyond Blocks&lt;/a&gt; with Yuri Gerasymov, who runs Diffy.&lt;/p&gt;

&lt;p&gt;He and I discussed visual regression testing, why you'd use it, and some features Diffy offers.&lt;/p&gt;

&lt;p&gt;I usually write a combination of browser, kernel and unit tests within an application framework like Drupal and Symfony or behavioural tests with Behat.&lt;/p&gt;

&lt;p&gt;These validate that my logic works as expected and that functions return the correct results or pages return the correct response codes and content.&lt;/p&gt;

&lt;p&gt;There are types of issues, though, such as breakages within the page layout or structure, which these tests won't discover but can be identified by visual regression tests that compare before and after screenshots.&lt;/p&gt;

&lt;p&gt;I added to my website during the recording and can see what value it offers as an additional layer of testing on top of the tests I already write.&lt;/p&gt;

&lt;p&gt;P.S. Do you need immediate access to an expert Drupal Developer? With my &lt;a href="https://www.oliverdavies.uk/subscription"&gt;Drupal development subscription&lt;/a&gt;, make unlimited requests for a fixed monthly price in less time than posting to a job board!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Coding defensively and considering the unhappy path</title>
      <dc:creator>Oliver Davies</dc:creator>
      <pubDate>Wed, 21 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/opdavies/coding-defensively-and-considering-the-unhappy-path-1ie3</link>
      <guid>https://dev.to/opdavies/coding-defensively-and-considering-the-unhappy-path-1ie3</guid>
      <description>&lt;p&gt;Last week, whilst speaking about Sculpin at PHP South West, I showed an example from a client project I'd built with Sculpin.&lt;/p&gt;

&lt;p&gt;The project was for a local gym and fitness centre, and I was demonstrating how I'd created the timetable page and kept the data separate from the HTML and Twig markup so the client could easily administer it (they edit the files on GitHub, which triggers a rebuild of the website).&lt;/p&gt;

&lt;p&gt;Each class should have a name and start and end times and be on a specified day.&lt;/p&gt;

&lt;p&gt;But what if the client didn't include a name or start or end time?&lt;/p&gt;

&lt;p&gt;What if they put a number or boolean instead of a string?&lt;/p&gt;

&lt;p&gt;What if there are no classes on a particular day?&lt;/p&gt;

&lt;p&gt;You don't know how people will use your software, so it's best to be defensive - validate and verify things before rendering them and prevent the page or whole application from breaking if something isn't as you expected or assumed.&lt;/p&gt;

&lt;p&gt;We also can't assume the "happy path" will always be correct.&lt;/p&gt;

&lt;p&gt;What if there aren't any classes? Do we put an empty message on the timetable or not show that day?&lt;/p&gt;

&lt;h2&gt;
  
  
  Another scenario
&lt;/h2&gt;

&lt;p&gt;If you were retrieving or posting data to an API endpoint, would you assume it was successful or verify the response code is what you expected?&lt;/p&gt;

&lt;p&gt;If you get the data, do you check if it's in the correct format and something you can use?&lt;/p&gt;

&lt;p&gt;If not, do you verify other actions in your application haven't run and it's not in an invalid state?&lt;/p&gt;

&lt;h2&gt;
  
  
  Here's the thing
&lt;/h2&gt;

&lt;p&gt;In PHP, a common approach is to use the &lt;code&gt;assert()&lt;/code&gt; function, as we saw in &lt;a href="https://www.oliverdavies.uk/archive/2024/02/20/which-level-is-right-for-you"&gt;yesterday's email&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Then, write automated tests that don't test just the happy path but also the unhappy paths.&lt;/p&gt;

&lt;p&gt;P.S. There's less than a year until Drupal 7's end-of-life date. &lt;a href="https://www.oliverdavies.uk/drupal-upgrade"&gt;Plan your upgrade to Drupal 10 now!&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Which level is right for you?</title>
      <dc:creator>Oliver Davies</dc:creator>
      <pubDate>Tue, 20 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/opdavies/which-level-is-right-for-you-3al9</link>
      <guid>https://dev.to/opdavies/which-level-is-right-for-you-3al9</guid>
      <description>&lt;p&gt;Today, whilst working on &lt;a href="https://www.oliverdavies.uk/archive/2024/02/19/introducing-versa"&gt;Versa&lt;/a&gt;, I was experimenting with different PHPStan levels.&lt;/p&gt;

&lt;p&gt;Level 1 is the least strict level, and applies the fewest rules and returns the fewest results.&lt;/p&gt;

&lt;p&gt;As you increase the level, the stricter PHPStan is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Levelling up to 9
&lt;/h2&gt;

&lt;p&gt;Here is the code to get the values of the &lt;code&gt;--extra-args&lt;/code&gt; and &lt;code&gt;--working-dir&lt;/code&gt; options:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$extraArgs = $input-&amp;gt;getOption('extra-args');
$workingDir = $input-&amp;gt;getOption('working-dir');

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This passed PHPStan level 8, but these are the errors I get when running level 9:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;------ -------------------------------------------------------------------------------------------------------
 Line versa
------ -------------------------------------------------------------------------------------------------------
 61 Parameter $extraArgs of static method App\Process\Process::create() expects string|null, mixed given.
 62 Parameter $workingDir of static method App\Process\Process::create() expects string, mixed given.
 72 Parameter $extraArgs of static method App\Process\Process::create() expects string|null, mixed given.
 73 Parameter $workingDir of static method App\Process\Process::create() expects string, mixed given.
 84 Parameter $extraArgs of static method App\Process\Process::create() expects string|null, mixed given.
 85 Parameter $workingDir of static method App\Process\Process::create() expects string, mixed given.
 94 Parameter $extraArgs of static method App\Process\Process::create() expects string|null, mixed given.
 95 Parameter $workingDir of static method App\Process\Process::create() expects string, mixed given.
 104 Parameter $extraArgs of static method App\Process\Process::create() expects string|null, mixed given.
 105 Parameter $workingDir of static method App\Process\Process::create() expects string, mixed given.
 119 Parameter $extraArgs of static method App\Process\Process::create() expects string|null, mixed given.
 120 Parameter $workingDir of static method App\Process\Process::create() expects string, mixed given.
------ -------------------------------------------------------------------------------------------------------

[ERROR] Found 12 errors

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The issue is that &lt;code&gt;$input-&amp;gt;getOption()&lt;/code&gt; from Symfony's &lt;code&gt;InputInterface&lt;/code&gt; returns &lt;code&gt;mixed&lt;/code&gt; - even though it always returns &lt;code&gt;null&lt;/code&gt; or a string.&lt;/p&gt;

&lt;p&gt;If I did &lt;code&gt;--working-dir 2&lt;/code&gt;, it would return the string &lt;code&gt;"2"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;An empty string throws an error, and an empty value (if there are no extra arguments) returns &lt;code&gt;null&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So, I know &lt;code&gt;$workingDir&lt;/code&gt; will always be a string and &lt;code&gt;$extraArgs&lt;/code&gt; will either a string or &lt;code&gt;null&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Passing level 8
&lt;/h2&gt;

&lt;p&gt;To pass level 8, PHPStan needs to be sure the variables are what I think they are.&lt;/p&gt;

&lt;p&gt;Here's the code I can use to get it to pass:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$extraArgs = $input-&amp;gt;getOption('extra-args');
$workingDir = $input-&amp;gt;getOption('working-dir');
assert(is_string($extraArgs) || is_null($extraArgs));
assert(is_string($workingDir));

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By using &lt;code&gt;assert()&lt;/code&gt; and throwing an Exception if the condition fails, PHPStan is now happy with the code and my code passes level 9.&lt;/p&gt;

&lt;h2&gt;
  
  
  Here's the thing
&lt;/h2&gt;

&lt;p&gt;Although the extra code gets PHPStan to pass, it it worth it?&lt;/p&gt;

&lt;p&gt;Is this extra code adding value? Does it make the code more readable or is it likely to prevent a bug?&lt;/p&gt;

&lt;p&gt;In this case, I know the value will always be the type I expect.&lt;/p&gt;

&lt;p&gt;I can work around this using a baseline or annotations for PHPStan to ignore these lines, &lt;strong&gt;or is level 8 good enough for this project&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;Similar to 100% test coverage, is aiming for the highest PHPStan level an objective to be met, or is enough value being added added by the lower level?&lt;/p&gt;

&lt;p&gt;Which level is right for you and this codebase?&lt;/p&gt;

&lt;p&gt;P.S. Need help or want another pair of eyes on your code? Book a &lt;a href="https://www.oliverdavies.uk/call"&gt;1-on-1 consulting call&lt;/a&gt; or an &lt;a href="https://www.oliverdavies.uk/pair"&gt;online pair programming session&lt;/a&gt; with a 100% money-back guarantee.&lt;/p&gt;

</description>
      <category>php</category>
      <category>phpstan</category>
    </item>
    <item>
      <title>Introducing Versa - the versatile CLI tool</title>
      <dc:creator>Oliver Davies</dc:creator>
      <pubDate>Mon, 19 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/opdavies/introducing-versa-the-versatile-cli-tool-gl9</link>
      <guid>https://dev.to/opdavies/introducing-versa-the-versatile-cli-tool-gl9</guid>
      <description>&lt;p&gt;Today, I started to build a new open-source project - Versa, the versatile command-line tool that standardises common commands across projects.&lt;/p&gt;

&lt;p&gt;After watching a Twitch streamer building something similar in Rust, I decided to build my take on it and add features I'd need, such as support for local vs Docker-based commands and to run different commands for different projects.&lt;/p&gt;

&lt;p&gt;For example, &lt;code&gt;versa run&lt;/code&gt; would need to run different commands for Drupal and Sculpin projects, &lt;code&gt;versa test&lt;/code&gt; should support different test frameworks for the same language - e.g. PHPUnit, Pest and ParaTest for PHP - and the commands will need to be different in Docker Compose-based projects.&lt;/p&gt;

&lt;p&gt;Currently, this logic is within my &lt;a href="https://www.oliverdavies.uk/build-configs"&gt;Build Configs&lt;/a&gt; project but can be moved to Versa.&lt;/p&gt;

&lt;p&gt;This reduces the complexity within that codebase and means I can open-source it as it's a separate project.&lt;/p&gt;

&lt;p&gt;At the moment, I've added PHP as the only supported language but I will add JavaScript/TypeScript support so it supports projects like Fractal.&lt;/p&gt;

&lt;p&gt;It's still in the prototype phase and includes some initial commands, but the interesting parts will be making it clever.&lt;/p&gt;

&lt;p&gt;Instead of running &lt;code&gt;versa run --type sculpin&lt;/code&gt;, I'd like to just do &lt;code&gt;versa run&lt;/code&gt; and have it determine the type of project automatically.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;versa test&lt;/code&gt; should be able to determine the testing framework automatically based on what's in the project's &lt;code&gt;composer.json&lt;/code&gt; file instead of having to specify it.&lt;/p&gt;

&lt;p&gt;Likewise, for JavaScript, &lt;code&gt;versa install&lt;/code&gt; should be able to determine if &lt;code&gt;npm&lt;/code&gt;, &lt;code&gt;yarn&lt;/code&gt; or &lt;code&gt;pnpm&lt;/code&gt; is used.&lt;/p&gt;

&lt;p&gt;That'll be where the more complex code will be added and when I start doing test-driven development - maybe with Behat, which is also something I've been thinking about for Build Configs.&lt;/p&gt;

&lt;p&gt;Interested? &lt;a href="https://github.com/opdavies/versa"&gt;Take a look at the code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;P.S. Are you still using Drupal 7 and don’t know what’s involved to upgrade to Drupal 10? &lt;a href="https://www.oliverdavies.uk/call"&gt;Book a Drupal 7 upgrade consultation call&lt;/a&gt; or &lt;a href="https://www.oliverdavies.uk/drupal-upgrade"&gt;an upgrade roadmap&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>php</category>
      <category>symfony</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Build something useful in one day with Mark Conroy</title>
      <dc:creator>Oliver Davies</dc:creator>
      <pubDate>Sun, 18 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/opdavies/build-something-useful-in-one-day-with-mark-conroy-58g1</link>
      <guid>https://dev.to/opdavies/build-something-useful-in-one-day-with-mark-conroy-58g1</guid>
      <description>&lt;p&gt;This week on the Beyond Blocks podcast, I'm joined by Mark Conroy - Director of Development at Annertech to discuss all things front-end development and building something useful in one day.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.oliverdavies.uk/podcast/11-mark-conroy"&gt;Listen now&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Talking points
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Building better websites faster, including Drupal distributions, such as LocalGov.&lt;/li&gt;
&lt;li&gt;What Drupal gives you out of the box and using the right tool for the job.&lt;/li&gt;
&lt;li&gt;Drupal migrations and migrating Drupal configuration from a spreadsheet.&lt;/li&gt;
&lt;li&gt;Saving time and improving efficiency by standardising base builds with Docksal and Composer.&lt;/li&gt;
&lt;li&gt;How to build projects, like the Running Plan Generator, in a day and training for 10Ks and marathons.&lt;/li&gt;
&lt;li&gt;Prioritising tasks.&lt;/li&gt;
&lt;li&gt;Annertech's development workflow and standardisation by developing on remote servers.&lt;/li&gt;
&lt;li&gt;Why you may not need preprocessors and complicated front-end build tools, and reducing complexity using vanilla CSS, JavaScript and web components.&lt;/li&gt;
&lt;li&gt;Lowering the barrier to entry to contribute to open-source projects.&lt;/li&gt;
&lt;li&gt;Building a design system/component library with web components.&lt;/li&gt;
&lt;li&gt;The Content Access by Path module that was developed for Essex County Council.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;P.S. There's less than a year until Drupal 7's end-of-life date. &lt;a href="https://www.oliverdavies.uk/drupal-upgrade"&gt;Plan your upgrade to Drupal 10 now!&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>podcast</category>
    </item>
  </channel>
</rss>
