Skip to content

Commit 38c7abf

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.8
2 parents 680873b + cc882d6 commit 38c7abf

99 files changed

Lines changed: 1270 additions & 579 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/test-structarmed.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
php-version: ${{ matrix.php-version }}
6060
extensions: intl
6161
tools: composer
62+
coverage: none
6263

6364
- name: Validate composer.json
6465
run: composer validate --strict

‎app/Controllers/BaseController.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace App\Controllers;
44

55
use CodeIgniter\Controller;
6+
use CodeIgniter\HTTP\CLIRequest;
7+
use CodeIgniter\HTTP\IncomingRequest;
68
use CodeIgniter\HTTP\RequestInterface;
79
use CodeIgniter\HTTP\ResponseInterface;
810
use Psr\Log\LoggerInterface;
@@ -28,6 +30,8 @@ abstract class BaseController extends Controller
2830
// protected $session;
2931

3032
/**
33+
* @param CLIRequest|IncomingRequest $request
34+
*
3135
* @return void
3236
*/
3337
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)

‎composer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"psr/log": "^3.0"
1818
},
1919
"require-dev": {
20-
"boundwize/structarmed": "^0.16",
20+
"boundwize/structarmed": "^0.17",
2121
"codeigniter/phpstan-codeigniter": "^2.1",
2222
"fakerphp/faker": "^1.24",
2323
"kint-php/kint": "^6.1",
@@ -29,7 +29,7 @@
2929
"phpunit/phpcov": "^9.0.2 || ^10.0",
3030
"phpunit/phpunit": "^10.5.16 || ^11.2",
3131
"predis/predis": "^3.0",
32-
"rector/rector": "2.6.3",
32+
"rector/rector": "2.6.5",
3333
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3434
},
3535
"replace": {

‎phpstan.dist.neon‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ includes:
22
- utils/phpstan-baseline/loader.neon
33

44
parameters:
5-
phpVersion: 80200
5+
phpVersion:
6+
min: 80200
7+
max: 80599
68
tmpDir: build/phpstan
79
level: 6
810
bootstrapFiles:

‎rector.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@
6969
__DIR__ . '/phpstan-bootstrap.php',
7070
])
7171
->withPHPStanConfigs([
72-
__DIR__ . '/phpstan.dist.neon',
7372
__DIR__ . '/vendor/codeigniter/phpstan-codeigniter/extension.neon',
7473
__DIR__ . '/vendor/phpstan/phpstan-strict-rules/rules.neon',
7574
__DIR__ . '/vendor/shipmonk/phpstan-baseline-per-identifier/extension.neon',
75+
__DIR__ . '/phpstan.dist.neon',
7676
])
7777
// is there a file you need to skip?
7878
->withSkip([

‎structarmed.php‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
* For the full copyright and license information, please view
1111
* the LICENSE file that was distributed with this source code.
1212
*/
13-
13+
use Boundwize\StructArmed\Rule\Rules\Function_\MustHaveReturnTypeFunctionRule;
14+
use Boundwize\StructArmed\Preset\Presets\CodeQualityPreset;
1415
use CodeIgniter\Cache\ResponseCache;
1516
use CodeIgniter\HTTP\CLIRequest;
1617
use CodeIgniter\HTTP\Header;
@@ -47,9 +48,16 @@
4748
__DIR__ . '/tests/system/Config/fixtures',
4849
],
4950
__DIR__ . '/system/ThirdParty',
51+
CodeQualityPreset::ANONYMOUS_FUNCTIONS_MUST_BE_STATIC => [
52+
__DIR__ . '/system/View/Cells/Cell.php',
53+
],
5054
])
5155
->cacheDirectory(is_dir('/tmp') ? '/tmp/structarmed' : null)
52-
->withPreset(Preset::PSR4())
56+
->withPresets(Preset::PSR4(), Preset::CODEQUALITY())
57+
58+
->layer('Helpers', __DIR__ . '/system/Helpers')
59+
->rule('helpers.functions_must_have_return_type', new MustHaveReturnTypeFunctionRule('Helpers'))
60+
5361
// Resolve CodeIgniter layers from class names because several layers share directories.
5462
->layerPattern('API', '/^CodeIgniter\\\\API\\\\.*$/')
5563
->layerPattern('Cache', '/^CodeIgniter\\\\Cache\\\\.*$/')
@@ -112,7 +120,7 @@
112120
'Security' => ['Cookie', 'HTTP', 'I18n', 'Session'],
113121
'Session' => ['Cookie', 'Database', 'HTTP', 'I18n'],
114122
'Throttle' => ['Cache', 'I18n'],
115-
'Validation' => ['Database', 'HTTP', 'I18n', 'Input'],
123+
'Validation' => ['Database', 'HTTP', 'Helpers', 'I18n', 'Input'],
116124
'View' => ['Cache'],
117125
])
118126
->skipPathsForRuleset(['*test*'])

‎system/Autoloader/Autoloader.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ private function autoloadKint(): void
450450
{
451451
// If we have KINT_DIR it means it's already loaded via composer
452452
if (! defined('KINT_DIR')) {
453-
spl_autoload_register(function ($class): void {
453+
spl_autoload_register(static function ($class): void {
454454
$class = explode('\\', $class);
455455

456456
if (array_shift($class) !== 'Kint') {

‎system/BaseModel.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,9 +1825,7 @@ public function getValidationRules(array $options = []): array
18251825

18261826
protected function ensureValidation(): void
18271827
{
1828-
if ($this->validation === null) {
1829-
$this->validation = service('validation', null, false);
1830-
}
1828+
$this->validation ??= service('validation', null, false);
18311829
}
18321830

18331831
/**

‎system/CLI/CLI.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,12 @@ public static function prompt(string $field, $options = null, $validation = null
236236
$default = $options[0];
237237
}
238238

239-
static::fwrite(STDOUT, $field . (trim($field) !== '' ? ' ' : '') . $extraOutput . ': ');
240239
static::$lastWrite = 'write';
241240

242-
// Read the input from keyboard.
243-
$input = trim(static::$io->input());
244-
$input = ($input === '') ? (string) $default : $input;
241+
// The reader renders the prompt itself, so readline redraws repaint it instead of erasing it.
242+
$prompt = sprintf('%s%s%s: ', $field, trim($field) !== '' ? ' ' : '', $extraOutput);
243+
$input = trim(static::$io->input($prompt));
244+
$input = $input === '' ? (string) $default : $input;
245245

246246
if ($validation !== []) {
247247
while (! static::validate('"' . trim($field) . '"', $input, $validation)) {

‎system/CLI/InputOutput.php‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,18 @@ public function input(?string $prefix = null): string
4343
{
4444
// readline() can't be tested.
4545
if ($this->readlineSupport && ! service('environment')->isTesting()) {
46-
return readline($prefix); // @codeCoverageIgnore
46+
// @codeCoverageIgnoreStart
47+
// Libedit reports "EditLine wrapper" and mangles the markers, so only GNU readline gets them.
48+
if ($prefix !== null && ! str_contains(readline_info('library_version'), 'EditLine')) {
49+
$prefix = $this->markAnsiNonPrinting($prefix);
50+
}
51+
52+
return readline($prefix);
53+
// @codeCoverageIgnoreEnd
4754
}
4855

49-
echo $prefix;
56+
// self:: skips MockInputOutput's fwrite override, whose filter bookkeeping must not nest inside input().
57+
self::fwrite(STDOUT, $prefix ?? '');
5058

5159
$input = fgets(fopen('php://stdin', 'rb'));
5260

@@ -77,4 +85,12 @@ public function fwrite($handle, string $string): void
7785

7886
fwrite($handle, $string);
7987
}
88+
89+
/**
90+
* Wraps ANSI escape sequences in readline's non-printing markers so line-redraw column accounting skips them.
91+
*/
92+
private function markAnsiNonPrinting(string $prefix): string
93+
{
94+
return preg_replace('/(\e\[[0-9;]*m)/', "\x01\$1\x02", $prefix);
95+
}
8096
}

0 commit comments

Comments
 (0)