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
  • Loading branch information
kenjis committed Jun 19, 2024
2 parents 33bd537 + 19d5755 commit cd82a0d
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 14 deletions.
21 changes: 20 additions & 1 deletion .github/scripts/deploy-userguide
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,26 @@
SOURCE=$1
TARGET=$2
RELEASE=$3
VERSION=`echo "$RELEASE" | cut -c 2-`

# Check if RELEASE is empty
if [ -z "$RELEASE" ]; then
echo "Error: \$RELEASE parameter is empty."
exit 1
fi

VERSION=$(echo "$RELEASE" | cut -c 2-)

# Check if VERSION is empty
if [ -z "$VERSION" ]; then
echo "Error: Failed to extract \$VERSION from \$RELEASE parameter '$RELEASE'."
exit 1
fi

# Check if VERSION matches the format X.Y.Z
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: VERSION '$VERSION' does not match the expected format X.Y.Z."
exit 1
fi

echo "Preparing for version $3"
echo "Merging files from $1 to $2"
Expand Down
3 changes: 2 additions & 1 deletion admin/starter/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
},
"autoload": {
"psr-4": {
"App\\": "app/"
"App\\": "app/",
"Config\\": "app/Config"
},
"exclude-from-classmap": [
"**/Database/Migrations/**"
Expand Down
10 changes: 0 additions & 10 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -10356,21 +10356,11 @@
'count' => 1,
'path' => __DIR__ . '/tests/system/Commands/CommandGeneratorTest.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Commands\\\\CommandTest\\:\\:getBuffer\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Commands/CommandTest.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Commands\\\\CommandTest\\:\\:provideCommandParsesArgsCorrectly\\(\\) return type has no value type specified in iterable type iterable\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Commands/CommandTest.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Commands\\\\CommandTest\\:\\:testCommandParsesArgsCorrectly\\(\\) has parameter \\$expected with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Commands/CommandTest.php',
];
$ignoreErrors[] = [
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
'count' => 1,
Expand Down
4 changes: 3 additions & 1 deletion system/Validation/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,10 @@ private function processIfExist(string $field, array $rules, array $data)
break;
}
}
} else {
} elseif (str_contains($field, '.')) {
$dataIsExisting = array_key_exists($ifExistField, $flattenedData);
} else {
$dataIsExisting = array_key_exists($ifExistField, $data);
}

if (! $dataIsExisting) {
Expand Down
5 changes: 4 additions & 1 deletion tests/system/Commands/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function setUp(): void
$this->commands = Services::commands();
}

protected function getBuffer()
protected function getBuffer(): string
{
return $this->getStreamFilterBuffer();
}
Expand Down Expand Up @@ -130,6 +130,9 @@ public function testInexistentCommandsButWithManyAlternatives(): void
$this->assertStringContainsString(':clear', $this->getBuffer());
}

/**
* @param list<string> $expected
*/
#[DataProvider('provideCommandParsesArgsCorrectly')]
public function testCommandParsesArgsCorrectly(string $input, array $expected): void
{
Expand Down
14 changes: 14 additions & 0 deletions tests/system/Validation/RulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use CodeIgniter\Test\CIUnitTestCase;
use Config\Services;
use ErrorException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use stdClass;
Expand Down Expand Up @@ -126,6 +127,19 @@ public static function provideIfExist(): iterable
];
}

public function testIfExistArray(): void
{
$this->expectException(ErrorException::class);
$this->expectExceptionMessage('Array to string conversion');

$rules = ['foo' => 'if_exist|alpha'];
// Invalid array input
$data = ['foo' => ['bar' => '12345']];

$this->validation->setRules($rules);
$this->validation->run($data);
}

#[DataProvider('providePermitEmpty')]
public function testPermitEmpty(array $rules, array $data, bool $expected): void
{
Expand Down
10 changes: 10 additions & 0 deletions tests/system/Validation/StrictRules/RulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,14 @@ public static function provideDiffers(): iterable
'foo bar bool match' => [['foo' => true, 'bar' => true], false],
];
}

public function testIfExistArray(): void
{
$rules = ['foo' => 'if_exist|alpha'];
// Invalid array input
$data = ['foo' => ['bar' => '12345']];

$this->validation->setRules($rules);
$this->assertFalse($this->validation->run($data));
}
}
3 changes: 3 additions & 0 deletions user_guide_src/source/concepts/autoloader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ Config files are namespaced in the ``Config`` namespace, not in ``App\Config`` a
expect. This allows the core system files to always be able to locate them, even when the application
namespace has changed.

.. note:: Since v4.5.3 appstarter, the ``Config\\`` namespace has been added to
**composer.json**'s ``autoload.psr-4``.

Changing App Namespace
----------------------

Expand Down

0 comments on commit cd82a0d

Please sign in to comment.