Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.6
Browse files Browse the repository at this point in the history
 Conflicts:
	phpstan-baseline.php
  • Loading branch information
kenjis committed Jun 20, 2024
2 parents cd82a0d + d6d1434 commit 11d0631
Show file tree
Hide file tree
Showing 9 changed files with 3,210 additions and 46 deletions.
3,189 changes: 3,148 additions & 41 deletions phpstan-baseline.php

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions system/Commands/Database/ShowTableInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ private function restoreDBPrefix(): void
$this->db->setPrefix($this->DBPrefix);
}

/**
* Show Data of Table
*
* @return void
*/
private function showDataOfTable(string $tableName, int $limitRows, int $limitFieldValue)
{
CLI::write("Data of Table \"{$tableName}\":", 'black', 'yellow');
Expand All @@ -207,6 +212,13 @@ private function showDataOfTable(string $tableName, int $limitRows, int $limitFi
CLI::table($this->tbody, $thead);
}

/**
* Show All Tables
*
* @param list<string> $tables
*
* @return void
*/
private function showAllTables(array $tables)
{
CLI::write('The following is a list of the names of all database tables:', 'black', 'yellow');
Expand All @@ -219,6 +231,13 @@ private function showAllTables(array $tables)
CLI::newLine();
}

/**
* Make body for table
*
* @param list<string> $tables
*
* @return list<list<int|string>>
*/
private function makeTbodyForShowAllTables(array $tables): array
{
$this->removeDBPrefix();
Expand All @@ -244,6 +263,11 @@ private function makeTbodyForShowAllTables(array $tables): array
return $this->tbody;
}

/**
* Make table rows
*
* @return list<list<int|string>>
*/
private function makeTableRows(
string $tableName,
int $limitRows,
Expand Down
4 changes: 4 additions & 0 deletions system/Commands/ListCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public function run(array $params)

/**
* Lists the commands with accompanying info.
*
* @return void
*/
protected function listFull(array $commands)
{
Expand Down Expand Up @@ -126,6 +128,8 @@ protected function listFull(array $commands)

/**
* Lists the commands only.
*
* @return void
*/
protected function listSimple(array $commands)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ final class AutoRouteCollector
* @param string $namespace namespace to search
* @param list<class-string> $protectedControllers List of controllers in Defined
* Routes that should not be accessed via Auto-Routing.
* @param list<string> $httpMethods
* @param string $prefix URI prefix for Module Routing
*/
public function __construct(
Expand Down Expand Up @@ -91,6 +92,13 @@ public function get(): array
return $tbody;
}

/**
* Adding Filters
*
* @param list<array<string, array|string>> $routes
*
* @return list<array<string, array|string>>
*/
private function addFilters($routes)
{
$filterCollector = new FilterCollector(true);
Expand Down
3 changes: 2 additions & 1 deletion system/Commands/Utilities/Routes/FilterFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\Filters\Filters;
use CodeIgniter\HTTP\Exceptions\BadRequestException;
use CodeIgniter\HTTP\Exceptions\RedirectException;
use CodeIgniter\Router\Router;
use Config\Feature;
Expand Down Expand Up @@ -72,7 +73,7 @@ public function find(string $uri): array
'before' => [],
'after' => [],
];
} catch (PageNotFoundException) {
} catch (BadRequestException|PageNotFoundException) {
return [
'before' => ['<unknown>'],
'after' => ['<unknown>'],
Expand Down
6 changes: 6 additions & 0 deletions system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ public static function serviceExists(string $name): ?string
* Reset shared instances and mocks for testing.
*
* @return void
*
* @testTag only available to test code
*/
public static function reset(bool $initAutoloader = true)
{
Expand All @@ -362,6 +364,8 @@ public static function reset(bool $initAutoloader = true)
* Resets any mock and shared instances for a single service.
*
* @return void
*
* @testTag only available to test code
*/
public static function resetSingle(string $name)
{
Expand All @@ -375,6 +379,8 @@ public static function resetSingle(string $name)
* @param object $mock
*
* @return void
*
* @testTag only available to test code
*/
public static function injectMock(string $name, $mock)
{
Expand Down
7 changes: 3 additions & 4 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1448,11 +1448,12 @@ public function orHaving($key, $value = null, ?bool $escape = null)
*/
public function orderBy(string $orderBy, string $direction = '', ?bool $escape = null)
{
$qbOrderBy = [];
if ($orderBy === '') {
return $this;
}

$qbOrderBy = [];

$direction = strtoupper(trim($direction));

if ($direction === 'RANDOM') {
Expand All @@ -1463,7 +1464,7 @@ public function orderBy(string $orderBy, string $direction = '', ?bool $escape =
$direction = in_array($direction, ['ASC', 'DESC'], true) ? ' ' . $direction : '';
}

if (! is_bool($escape)) {
if ($escape === null) {
$escape = $this->db->protectIdentifiers;
}

Expand All @@ -1474,8 +1475,6 @@ public function orderBy(string $orderBy, string $direction = '', ?bool $escape =
'escape' => false,
];
} else {
$qbOrderBy = [];

foreach (explode(',', $orderBy) as $field) {
$qbOrderBy[] = ($direction === '' && preg_match('/\s+(ASC|DESC)$/i', rtrim($field), $match, PREG_OFFSET_CAPTURE))
? [
Expand Down
1 change: 1 addition & 0 deletions system/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public function __construct(RouteCollectionInterface $routes, ?Request $request
*
* @return (Closure(mixed...): (ResponseInterface|string|void))|string Controller classname or Closure
*
* @throws BadRequestException
* @throws PageNotFoundException
* @throws RedirectException
*/
Expand Down
14 changes: 14 additions & 0 deletions tests/system/Commands/RoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,18 @@ public function testRoutesCommandRouteLegacy(): void
EOL;
$this->assertStringContainsString($expected, $this->getBuffer());
}

public function testRoutesCommandRouteWithRegexp(): void
{
$routes = Services::routes();
$routes->resetRoutes();
$routes->options('picker/(.+)', 'Options::index');

command('routes');

$expected = <<<'EOL'
| OPTIONS | picker/(.+) | » | \App\Controllers\Options::index | <unknown> | <unknown> |
EOL;
$this->assertStringContainsString($expected, $this->getBuffer());
}
}

0 comments on commit 11d0631

Please sign in to comment.