title: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in [...]
body: <p>I've the following error, using PHP 8.1</p>
  <p>Could you please help me?</p>
  <blockquote>
  <p>Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in [...]</p>
  </blockquote>
  <p>The Model:</p>
  <pre><code>class ComputerModel
  {
  
      public $id;
      public $hardwareComputerLocation;
      [...] 
  }
  </code></pre>
  <p>The Controller:</p>
  <pre><code>$countComputer = $this-&gt;computerRepository-&gt;countComputer();
  </code></pre>
  <p>The Repository:</p>
  <pre><code>function countComputer()
  {
      $stmt = $this-&gt;pdo-&gt;query(&quot;
      SELECT
          hardwareComputerLocation, COUNT(*)
      FROM
          tbl_computer
      WHERE
          hardwareComputerLocation != '' 
      GROUP BY hardwareComputerLocation
      &quot;);
      return $res = $stmt-&gt;fetchAll(PDO::FETCH_CLASS, &quot;itportal\\CMR\\ComputerModel&quot;);
  }
  </code></pre>
  <p>The View:</p>
  <pre><code>&lt;?php
      foreach ($countComputer AS $count):
  ?&gt;
  &lt;li&gt;&lt;i class=&quot;bi bi-pc&quot;&gt;&lt;/i&gt; &lt;a href=&quot;computerOverview&quot;&gt; &lt;?= $count-&gt;hardwareComputerLocation ?&gt; (&lt;?= COUNT($count-&gt;hardwareComputerLocation) ?&gt;)&lt;/a&gt;&lt;/li&gt;
  &lt;?php
      endforeach;     
  ?&gt;
  </code></pre>