title: Must be of the type array, null given,
body: <p>I keep getting the following error and I'm not to sure why: </p>
  
  <p>Catchable fatal error: Argument 3 passed to System\Loader::action() must be of the type array, null given, called in /Application.php on line 31 and defined in /Loader.php on line 18</p>
  
  <p>Loader class: </p>
  
  <pre><code>    &lt;?php
  
  namespace System;
  
  class Loader{
      //application object 
      private $app;
      //controllers container of array
      private $controllers = [];
      //models container array
      private $models = [];
      //constructor takes in system/application $app
      public function __construct(Application $app){
          $this-&gt;app = $app;
      }
      //call the given controller with the given method and pass the given arguments to the controller method
      //takes in string $controller, string $method and array $arguements returns mixed
      public function action ($controller, $method, array $arguements){ ##line 18
          $object = $this-&gt;controller($controller);
          return call_user_func([$object, $method], $arguements);
      }
      //call the given controller takes in string $controller and returns object
      public function controller ($controller){
          $controller = $this-&gt;getControllerName($controller);
          if(! $this-&gt;hasController($controller)){
              $this-&gt;addController($controller);
          }
          return $this-&gt;getController($controller);
      }
      //determine if the given clas/controller exists in the controller container takes in string $controller and returns boolean
      private function hasController($controller){
          return array_key_exists($controller, $this-&gt;controllers);
      }
      //create new object for the given controller and store it in the controllers container
      //takes in string $controller and returns void
      private function addController($controller){
          $object = new $controller($this-&gt;app);
          $this-&gt;controllers[$controller] = $object;
      }
      //get the controller object takes in string $controller and returns object
      private function getController($controller){
          return $this-&gt;controllers[$controller];
      }
      //get the full class name for the given controller takes string $controller returns string
      private function getControllerName($controller){
          $controller .= 'Controller';
          $controller = 'App\\Controllers\\' . $controller;
          return str_replace('/', '\\', $controller);
      }
  
      //call the given Model takes in string $Model and returns object
      public function model ($model){
          $model = $this-&gt;getModelName($model);
          if(! $this-&gt;hasModel($model)){
              $this-&gt;addModel($model);
          }
          return $this-&gt;getModel($model);
      }
      //determine if the given clas/Model exists in the Model container takes in string $controller and returns boolean
      private function hasModel($model){
          return array_key_exists($model, $this-&gt;models);
      }
      //create new object for the given Model and store it in the controllers container
      //takes in string $Model and returns void
      private function addModel($model){
          $object = new $model($this-&gt;app);
          $this-&gt;models[$model] = $object;
      }
      //get the Model object takes in string $Model and returns object
      private function getModel($model){
          return $this-&gt;models[$model];
      }
      //get the full class name for the given Model takes string $Model returns string
      private function getModelName($model){
          $model .= 'Model';
          $model = 'App\\Models\\' . $model;
          return str_replace('/', '\\', $model);
      }
  
  }
  </code></pre>
  
  <p>application class: </p>
  
  <pre><code>&lt;?php
  
  namespace System; 
  
  class Application {
      //Container array var
      private $container = [];
      //application object 
      private static $instance;
      //constructor $file param
      private function __construct(File $file){
          $this-&gt;share('file', $file);
          $this-&gt;registerClasses();
          // static::$instance = $this;
          $this-&gt;loadHelpers();
  
      }
      //get application instance parameter $file returns system\application
      public static function getInstance($file = null){
          if(is_null(static::$instance)) {
              static::$instance = new static($file);
          }
          return static::$instance;
      }
      //run the application returns void
      public function run(){
          $this-&gt;session-&gt;start();
          $this-&gt;request-&gt;prepareUrl();
          $this-&gt;file-&gt;call('App/index.php');
          list($controller, $method, $arguments) = $this-&gt;route-&gt;getProperRoute();
          $output = (string) $this-&gt;load-&gt;action($controller, $method, $arguments); ##line 31
          $this-&gt;response-&gt;setOutput($output);
          $this-&gt;response-&gt;send();
  
      }
      //register classes in sql auto load register
      private function registerClasses(){
          spl_autoload_register([$this, 'load']);
      }
      //load class through autoloading takes string $class and returns void
      public function load($class){
          if(strpos($class, 'App') === 0){
              $file = $class . '.php';
          } else {
              //get the class from vendor
              $file = 'vendor/' . $class . '.php';
          }
          if($this-&gt;file-&gt;exists($file)){
              $this-&gt;file-&gt;call($file);   
          }
      }
      //load helpers file returns void
      private function loadHelpers(){
          $this-&gt;file-&gt;call('vendor/helpers.php');
      }
      // get shared value takes in string $key returns mixed
      public function get($key){
          if(! $this-&gt;isSharing($key)){
              if($this-&gt;isCoreAlias($key)){
                  $this-&gt;share($key, $this-&gt;createNewCoreObject($key));
              } else{
                  die('&lt;b&gt;' . $key . '&lt;/br&gt; not found in application container');
              }
          }
          return $this-&gt;container[$key];
          // return $this-&gt;isSharing() ? $this-&gt;container[$key] : null;
      }
      //determind if the given key is shared through application takes string $key returns boolean
      public function isSharing($key){
          return isset($this-&gt;container[$key]);
      }
      //share key and value through application
      public function share($key, $value){
          $this-&gt;container[$key] = $value;
      }
      //determines if the given key is an alias to core class takes string $alias returns boolean
      public function isCoreAlias($alias){
          $coreClasses = $this-&gt;coreClasses();
          return isset($coreClasses[$alias]);
      }
      //create new object for the core class based on the given alias takes in string $alias returns object
      public function createNewCoreObject($alias){
          $coreClasses = $this-&gt;coreClasses();
          $object = $coreClasses[$alias];
          return new $object($this);
      }
  //get all core classes with its aliase returns array
  private function coreClasses(){
      return [
              'request'       =&gt; 'System\\Http\\Request', 
              'response'      =&gt; 'System\\Http\\Response', 
              'session'       =&gt; 'System\\Session',
              'route'         =&gt; 'System\\Route',
              'cookie'        =&gt; 'System\\Cookie',
              'load'          =&gt; 'System\\Loader',
              'html'          =&gt; 'System\\Html', 
              'db'            =&gt; 'System\\Database', 
              'view'          =&gt; 'System\\View\\ViewFactory',
              'url'           =&gt; 'System\\Url', 
      ];
  }
  //get shared value dynamically takes string $key returns mixed
  public function __get($key){
      return $this-&gt;get($key);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Not too sure where its getting this null from would appreciate if someone could help me figure this out. </p>
  
  <p>edit: route class </p>
  
  <pre><code>&lt;?php
  
  namespace System;
  
  class Route {
      //application object 
      private $app;
      //routes container
      private $routes = [];
      //not found url 
      private $notFound;
      //constructor
      public function __construct(Application $app){
          $this-&gt;app = $app;
      }
      //add new route takes string $url string $action and string $requestmethod returns void
      public function add ($url, $action, $requestMethod = 'GET'){
          $route = [
              'url'       =&gt; $url,
              'pattern'   =&gt; $this-&gt;generatePattern($url),
              'action'    =&gt; $this-&gt;getAction($action),
              'method'    =&gt; strtoupper($requestMethod),
              ];
          $this-&gt;routes[] = $route;
      }   
      //set not found url take string $url returns void
      public function notFound($url){
          $this-&gt;notFound = $url;
      }
      //get proper route reutns array
      public function getProperRoute(){
          foreach ($this-&gt;routes as $route) {
              if ($this-&gt;isMatching($route['pattern'])){
                  $arguments = $this-&gt;getArgumentsFrom($route['pattern']);
                  list($controller, $method) = explode('@', $route['action']);
                  return [$controller, $method, $arguments];
              }
          }
      }
      //determine if the given pattern matches the current requested url takes string $pattern returns boolean
      private function isMatching($pattern){ 
          return preg_match($pattern, $this-&gt;app-&gt;request-&gt;url());
      }
      // get arguement from the current requested url based on the given pattern takes in string $pattern returns array
      private function getArgumentsFrom($pattern){
          preg_match($pattern, $this-&gt;app-&gt;request-&gt;url(), $matches);
          array_shift($matches);
          return $matches;
      } 
      //generate a regex pattern for the given url takes string url returns string
      private function generatePattern($url){
          $pattern = '#^';
          // :text ([a-zA-Z0-9-]+)
          // :id (\d+)
  
          $pattern .= str_replace([':text', ':id'], ['([a-zA-Z0-9-]+)', '(\d+)'], $url);
          $pattern .= '$#';
          return $pattern;
      }
  
      //get proper action takes in string $action returns string
      private function getAction($action){
          $action = str_replace('/', '\\', $action);
          return strpos($action, '@') !== false ? $action : $action . '@index';
      }
  }
  </code></pre>