original_string: public function get(string $filename = null): \BearFramework\App\Context
      {
          if ($filename === null) {
              $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
              if (!isset($trace[0])) {
                  throw new \Exception('Cannot detect context!');
              }
              $filename = $trace[0]['file'];
          }
          $filename = \BearFramework\Internal\Utilities::normalizePath($filename);
          if (isset($this->objectsCache[$filename])) {
              return clone($this->objectsCache[$filename]);
          }
          $matchedDir = null;
          foreach ($this->dirs as $dir => $length) {
              if ($dir === $filename . '/' || substr($filename, 0, $length) === $dir) {
                  $matchedDir = $dir;
                  break;
              }
          }
          if ($matchedDir !== null) {
              if (isset($this->objectsCache[$matchedDir])) {
                  return clone($this->objectsCache[$matchedDir]);
              }
              $this->objectsCache[$matchedDir] = new App\Context($this->app, substr($matchedDir, 0, -1));
              $this->objectsCache[$filename] = clone($this->objectsCache[$matchedDir]);
              return clone($this->objectsCache[$matchedDir]);
          }
          throw new \Exception('Connot find context for ' . $filename);
      }
code: public function get(string $filename = null): \BearFramework\App\Context
      {
          if ($filename === null) {
              $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
              if (!isset($trace[0])) {
                  throw new \Exception('Cannot detect context!');
              }
              $filename = $trace[0]['file'];
          }
          $filename = \BearFramework\Internal\Utilities::normalizePath($filename);
          if (isset($this->objectsCache[$filename])) {
              return clone($this->objectsCache[$filename]);
          }
          $matchedDir = null;
          foreach ($this->dirs as $dir => $length) {
              if ($dir === $filename . '/' || substr($filename, 0, $length) === $dir) {
                  $matchedDir = $dir;
                  break;
              }
          }
          if ($matchedDir !== null) {
              if (isset($this->objectsCache[$matchedDir])) {
                  return clone($this->objectsCache[$matchedDir]);
              }
              $this->objectsCache[$matchedDir] = new App\Context($this->app, substr($matchedDir, 0, -1));
              $this->objectsCache[$filename] = clone($this->objectsCache[$matchedDir]);
              return clone($this->objectsCache[$matchedDir]);
          }
          throw new \Exception('Connot find context for ' . $filename);
      }
code_tokens: public function get ( string $ filename = null ) : \ BearFramework \ App \ Context { if ( $ filename === null ) { $ trace = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS , 1 ) ; if ( ! isset ( $ trace [ 0 ] ) ) { throw new \ Exception ( 'Cannot detect context!' ) ; } $ filename = $ trace [ 0 ] [ 'file' ] ; } $ filename = \ BearFramework \ Internal \ Utilities :: normalizePath ( $ filename ) ; if ( isset ( $ this -> objectsCache [ $ filename ] ) ) { return clone ( $ this -> objectsCache [ $ filename ] ) ; } $ matchedDir = null ; foreach ( $ this -> dirs as $ dir => $ length ) { if ( $ dir === $ filename . '/' || substr ( $ filename , 0 , $ length ) === $ dir ) { $ matchedDir = $ dir ; break ; } } if ( $ matchedDir !== null ) { if ( isset ( $ this -> objectsCache [ $ matchedDir ] ) ) { return clone ( $ this -> objectsCache [ $ matchedDir ] ) ; } $ this -> objectsCache [ $ matchedDir ] = new App \ Context ( $ this -> app , substr ( $ matchedDir , 0 , - 1 ) ) ; $ this -> objectsCache [ $ filename ] = clone ( $ this -> objectsCache [ $ matchedDir ] ) ; return clone ( $ this -> objectsCache [ $ matchedDir ] ) ; } throw new \ Exception ( 'Connot find context for ' . $ filename ) ; }
docstring: Returns a context object for the filename specified.
  
  @param string|null $filename The filename used to find the context. Will be automatically detected if not provided.
  @throws \Exception
  @return \BearFramework\App\Context The context object for the filename specified.
docstring_tokens: Returns a context object for the filename specified .