From 1eb86d89ad75c5596807ce5fa385837bb7d6d051 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 23 Mar 2021 17:21:51 +0700 Subject: [PATCH] add require_once __DIR__ . /system/Test/bootstrap.php; outside rector config --- rector.php | 8 ++------ system/Autoloader/FileLocator.php | 3 +-- system/CLI/BaseCommand.php | 1 - system/Database/BaseBuilder.php | 7 +++---- system/Database/BaseConnection.php | 2 -- system/Database/BasePreparedQuery.php | 4 +--- system/Database/BaseUtils.php | 3 --- system/Database/Config.php | 3 --- system/Database/ConnectionInterface.php | 1 - system/Database/Database.php | 10 ++++------ system/Database/Forge.php | 2 -- system/Database/Migration.php | 1 - system/HTTP/CURLRequest.php | 10 ---------- system/HTTP/DownloadResponse.php | 1 - system/HTTP/IncomingRequest.php | 2 -- system/HTTP/Negotiate.php | 2 -- system/HTTP/Request.php | 16 +++++++++------- system/Images/Handlers/BaseHandler.php | 2 +- system/Log/Handlers/BaseHandler.php | 1 - system/Router/RouteCollection.php | 20 -------------------- system/Router/Router.php | 1 - system/Test/FeatureResponse.php | 2 +- system/Throttle/Throttler.php | 4 ++-- system/Validation/FileRules.php | 2 +- system/Validation/Validation.php | 4 ---- system/View/Parser.php | 2 -- 26 files changed, 25 insertions(+), 89 deletions(-) diff --git a/rector.php b/rector.php index 3ee0070e8f60..6a7a88f6bd74 100644 --- a/rector.php +++ b/rector.php @@ -24,6 +24,8 @@ use Utils\Rector\PassStrictParameterToFunctionParameterRector; use Utils\Rector\UnderscoreToCamelCaseVariableNameRector; +require_once __DIR__ . '/system/Test/bootstrap.php'; + return static function (ContainerConfigurator $containerConfigurator): void { $parameters = $containerConfigurator->parameters(); @@ -41,12 +43,6 @@ PassStrictParameterToFunctionParameterRector::class => [__DIR__ . '/tests/system/Database/Live/SelectTest.php'], ]); - // Rector relies on autoload setup of your project; Composer autoload is included by default; to add more: - $parameters->set(Option::AUTOLOAD_PATHS, [ - // autoload specific file - __DIR__ . '/system/Test/bootstrap.php', - ]); - // auto import fully qualified class names $parameters->set(Option::AUTO_IMPORT_NAMES, true); $parameters->set(Option::ENABLE_CACHE, true); diff --git a/system/Autoloader/FileLocator.php b/system/Autoloader/FileLocator.php index 9146b072545c..b8ef4d19bc99 100644 --- a/system/Autoloader/FileLocator.php +++ b/system/Autoloader/FileLocator.php @@ -22,12 +22,11 @@ class FileLocator /** * The Autoloader to use. * - * @var \CodeIgniter\Autoloader\Autoloader + * @var Autoloader */ protected $autoloader; //-------------------------------------------------------------------- - /** * Constructor * diff --git a/system/CLI/BaseCommand.php b/system/CLI/BaseCommand.php index d34a1b0f74dd..fc9a33b80f5b 100644 --- a/system/CLI/BaseCommand.php +++ b/system/CLI/BaseCommand.php @@ -79,7 +79,6 @@ abstract class BaseCommand protected $commands; //-------------------------------------------------------------------- - /** * BaseCommand constructor. * diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index a9afedca892e..d370439ca714 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -247,7 +247,6 @@ class BaseBuilder ]; //-------------------------------------------------------------------- - /** * Constructor * @@ -263,7 +262,9 @@ public function __construct($tableName, ConnectionInterface &$db, array $options throw new DatabaseException('A table must be specified when creating a new Query Builder.'); } - /** @var BaseConnection $db */ + /** + * @var BaseConnection $db +*/ $this->db = $db; $this->tableName = $tableName; @@ -282,7 +283,6 @@ public function __construct($tableName, ConnectionInterface &$db, array $options } //-------------------------------------------------------------------- - /** * Returns the current database connection * @@ -2022,7 +2022,6 @@ public function getCompiledQBWhere() } //-------------------------------------------------------------------- - /** * Get_Where * diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index 70a91f655c3b..a37ffaaa1025 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -950,7 +950,6 @@ abstract protected function _transCommit(): bool; abstract protected function _transRollback(): bool; //-------------------------------------------------------------------- - /** * Returns an instance of the query builder for this connection. * @@ -972,7 +971,6 @@ public function table($tableName) } //-------------------------------------------------------------------- - /** * Creates a prepared statement with the database that can then * be used to execute multiple statements against. Within the diff --git a/system/Database/BasePreparedQuery.php b/system/Database/BasePreparedQuery.php index e191646a023f..00f477b65c9e 100644 --- a/system/Database/BasePreparedQuery.php +++ b/system/Database/BasePreparedQuery.php @@ -56,7 +56,6 @@ abstract class BasePreparedQuery implements PreparedQueryInterface protected $db; //-------------------------------------------------------------------- - /** * Constructor. * @@ -90,7 +89,7 @@ public function prepare(string $sql, array $options = [], string $queryClass = ' $sql = preg_replace('/:[^\s,)]+/', '?', $sql); /** - * @var \CodeIgniter\Database\Query $query + * @var Query $query */ $query = new $queryClass($this->db); @@ -119,7 +118,6 @@ public function prepare(string $sql, array $options = [], string $queryClass = ' abstract public function _prepare(string $sql, array $options = []); //-------------------------------------------------------------------- - /** * Takes a new set of data and runs it against the currently * prepared query. Upon success, will return a Results object. diff --git a/system/Database/BaseUtils.php b/system/Database/BaseUtils.php index 8bc9eb8012b4..9b9cf48cd7b8 100644 --- a/system/Database/BaseUtils.php +++ b/system/Database/BaseUtils.php @@ -49,7 +49,6 @@ abstract class BaseUtils protected $repairTable = false; //-------------------------------------------------------------------- - /** * Class constructor * @@ -221,7 +220,6 @@ public function repairTable(string $tableName) } //-------------------------------------------------------------------- - /** * Generate CSV from a query result object * @@ -258,7 +256,6 @@ public function getCSVFromResult(ResultInterface $query, string $delim = ',', st } //-------------------------------------------------------------------- - /** * Generate XML data from a query result object * diff --git a/system/Database/Config.php b/system/Database/Config.php index 0b658f57c20e..b84067d5a257 100644 --- a/system/Database/Config.php +++ b/system/Database/Config.php @@ -36,7 +36,6 @@ class Config extends BaseConfig static protected $factory; //-------------------------------------------------------------------- - /** * Creates the default * @@ -119,7 +118,6 @@ public static function forge($group = null) } //-------------------------------------------------------------------- - /** * Returns a new instance of the Database Utilities class. * @@ -135,7 +133,6 @@ public static function utils($group = null) } //-------------------------------------------------------------------- - /** * Returns a new instance of the Database Seeder. * diff --git a/system/Database/ConnectionInterface.php b/system/Database/ConnectionInterface.php index 59e1ba8849da..43806adcb22c 100644 --- a/system/Database/ConnectionInterface.php +++ b/system/Database/ConnectionInterface.php @@ -145,7 +145,6 @@ public function query(string $sql, $binds = null); public function simpleQuery(string $sql); //-------------------------------------------------------------------- - /** * Returns an instance of the query builder for this connection. * diff --git a/system/Database/Database.php b/system/Database/Database.php index 7e76326520a8..e173907b712c 100644 --- a/system/Database/Database.php +++ b/system/Database/Database.php @@ -23,7 +23,7 @@ class Database /** * Maintains an array of the instances of all connections that have * been created. - * + * * Helps to keep track of all open connections for performance * monitoring, logging, etc. * @@ -41,9 +41,9 @@ class Database * @param string $alias * * @return mixed - * + * * @throws InvalidArgumentException - * + * * @internal param bool $useBuilder */ public function load(array $params = [], string $alias = '') @@ -72,7 +72,6 @@ public function load(array $params = [], string $alias = '') } //-------------------------------------------------------------------- - /** * Creates a Forge instance for the current database type. * @@ -92,7 +91,6 @@ public function loadForge(ConnectionInterface $db): object } //-------------------------------------------------------------------- - /** * Creates a Utils instance for the current database type. * @@ -119,7 +117,7 @@ public function loadUtils(ConnectionInterface $db): object * @param array $params * * @return array - * + * * @throws InvalidArgumentException */ protected function parseDSN(array $params): array diff --git a/system/Database/Forge.php b/system/Database/Forge.php index 7e514c760197..2f8c8fa1c721 100644 --- a/system/Database/Forge.php +++ b/system/Database/Forge.php @@ -161,7 +161,6 @@ class Forge protected $default = ' DEFAULT '; //-------------------------------------------------------------------- - /** * Constructor. * @@ -173,7 +172,6 @@ public function __construct(BaseConnection $db) } //-------------------------------------------------------------------- - /** * Provides access to the forge's current database connection. * diff --git a/system/Database/Migration.php b/system/Database/Migration.php index c0874baae10f..670c2785c67b 100644 --- a/system/Database/Migration.php +++ b/system/Database/Migration.php @@ -40,7 +40,6 @@ abstract class Migration protected $forge; //-------------------------------------------------------------------- - /** * Constructor. * diff --git a/system/HTTP/CURLRequest.php b/system/HTTP/CURLRequest.php index a85152d401f4..35fb535e5c8e 100644 --- a/system/HTTP/CURLRequest.php +++ b/system/HTTP/CURLRequest.php @@ -73,7 +73,6 @@ class CURLRequest extends Request protected $delay = 0.0; //-------------------------------------------------------------------- - /** * Takes an array of options to set the following possible class properties: * @@ -105,7 +104,6 @@ public function __construct(App $config, URI $uri, ResponseInterface $response = } //-------------------------------------------------------------------- - /** * Sends an HTTP request to the specified $url. If this is a relative * URL, it will be merged with $this->baseURI to form a complete URL. @@ -130,7 +128,6 @@ public function request($method, string $url, array $options = []): ResponseInte } //-------------------------------------------------------------------- - /** * Convenience method for sending a GET request. * @@ -145,7 +142,6 @@ public function get(string $url, array $options = []): ResponseInterface } //-------------------------------------------------------------------- - /** * Convenience method for sending a DELETE request. * @@ -160,7 +156,6 @@ public function delete(string $url, array $options = []): ResponseInterface } //-------------------------------------------------------------------- - /** * Convenience method for sending a HEAD request. * @@ -175,7 +170,6 @@ public function head(string $url, array $options = []): ResponseInterface } //-------------------------------------------------------------------- - /** * Convenience method for sending an OPTIONS request. * @@ -190,7 +184,6 @@ public function options(string $url, array $options = []): ResponseInterface } //-------------------------------------------------------------------- - /** * Convenience method for sending a PATCH request. * @@ -205,7 +198,6 @@ public function patch(string $url, array $options = []): ResponseInterface } //-------------------------------------------------------------------- - /** * Convenience method for sending a POST request. * @@ -220,7 +212,6 @@ public function post(string $url, array $options = []): ResponseInterface } //-------------------------------------------------------------------- - /** * Convenience method for sending a PUT request. * @@ -375,7 +366,6 @@ public function getMethod(bool $upper = false): string } //-------------------------------------------------------------------- - /** * Fires the actual cURL request. * diff --git a/system/HTTP/DownloadResponse.php b/system/HTTP/DownloadResponse.php index bc1f01b6f280..97f0bb979f86 100644 --- a/system/HTTP/DownloadResponse.php +++ b/system/HTTP/DownloadResponse.php @@ -243,7 +243,6 @@ public function setStatusCode(int $code, string $reason = '') } //-------------------------------------------------------------------- - /** * Sets the Content Type header for this response with the mime type * and, optionally, the charset. diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index 1ae7d6e813e5..8dda43047f89 100755 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -120,7 +120,6 @@ class IncomingRequest extends Request protected $userAgent; //-------------------------------------------------------------------- - /** * Constructor * @@ -472,7 +471,6 @@ public function getCookie($index = null, $filter = null, $flags = null) } //-------------------------------------------------------------------- - /** * Fetch the user agent string * diff --git a/system/HTTP/Negotiate.php b/system/HTTP/Negotiate.php index a881031bbd6e..e44840ea727b 100644 --- a/system/HTTP/Negotiate.php +++ b/system/HTTP/Negotiate.php @@ -32,7 +32,6 @@ class Negotiate protected $request; //-------------------------------------------------------------------- - /** * Constructor * @@ -47,7 +46,6 @@ public function __construct(RequestInterface $request = null) } //-------------------------------------------------------------------- - /** * Stores the request instance to grab the headers from. * diff --git a/system/HTTP/Request.php b/system/HTTP/Request.php index 9b4c16df877e..62744506fc72 100644 --- a/system/HTTP/Request.php +++ b/system/HTTP/Request.php @@ -52,7 +52,9 @@ class Request extends Message implements MessageInterface, RequestInterface */ public function __construct($config = null) { - /** @deprecated $this->proxyIps property will be removed in the future */ + /** + * @deprecated $this->proxyIps property will be removed in the future +*/ $this->proxyIPs = $config->proxyIPs; if (empty($this->method)) @@ -127,12 +129,12 @@ public function withMethod($method) return $request; } - /** - * Retrieves the URI instance. - * - * @return URI - */ - public function getUri() + /** + * Retrieves the URI instance. + * + * @return URI + */ + public function getUri() { return $this->uri; } diff --git a/system/Images/Handlers/BaseHandler.php b/system/Images/Handlers/BaseHandler.php index f591cd693e40..9eb007a6c647 100644 --- a/system/Images/Handlers/BaseHandler.php +++ b/system/Images/Handlers/BaseHandler.php @@ -32,7 +32,7 @@ abstract class BaseHandler implements ImageHandlerInterface /** * The image/file instance * - * @var \CodeIgniter\Images\Image + * @var Image */ protected $image; diff --git a/system/Log/Handlers/BaseHandler.php b/system/Log/Handlers/BaseHandler.php index 61b6e7d7f832..7f06577815af 100644 --- a/system/Log/Handlers/BaseHandler.php +++ b/system/Log/Handlers/BaseHandler.php @@ -73,7 +73,6 @@ public function canHandle(string $level): bool abstract public function handle($level, $message): bool; //-------------------------------------------------------------------- - /** * Stores the date format to use while logging messages. * diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index c417fc7b6c6c..da381c0f9022 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -226,7 +226,6 @@ public function __construct(FileLocator $locator, Modules $moduleConfig) } //-------------------------------------------------------------------- - /** * Registers a new constraint with the system. Constraints are used * by the routes as placeholders for regular expressions to make defining @@ -253,7 +252,6 @@ public function addPlaceholder($placeholder, string $pattern = null): RouteColle } //-------------------------------------------------------------------- - /** * Sets the default namespace to use for Controllers when no other * namespace has been specified. @@ -271,7 +269,6 @@ public function setDefaultNamespace(string $value): RouteCollectionInterface } //-------------------------------------------------------------------- - /** * Sets the default controller to use when no other controller has been * specified. @@ -288,7 +285,6 @@ public function setDefaultController(string $value): RouteCollectionInterface } //-------------------------------------------------------------------- - /** * Sets the default method to call on the controller when no other * method has been set in the route. @@ -305,7 +301,6 @@ public function setDefaultMethod(string $value): RouteCollectionInterface } //-------------------------------------------------------------------- - /** * Tells the system whether to convert dashes in URI strings into * underscores. In some search engines, including Google, dashes @@ -325,7 +320,6 @@ public function setTranslateURIDashes(bool $value): RouteCollectionInterface } //-------------------------------------------------------------------- - /** * If TRUE, the system will attempt to match the URI against * Controllers by matching each segment against folders/files @@ -346,7 +340,6 @@ public function setAutoRoute(bool $value): RouteCollectionInterface } //-------------------------------------------------------------------- - /** * Sets the class/method that should be called if routing doesn't * find a match. It can be either a closure or the controller/method @@ -415,7 +408,6 @@ protected function discoverRoutes() } //-------------------------------------------------------------------- - /** * Sets the default constraint to be used in the system. Typically * for use with the 'resource' method. @@ -620,7 +612,6 @@ public function map(array $routes = [], array $options = null): RouteCollectionI } //-------------------------------------------------------------------- - /** * Adds a single route to the collection. * @@ -774,7 +765,6 @@ public function group(string $name, ...$params) // be expanded in the future. See the docblock for 'add' method above for // current list of globally available options. // - /** * Creates a collections of HTTP-verb based routes for a controller. * @@ -1005,7 +995,6 @@ public function presenter(string $name, array $options = null): RouteCollectionI } //-------------------------------------------------------------------- - /** * Specifies a single route to match for multiple HTTP Verbs. * @@ -1037,7 +1026,6 @@ public function match(array $verbs = [], string $from = '', $to = '', array $opt } //-------------------------------------------------------------------- - /** * Specifies a route that is only available to GET requests. * @@ -1055,7 +1043,6 @@ public function get(string $from, $to, array $options = null): RouteCollectionIn } //-------------------------------------------------------------------- - /** * Specifies a route that is only available to POST requests. * @@ -1073,7 +1060,6 @@ public function post(string $from, $to, array $options = null): RouteCollectionI } //-------------------------------------------------------------------- - /** * Specifies a route that is only available to PUT requests. * @@ -1091,7 +1077,6 @@ public function put(string $from, $to, array $options = null): RouteCollectionIn } //-------------------------------------------------------------------- - /** * Specifies a route that is only available to DELETE requests. * @@ -1109,7 +1094,6 @@ public function delete(string $from, $to, array $options = null): RouteCollectio } //-------------------------------------------------------------------- - /** * Specifies a route that is only available to HEAD requests. * @@ -1127,7 +1111,6 @@ public function head(string $from, $to, array $options = null): RouteCollectionI } //-------------------------------------------------------------------- - /** * Specifies a route that is only available to PATCH requests. * @@ -1145,7 +1128,6 @@ public function patch(string $from, $to, array $options = null): RouteCollection } //-------------------------------------------------------------------- - /** * Specifies a route that is only available to OPTIONS requests. * @@ -1163,7 +1145,6 @@ public function options(string $from, $to, array $options = null): RouteCollecti } //-------------------------------------------------------------------- - /** * Specifies a route that is only available to command-line requests. * @@ -1181,7 +1162,6 @@ public function cli(string $from, $to, array $options = null): RouteCollectionIn } //-------------------------------------------------------------------- - /** * Limits the routes to a specified ENVIRONMENT or they won't run. * diff --git a/system/Router/Router.php b/system/Router/Router.php index e1560b0d4bd6..1ee735d1bf83 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -103,7 +103,6 @@ class Router implements RouterInterface protected $filterInfo; //-------------------------------------------------------------------- - /** * Stores a reference to the RouteCollection object. * diff --git a/system/Test/FeatureResponse.php b/system/Test/FeatureResponse.php index d2611379495a..41e00cfe5b3c 100644 --- a/system/Test/FeatureResponse.php +++ b/system/Test/FeatureResponse.php @@ -26,7 +26,7 @@ class FeatureResponse extends TestCase /** * The response. * - * @var \CodeIgniter\HTTP\ResponseInterface + * @var ResponseInterface */ public $response; diff --git a/system/Throttle/Throttler.php b/system/Throttle/Throttler.php index 033fc93d6a8e..0b69db4ca7b6 100644 --- a/system/Throttle/Throttler.php +++ b/system/Throttle/Throttler.php @@ -30,7 +30,7 @@ class Throttler implements ThrottlerInterface /** * Container for throttle counters. * - * @var \CodeIgniter\Cache\CacheInterface + * @var CacheInterface */ protected $cache; @@ -135,7 +135,7 @@ public function check(string $key, int $capacity, int $seconds, int $cost = 1): // should be refilled, then checked against capacity // to be sure the bucket didn't overflow. $tokens += $rate * $elapsed; - $tokens = $tokens > $capacity ? $capacity : $tokens; + $tokens = $tokens > $capacity ? $capacity : $tokens; // If $tokens >= 1, then we are safe to perform the action, but // we need to decrement the number of available tokens. diff --git a/system/Validation/FileRules.php b/system/Validation/FileRules.php index 3c6de57fecbb..0ab18b215b36 100644 --- a/system/Validation/FileRules.php +++ b/system/Validation/FileRules.php @@ -23,7 +23,7 @@ class FileRules /** * Request instance. So we can get access to the files. * - * @var \CodeIgniter\HTTP\RequestInterface + * @var RequestInterface */ protected $request; diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index 7c68d9a73f99..307c52514d0f 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -335,7 +335,6 @@ protected function processRules(string $field, string $label = null, $value, $ru } //-------------------------------------------------------------------- - /** * Takes a Request object and grabs the input data to use from its * array values. @@ -402,7 +401,6 @@ public function setRule(string $field, string $label = null, string $rules, arra } //-------------------------------------------------------------------- - /** * Stores the rules that should be used to validate the items. * Rules should be an array formatted like: @@ -754,7 +752,6 @@ public function getErrors(): array } //-------------------------------------------------------------------- - /** * Sets the error for a specific field. Used by custom validation methods. * @@ -833,7 +830,6 @@ protected function splitRules(string $rules): array //-------------------------------------------------------------------- // Misc //-------------------------------------------------------------------- - /** * Resets the class to a blank slate. Should be called whenever * you need to process more than one array. diff --git a/system/View/Parser.php b/system/View/Parser.php index 26f3d1400fe0..3a32020ac140 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -191,7 +191,6 @@ public function renderString(string $template, array $options = null, bool $save } //-------------------------------------------------------------------- - /** * Sets several pieces of view data at once. * In the Parser, we need to store the context here @@ -540,7 +539,6 @@ protected function parseConditionals(string $template): string } //-------------------------------------------------------------------- - /** * Over-ride the substitution field delimiters. *