e107inc/e107

View on GitHub
e107_handlers/application.php

Summary

Maintainability
F
4 days
Test Coverage
F
38%

File application.php has 2980 lines of code (exceeds 2000 allowed). Consider refactoring.
Open

<?php
/*
 * e107 website system
 *
 * Copyright (C) 2008-2012 e107 Inc (e107.org)
Severity: Major
Found in e107_handlers/application.php - About 3 days to fix

    Avoid deeply nested control flow statements.
    Open

                                if($rule->allowVars)
                                {
                                    foreach ($rule->allowVars as $key) 
                                    {
                                        if(isset($_GET[$key]) && !$request->isRequestParam($key))
    Severity: Major
    Found in e107_handlers/application.php - About 45 mins to fix

      Avoid too many return statements within this method.
      Open

                      return $base.$route.$urlSuffix.'?'.$params.$anc;
      Severity: Major
      Found in e107_handlers/application.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return $base.$route.$urlSuffix.'?'.$params.$anc;
        Severity: Major
        Found in e107_handlers/application.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return rtrim($url, '/');
          Severity: Major
          Found in e107_handlers/application.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return self::underscore($title);
            Severity: Major
            Found in e107_handlers/application.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return $format === self::FORMAT_GET ? $base.'?'.$this->routeVar.'='.$route.$anc : $base.$route.$urlSuffix.$anc;
              Severity: Major
              Found in e107_handlers/application.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return $base.$tmp.$anc;
                Severity: Major
                Found in e107_handlers/application.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                               return $url !== '' ? $url.$suffix : $url;
                  Severity: Major
                  Found in e107_handlers/application.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return null;
                    Severity: Major
                    Found in e107_handlers/application.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return $base.$route.$urlSuffix.$anc;
                      Severity: Major
                      Found in e107_handlers/application.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return null;
                        Severity: Major
                        Found in e107_handlers/application.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                               return $base.rtrim(($this->isMainModule($module) ? '' : $alias.'/').$url, '/').$anc;
                          Severity: Major
                          Found in e107_handlers/application.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return str_replace(' ', '+', self::camelize($title, true, ' '));
                            Severity: Major
                            Found in e107_handlers/application.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return str_replace(' ', '+', $tp->ustrtolower($title));
                              Severity: Major
                              Found in e107_handlers/application.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return $title;
                                Severity: Major
                                Found in e107_handlers/application.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                  return str_replace(' ', '+', $title);
                                  Severity: Major
                                  Found in e107_handlers/application.php - About 30 mins to fix

                                    Invalid offset "en" of array type array{}
                                    Open

                                            $arr = (!empty($this->_legacyAliases[e_LAN])) ?  array_merge($this->_legacy,$this->_legacyAliases[e_LAN]) : $this->_legacy;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 2 (args) is null but \array_merge() takes array
                                    Open

                                            $arr = (!empty($this->_legacyAliases[e_LAN])) ?  array_merge($this->_legacy,$this->_legacyAliases[e_LAN]) : $this->_legacy;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type string but isLegacy() is declared to return bool
                                    Open

                                            return self::$_legacy;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getController() is declared to return \eController
                                    Open

                                            if(!$class_name) return null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but retrieveModule() is declared to return string
                                    Open

                                                return null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 2 (options) is '/' but \eRouter::createPathInfo() takes array defined at /code/e107_handlers/application.php:2406
                                    Open

                                            if ($this->append) $url .= '/'.$manager->createPathInfo($params, '/', '/').$suffix;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 2 (params) is '' but \eRouter::assemble() takes array defined at /code/e107_handlers/application.php:2133
                                    Open

                                                $url = eFront::instance()->getRouter()->assemble($url, '', 'encode=0');
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 2 (mode) is 'mix' but \e_parse::createConstants() takes int defined at /code/e107_handlers/e_parse_class.php:3255
                                    Open

                                            return e107::getParser()->createConstants($url, 'mix');
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Assigning \e_vars to property but \eUrlRule->_regexTemplates is \e_var
                                    Open

                                            $this->_regexTemplates = new e_vars($this->regexTemplates);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type array but getValidator() is declared to return \e_validator
                                    Open

                                            return $this->_validator;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Suspicious type \str of a variable or expression used to build a string. (Expected type to be able to cast to a string)
                                    Open

                                                           $("#'.$metaTitleID.'").addClass("has-error");
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 3 (options) is 'encode=0&full=1' but \eRouter::assemble() takes array defined at /code/e107_handlers/application.php:2133
                                    Open

                                                        $redirect = $this->assemble($this->notFoundUrl, '', 'encode=0&full=1');
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Assigning \e_validator to property but \eControllerFront->_validator is array
                                    Open

                                                $this->_validator = new e_validator('controller');
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getRouteHistory() is declared to return array|string
                                    Open

                                            if(!$this->_routeHistory) return null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Parameter $metaTitleID has undeclared type \str
                                    Open

                                        public static function syncSEOTitle($titleID, $metaTitleID)
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Suspicious type \str of a variable or expression used to build a string. (Expected type to be able to cast to a string)
                                    Open

                                                        var charlimit = $("#'.$metaTitleID.'").attr("data-char-count");
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Suspicious type \str of a variable or expression used to build a string. (Expected type to be able to cast to a string)
                                    Open

                                                    $("#'.$metaTitleID.'").attr("placeholder",title);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 2 (location) is null but \eRouter::file2config() takes string defined at /code/e107_handlers/application.php:1271
                                    Open

                                                    $c = eRouter::file2config($file, $location);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 1 (status) is array but \eFront::isLegacy() takes bool defined at /code/e107_handlers/application.php:554
                                    Open

                                                eFront::isLegacy($this->getConfigValue($module, 'legacy'));
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Variable $tr2 was undeclared, but array fields are being added to it.
                                    Open

                                            $tr2['/'] = $tr['/'] = '\\/';
                                    Severity: Info
                                    Found in e107_handlers/application.php by phan

                                    Argument 1 (pathInfo) is \eRequest but \eRouter::parsePathInfo() takes string defined at /code/e107_handlers/application.php:2448
                                    Open

                                                    $manager->parsePathInfo($request, ltrim(substr($pathInfo, strlen($matches[0])), '/'));
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    false to array comparison
                                    Open

                                            if(false !== $params) $request->setRequestParams($params);
                                    Severity: Info
                                    Found in e107_handlers/application.php by phan

                                    Assigning null to property but \eRequest->_controller is string
                                    Open

                                                $this->_controller = null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getConfigObject() is declared to return \eUrlConfig
                                    Open

                                                if(!$location) return null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getAliasFromModule() is declared to return string
                                    Open

                                                return (in_array($module, $aliases) ? array_search($module, $aliases) : null);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 2 (vars) is \e_var but \e_parse::simpleParse() takes \e_vars|array defined at /code/e107_handlers/e_parse_class.php:886
                                    Open

                                                        $value = $tp->simpleParse($value, $this->_regexTemplates, '[^\/]+');
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getRouteHistory() is declared to return array|string
                                    Open

                                            return null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getDispatchLocationPath() is declared to return string
                                    Open

                                                    if(!$plugin) return null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 1 (route) is null but \eRequest::setRoute() takes string defined at /code/e107_handlers/application.php:3834
                                    Open

                                                $request->setRequestInfo($url)->setPathInfo(null)->setRoute(null);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Assigning \e_vars to property but \eUrlRule->_regexTemplates is \e_var
                                    Open

                                                    $this->_regexTemplates = new e_vars($this->regexTemplates);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Variable $tr was undeclared, but array fields are being added to it.
                                    Open

                                            $tr2['/'] = $tr['/'] = '\\/';
                                    Severity: Info
                                    Found in e107_handlers/application.php by phan

                                    Assigning array<string></string> to property but \eResponse->_title is array<string>&gt;|array<string>|array<string>|array{default:array{}}</string></string></string>
                                    Open

                                                    $this->_title['default'] = '';
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Invalid offset "format" of array type array{configClass:string}|array{configPath:string}|array{location:mixed}|array{}
                                    Open

                                                if(!isset($_config['config']['format']) || !in_array($_config['config']['format'], array(self::FORMAT_GET, self::FORMAT_PATH)))
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 1 (route) is ?string but \eRequest::initFromRoute() takes string defined at /code/e107_handlers/application.php:3902
                                    Open

                                            return $this->initFromRoute($route);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Suspicious type \str of a variable or expression used to build a string. (Expected type to be able to cast to a string)
                                    Open

                                                        var title = $("#'.$titleID.'").val() + " | " + "'.SITENAME.'";
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Suspicious type \str of a variable or expression used to build a string. (Expected type to be able to cast to a string)
                                    Open

                                                $("#'.$metaTitleID.'").on("ready focus", function() {
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Suspicious type \str of a variable or expression used to build a string. (Expected type to be able to cast to a string)
                                    Open

                                                $("#'.$titleID.'").on("input change focus", function() 
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Variable $file is undeclared
                                    Open

                                                                define('e_PAGE', basename($file));
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getConfigObject() is declared to return \eUrlConfig
                                    Open

                                                if(!is_readable($path)) return null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Property \eUrlRule->_regexTemplates has undeclared type \e_var (Did you mean class \e_vars)
                                    Open

                                        protected $_regexTemplates;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Method \eUrlConfig::create is declared to return array|string but has no return value
                                    Open

                                        public function create($route, $params = array(), $options = array()) {}
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Assigning null to property but \eRequest->_action is string
                                    Open

                                                $this->_action = null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Call to deprecated function \getperms() defined at /code/class2.php:1322
                                    Open

                                                        elseif(getperms('0'))
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Suspicious type object of a variable or expression used to build a string. (Expected type to be able to cast to a string)
                                    Open

                                                throw new eException("Controller $controller is not an instance of eController");
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getControllerClass() is declared to return string
                                    Open

                                            return ($location ? $location.'_'.$module.'_'.$controllerName.'_controller' : null);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type false but isDispatchableModule() is declared to return string
                                    Open

                                                if(!$class_name) return false;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Saw possibly unextractable annotation for a fragment of comment '* @param array current configuration array (url_config core preference like)': after array, did not see an element name (will guess based on comment order)
                                    Open

                                         * @param array current configuration array (url_config core preference like)
                                    Severity: Info
                                    Found in e107_handlers/application.php by phan

                                    Argument 1 (pathInfo) is null but \eRequest::setPathInfo() takes string defined at /code/e107_handlers/application.php:3660
                                    Open

                                                $request->setRequestInfo($url)->setPathInfo(null)->setRoute(null);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type false but parse() is declared to return string
                                    Open

                                            return false;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Suspicious type \str of a variable or expression used to build a string. (Expected type to be able to cast to a string)
                                    Open

                                                    var title = $("#'.$titleID.'").val() + " | " + "'.SITENAME.'";
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Invalid offset "en" of array type array{}
                                    Open

                                                        $alias = (!empty($this->_alias[e_LAN][$plug][$k])) ? $this->_alias[e_LAN][$plug][$k] : $v['alias'];
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Suspicious array access to true
                                    Open

                                                if(!empty($status[0]) && ($status[0] === '{'))
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getConfigLocationPath() is declared to return string
                                    Open

                                                    return null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type false but isDispatchableModule() is declared to return string
                                    Open

                                                if(($location = eDispatcher::getModuleRealLocation($module)) === null) return false;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getAliasFromModule() is declared to return string
                                    Open

                                            return (in_array($module, $this->_aliases) ? array_search($module, $this->_aliases) : null);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Assigning null to property but \eRequest->_module is string
                                    Open

                                                $this->_module = null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Suspicious type \str of a variable or expression used to build a string. (Expected type to be able to cast to a string)
                                    Open

                                                    var title = $("#'.$titleID.'").val() + " | " + "'.SITENAME.'";
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 1 (text) is true but \e_parse::replaceConstants() takes string defined at /code/e107_handlers/e_parse_class.php:3025
                                    Open

                                                    $status = e107::getParser()->replaceConstants($status);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getControllerPath() is declared to return string
                                    Open

                                            return ($location ? self::getDispatchPath($module, $location, $sc).$controller.'.php': null);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    array to false comparison
                                    Open

                                            if($this->allowVars === false) $this->allowVars = array_keys($this->params);
                                    Severity: Info
                                    Found in e107_handlers/application.php by phan

                                    Saw possibly unextractable annotation for a fragment of comment '* @param array available URL modules as detected by {@link eDispatcher::adminReadModules()} and stored as url_modules core preference value': after array, did not see an element name (will guess based on comment order)
                                    Open

                                         * @param array available URL modules as detected by {@link eDispatcher::adminReadModules()} and stored as url_modules core preference value
                                    Severity: Info
                                    Found in e107_handlers/application.php by phan

                                    Saw possibly unextractable annotation for a fragment of comment '* @param string module': after string, did not see an element name (will guess based on comment order)
                                    Open

                                         * @param string module
                                    Severity: Info
                                    Found in e107_handlers/application.php by phan

                                    Reference to undeclared constant \e_UC_PUBLIC
                                    Open

                                        protected $userclass = e_UC_PUBLIC;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Parameter $titleID has undeclared type \str
                                    Open

                                        public static function syncSEOTitle($titleID, $metaTitleID)
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Suspicious type \str of a variable or expression used to build a string. (Expected type to be able to cast to a string)
                                    Open

                                                        $("#'.$metaTitleID.'").attr("placeholder",title);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getModuleFromAlias() is declared to return string
                                    Open

                                            return (isset($this->_aliases[$alias]) ? $this->_aliases[$alias] : null);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Saw possibly unextractable annotation for a fragment of comment '* @param void': after void, did not see an element name (will guess based on comment order)
                                    Open

                                         * @param void
                                    Severity: Info
                                    Found in e107_handlers/application.php by phan

                                    Suspicious type \str of a variable or expression used to build a string. (Expected type to be able to cast to a string)
                                    Open

                                                    if(!$("#'.$metaTitleID.'").val()) 
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 2 (params) is '' but \eRouter::assemble() takes array defined at /code/e107_handlers/application.php:2133
                                    Open

                                                        $redirect = $this->assemble($this->notFoundUrl, '', 'encode=0&full=1');
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 3 (options) is 'encode=0' but \eRouter::assemble() takes array defined at /code/e107_handlers/application.php:2133
                                    Open

                                                $url = eFront::instance()->getRouter()->assemble($url, '', 'encode=0');
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    When appending to a value of type array{}, found an array access index of type ?string, but expected the index to be of type int|string
                                    Open

                                                    $this->_meta[$name] = $attr;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getConfigPath() is declared to return string
                                    Open

                                                    return null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getDispatchLocationPath() is declared to return string
                                    Open

                                                    return null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type false but isDispatchableModule() is declared to return string
                                    Open

                                            return false;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getConfigObject() is declared to return \eUrlConfig
                                    Open

                                                if(!class_exists($className, false)) return null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 1 (status) is '' but \eFront::isLegacy() takes bool defined at /code/e107_handlers/application.php:554
                                    Open

                                                    eFront::isLegacy(''); // reset legacy - not found route isn't legacy call
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getRouteHistory() is declared to return array|string
                                    Open

                                                return isset($this->_routeHistory[$source]) ? $this->_routeHistory[$source] : null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Returning type null but getDispatchPath() is declared to return string
                                    Open

                                                    return null;
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 1 (encoded_string) is array but \parse_str() takes string
                                    Open

                                                    parse_str($this->defaultParams, $this->defaultParams);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    Argument 1 (action) is null but \e_jshelper::sendJsonResponse() takes string defined at /code/e107_handlers/js_helper.php:222
                                    Open

                                            $jshelper->sendJsonResponse(null);
                                    Severity: Minor
                                    Found in e107_handlers/application.php by phan

                                    There are no issues that match your filters.

                                    Category
                                    Status