original_string: public function createView($viewClass = null)
      {
          $builder = $this->viewBuilder();
          if ($viewClass === null && $builder->getClassName() === null) {
              $builder->setClassName($this->viewClass);
              $this->viewClass = null;
          }
          if ($viewClass) {
              $builder->setClassName($viewClass);
          }
  
          $validViewOptions = isset($this->_validViewOptions) ? $this->_validViewOptions : [];
          $viewOptions = [];
          foreach ($validViewOptions as $option) {
              if (property_exists($this, $option)) {
                  $viewOptions[$option] = $this->{$option};
              }
          }
  
          $deprecatedOptions = [
              'layout' => 'setLayout',
              'view' => 'setTemplate',
              'theme' => 'setTheme',
              'autoLayout' => 'enableAutoLayout',
              'viewPath' => 'setTemplatePath',
              'layoutPath' => 'setLayoutPath',
          ];
          foreach ($deprecatedOptions as $old => $new) {
              if (property_exists($this, $old)) {
                  $builder->{$new}($this->{$old});
                  $message = sprintf(
                      'Property $%s is deprecated. Use $this->viewBuilder()->%s() instead in beforeRender().',
                      $old,
                      $new
                  );
                  deprecationWarning($message);
              }
          }
  
          foreach (['name', 'helpers', 'plugin'] as $prop) {
              if (isset($this->{$prop})) {
                  $method = 'set' . ucfirst($prop);
                  $builder->{$method}($this->{$prop});
              }
          }
          $builder->setOptions($viewOptions);
  
          return $builder->build(
              $this->viewVars,
              isset($this->request) ? $this->request : null,
              isset($this->response) ? $this->response : null,
              $this instanceof EventDispatcherInterface ? $this->getEventManager() : null
          );
      }
code: public function createView($viewClass = null)
      {
          $builder = $this->viewBuilder();
          if ($viewClass === null && $builder->getClassName() === null) {
              $builder->setClassName($this->viewClass);
              $this->viewClass = null;
          }
          if ($viewClass) {
              $builder->setClassName($viewClass);
          }
  
          $validViewOptions = isset($this->_validViewOptions) ? $this->_validViewOptions : [];
          $viewOptions = [];
          foreach ($validViewOptions as $option) {
              if (property_exists($this, $option)) {
                  $viewOptions[$option] = $this->{$option};
              }
          }
  
          $deprecatedOptions = [
              'layout' => 'setLayout',
              'view' => 'setTemplate',
              'theme' => 'setTheme',
              'autoLayout' => 'enableAutoLayout',
              'viewPath' => 'setTemplatePath',
              'layoutPath' => 'setLayoutPath',
          ];
          foreach ($deprecatedOptions as $old => $new) {
              if (property_exists($this, $old)) {
                  $builder->{$new}($this->{$old});
                  $message = sprintf(
                      'Property $%s is deprecated. Use $this->viewBuilder()->%s() instead in beforeRender().',
                      $old,
                      $new
                  );
                  deprecationWarning($message);
              }
          }
  
          foreach (['name', 'helpers', 'plugin'] as $prop) {
              if (isset($this->{$prop})) {
                  $method = 'set' . ucfirst($prop);
                  $builder->{$method}($this->{$prop});
              }
          }
          $builder->setOptions($viewOptions);
  
          return $builder->build(
              $this->viewVars,
              isset($this->request) ? $this->request : null,
              isset($this->response) ? $this->response : null,
              $this instanceof EventDispatcherInterface ? $this->getEventManager() : null
          );
      }
code_tokens: public function createView ( $ viewClass = null ) { $ builder = $ this -> viewBuilder ( ) ; if ( $ viewClass === null && $ builder -> getClassName ( ) === null ) { $ builder -> setClassName ( $ this -> viewClass ) ; $ this -> viewClass = null ; } if ( $ viewClass ) { $ builder -> setClassName ( $ viewClass ) ; } $ validViewOptions = isset ( $ this -> _validViewOptions ) ? $ this -> _validViewOptions : [ ] ; $ viewOptions = [ ] ; foreach ( $ validViewOptions as $ option ) { if ( property_exists ( $ this , $ option ) ) { $ viewOptions [ $ option ] = $ this -> { $ option } ; } } $ deprecatedOptions = [ 'layout' => 'setLayout' , 'view' => 'setTemplate' , 'theme' => 'setTheme' , 'autoLayout' => 'enableAutoLayout' , 'viewPath' => 'setTemplatePath' , 'layoutPath' => 'setLayoutPath' , ] ; foreach ( $ deprecatedOptions as $ old => $ new ) { if ( property_exists ( $ this , $ old ) ) { $ builder -> { $ new } ( $ this -> { $ old } ) ; $ message = sprintf ( 'Property $%s is deprecated. Use $this->viewBuilder()->%s() instead in beforeRender().' , $ old , $ new ) ; deprecationWarning ( $ message ) ; } } foreach ( [ 'name' , 'helpers' , 'plugin' ] as $ prop ) { if ( isset ( $ this -> { $ prop } ) ) { $ method = 'set' . ucfirst ( $ prop ) ; $ builder -> { $ method } ( $ this -> { $ prop } ) ; } } $ builder -> setOptions ( $ viewOptions ) ; return $ builder -> build ( $ this -> viewVars , isset ( $ this -> request ) ? $ this -> request : null , isset ( $ this -> response ) ? $ this -> response : null , $ this instanceof EventDispatcherInterface ? $ this -> getEventManager ( ) : null ) ; }
docstring: Constructs the view class instance based on the current configuration.
  
  @param string|null $viewClass Optional namespaced class name of the View class to instantiate.
  @return \Cake\View\View
  @throws \Cake\View\Exception\MissingViewException If view class was not found.
docstring_tokens: Constructs the view class instance based on the current configuration .