public function render($view, $file, $params)
 {
     $remainingCalls = self::CALL_LIMIT;
     if ($this->isPhp7 == false) {
         set_error_handler($this->errorToExceptionHandler());
         //convert errors to exceptions
     }
     while ($remainingCalls > 0) {
         try {
             $output = $view->renderPhpFile($file, $params);
             if ($this->isPhp7 == false) {
                 restore_error_handler();
                 //give control back to the default error handler
             }
             return $output;
         } catch (\Exception $ex) {
             ob_get_clean();
             //flush all accumulated junk from renderPhpFile
             $matches = [];
             if (preg_match(self::UNDEFINED_VARIABLE_PATTERN, $ex->getMessage(), $matches)) {
                 $variableName = $matches[1];
                 $params[$variableName] = FrontendMockBuilder::createMock();
             } else {
                 //This is a real exception that we can't handle. Rethrow
                 throw $ex;
             }
         }
         $remainingCalls -= 1;
     }
     throw new yii\base\Exception('FrontendRenderer::render reached max call limit');
 }
 /**
  * Offset to retrieve
  *
  * @link http://php.net/manual/en/arrayaccess.offsetget.php
  *
  * @param mixed $offset <p>
  * The offset to retrieve.
  * </p>
  *
  * @return mixed Can return all value types.
  * @since 5.0.0
  */
 public function offsetGet($offset)
 {
     return FrontendMockBuilder::createMock();
 }
 public function testCreateMockWithValidData_ExpectsNotNullResult()
 {
     FrontendMockBuilder::setMessage('Some message');
     FrontendMockBuilder::setNumberOfIterations(10);
     $this->assertNotNull(FrontendMockBuilder::createMock());
 }
 protected function _before()
 {
     FrontendMockBuilder::setMessage(self::MESSAGE);
     FrontendMockBuilder::setNumberOfIterations(self::ITERATIONS);
     $this->mockModel = FrontendMockBuilder::createMock();
 }