title: Expected type 'object'. Found 'void'.intelephense(1006) Issue in PHP MVC project
body: <p>Getting Expected type 'object'. Found 'void'.intelephense(1006) Issue in PHP MVC project. I attached the relevant code and source that I followed (youtube) here. Appreciate it if someone can explain what happened.</p>
  <p>Have a home controller with a function to get an instance of a model like this: (How I coded)</p>
  <pre><code>&lt;?php
  
  class Controller{
  
      public function model($model){
  
          require_once '../app/models/' . $model . '.php';
          
          return new $model();
      }
      
  }
  </code></pre>
  <p>Have User.php class like this: (How I coded)</p>
  <pre><code>&lt;?php 
  
  
  class User{
      public $name;
  
      public function __construct()
      {
          
      }
  }
  </code></pre>
  <p>Have Home controller like this:  (How I coded)</p>
  <pre><code>&lt;?php
  
  class Home extends Controller{
  
      public function index($name = ''){
  
        
          $user = $this-&gt;model('User');
          $user-&gt;name = $name;
          echo $user-&gt;name;
          
      }
  
      public function test(){
  
          echo 'test_function()';
  
      }
  
      public function get_user_name(){
  
      }
  
      public function model($model){
          echo $model;
      }
  }
  </code></pre>
  <p>Near the $user-&gt;name = $name; and the  echo $user-&gt;name; it shows the error. <a href="https://i.stack.imgur.com/iARG4.png" rel="nofollow noreferrer">this is the screenshot</a>
  I'm afraid can't find the issue. I thought it was an issue with the model but was unable to resolve it yet. I am watching a youtube video series and doing this. this is the relevant video URL <a href="https://www.youtube.com/watch?v=FWLXYPIxbYI&amp;list=PLfdtiltiRHWGXVHXX09fxXDi-DqInchFD&amp;index=6&amp;ab_channel=Codecourse" rel="nofollow noreferrer">youtube video</a> Coded as here but I'm in trouble. Can someone explain why this happen and where is the error, please? I want to clarify this MVC architecture.</p>