Skip to content

Commit c3bfac5

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.6
# Conflicts: # composer.json # utils/phpstan-baseline/missingType.iterableValue.neon
2 parents cc96fe3 + 61741c5 commit c3bfac5

30 files changed

+131
-114
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"phpunit/phpcov": "^9.0.2 || ^10.0",
2929
"phpunit/phpunit": "^10.5.16 || ^11.2",
3030
"predis/predis": "^1.1 || ^2.3",
31-
"rector/rector": "2.0.4",
31+
"rector/rector": "2.0.5",
3232
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
3333
},
3434
"replace": {

system/CLI/CLI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public static function promptByKey($text, array $options, $validation = null): s
289289

290290
CLI::isZeroOptions($options);
291291

292-
if ($line = array_shift($text)) {
292+
if (($line = array_shift($text)) !== null) {
293293
CLI::write($line);
294294
}
295295

@@ -348,7 +348,7 @@ public static function promptByMultipleKeys(string $text, array $options): array
348348
// return the prompt again if $input contain(s) non-numeric character, except a comma.
349349
// And if max from $options less than max from input,
350350
// it means user tried to access null value in $options
351-
if ($pattern === 0 || $maxOptions < $maxInput) {
351+
if ($pattern < 1 || $maxOptions < $maxInput) {
352352
static::error('Please select correctly.');
353353
CLI::newLine();
354354

system/Database/BaseBuilder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ public function join(string $table, $cond, string $type = '', ?bool $escape = nu
668668
} else {
669669
// Split multiple conditions
670670
// @TODO This does not parse `BETWEEN a AND b` correctly.
671-
if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE)) {
671+
if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE) >= 1) {
672672
$conditions = [];
673673
$joints = $joints[0];
674674
array_unshift($joints, ['', 0]);
@@ -2203,7 +2203,7 @@ protected function formatValues(array $values): array
22032203
*
22042204
* @param array|object|null $set a dataset
22052205
*
2206-
* @return false|int|list<string> Number of rows inserted or FALSE on failure, SQL array when testMode
2206+
* @return false|int|list<string> Number of rows inserted or FALSE on no data to perform an insert operation, SQL array when testMode
22072207
*/
22082208
public function insertBatch($set = null, ?bool $escape = null, int $batchSize = 100)
22092209
{
@@ -3477,7 +3477,7 @@ protected function getOperator(string $str, bool $list = false)
34773477
'/' . implode('|', $this->pregOperators) . '/i',
34783478
$str,
34793479
$match
3480-
) ? ($list ? $match[0] : $match[0][0]) : false;
3480+
) >= 1 ? ($list ? $match[0] : $match[0][0]) : false;
34813481
}
34823482

34833483
/**
@@ -3508,7 +3508,7 @@ private function getOperatorFromWhereKey(string $whereKey)
35083508
'/' . implode('|', $pregOperators) . '/i',
35093509
$whereKey,
35103510
$match
3511-
) ? $match[0] : false;
3511+
) >= 1 ? $match[0] : false;
35123512
}
35133513

35143514
/**

system/Database/Postgre/Connection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ protected function getDriverFunctionPrefix(): string
228228
*/
229229
public function affectedRows(): int
230230
{
231+
if ($this->resultID === false) {
232+
return 0;
233+
}
234+
231235
return pg_affected_rows($this->resultID);
232236
}
233237

system/Database/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ protected function matchNamedBinds(string $sql, array $binds): string
342342
*/
343343
protected function matchSimpleBinds(string $sql, array $binds, int $bindCount, int $ml): string
344344
{
345-
if ($c = preg_match_all("/'[^']*'/", $sql, $matches)) {
345+
if ($c = preg_match_all("/'[^']*'/", $sql, $matches) >= 1) {
346346
$c = preg_match_all('/' . preg_quote($this->bindMarker, '/') . '/i', str_replace($matches[0], str_replace($this->bindMarker, str_repeat(' ', $ml), $matches[0]), $sql, $c), $matches, PREG_OFFSET_CAPTURE);
347347

348348
// Bind values' count must match the count of markers in the query

system/Database/SQLSRV/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function join(string $table, $cond, string $type = '', ?bool $escape = nu
122122
$cond = ' ON ' . $cond;
123123
} else {
124124
// Split multiple conditions
125-
if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE)) {
125+
if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE) >= 1) {
126126
$conditions = [];
127127
$joints = $joints[0];
128128
array_unshift($joints, ['', 0]);

system/Database/SQLSRV/Connection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ public function error(): array
453453
*/
454454
public function affectedRows(): int
455455
{
456+
if ($this->resultID === false) {
457+
return 0;
458+
}
459+
456460
return sqlsrv_rows_affected($this->resultID);
457461
}
458462

system/Email/Email.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ public function wordWrap($str, $charlim = null)
10311031

10321032
$unwrap = [];
10331033

1034-
if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches)) {
1034+
if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches) >= 1) {
10351035
for ($i = 0, $c = count($matches[0]); $i < $c; $i++) {
10361036
$unwrap[] = $matches[1][$i];
10371037
$str = str_replace($matches[0][$i], '{{unwrapped' . $i . '}}', $str);

system/Helpers/text_helper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function ascii_to_entities(string $str): string
132132
*/
133133
function entities_to_ascii(string $str, bool $all = true): string
134134
{
135-
if (preg_match_all('/\&#(\d+)\;/', $str, $matches)) {
135+
if (preg_match_all('/\&#(\d+)\;/', $str, $matches) >= 1) {
136136
for ($i = 0, $s = count($matches[0]); $i < $s; $i++) {
137137
$digits = (int) $matches[1][$i];
138138
$out = '';
@@ -196,7 +196,7 @@ function word_censor(string $str, array $censored, string $replacement = ''): st
196196
"\\1{$replacement}\\3",
197197
$str
198198
);
199-
} elseif (preg_match_all("/{$delim}(" . $badword . "){$delim}/i", $str, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE)) {
199+
} elseif (preg_match_all("/{$delim}(" . $badword . "){$delim}/i", $str, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) >= 1) {
200200
$matches = $matches[1];
201201

202202
for ($i = count($matches) - 1; $i >= 0; $i--) {
@@ -352,7 +352,7 @@ function word_wrap(string $str, int $charlim = 76): string
352352
// strip the entire chunk and replace it with a marker.
353353
$unwrap = [];
354354

355-
if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches)) {
355+
if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches) >= 1) {
356356
for ($i = 0, $c = count($matches[0]); $i < $c; $i++) {
357357
$unwrap[] = $matches[1][$i];
358358
$str = str_replace($matches[0][$i], '{{unwrapped' . $i . '}}', $str);

system/Helpers/url_helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ function auto_link(string $str, string $type = 'both', bool $popup = false): str
360360
$str,
361361
$matches,
362362
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
363-
)
363+
) >= 1
364364
) {
365365
// Set our target HTML if using popup links.
366366
$target = ($popup) ? ' target="_blank"' : '';
@@ -387,7 +387,7 @@ function auto_link(string $str, string $type = 'both', bool $popup = false): str
387387
$str,
388388
$matches,
389389
PREG_OFFSET_CAPTURE
390-
)
390+
) >= 1
391391
) {
392392
foreach (array_reverse($matches[0]) as $match) {
393393
if (filter_var($match[0], FILTER_VALIDATE_EMAIL) !== false) {

0 commit comments

Comments
 (0)