PHP Version
8.5
CodeIgniter4 Version
develop
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
cli-server (PHP built-in webserver)
Environment
testing, development
Database
No response
What happened?
PHP works in a magical way: Some type conversions are preserved, others are not.
Specifically, the database setup has different behavior:
database.tests.hostname=127.0.0.1database.tests.database=:memory:database.tests.DBDriver=SQLite3database.tests.synchronous=1database.tests.busyTimeout=1234
// app/Config/Database.php...'busyTimeout' => 1000,
'synchronous' => null,
...
/* output ./spark config:check Database ... 'foreignKeys' => boolean true 'busyTimeout' => integer 1234 'synchronous' => string (1) "0"*/
TypeError: Cannot assign string to property CodeIgniter\Database\SQLite3\Connection::$synchronous of type ?int
To clarify: If we specify a number in the array Database, then the ENV data will be numeric. If it is null or a string, then the type changes to string.
// app/Config/Database.php...'busyTimeout' => null,
'synchronous' => 0,
...
/* output ./spark config:check Database ... 'foreignKeys' => boolean true 'busyTimeout' => string (4) "1234" 'synchronous' => integer 2*/
Steps to Reproduce
Add the ENV settings
database.tests.synchronous = 1
database.tests.busyTimeout = 1234
and run the command ./spark config:check Database
Expected Output
Correct typing
Anything else?
Errors can manifest themselves in other places. There aren't any because it's a native type?int is specified for synchronous.
// Constructor system/Database/BaseConnection.phpforeach ($paramsas$key => $value) {
if (property_exists($this, $key)) {
$this->{$key} = $value;
}
}I noticed the same thing in routing, when route parameters can be matched with the types in the controller.
PHP Version
8.5
CodeIgniter4 Version
develop
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter)Which operating systems have you tested for this bug?
Linux
Which server did you use?
cli-server (PHP built-in webserver)
Environment
testing, development
Database
No response
What happened?
PHP works in a magical way: Some type conversions are preserved, others are not.
Specifically, the database setup has different behavior:
To clarify: If we specify a number in the array Database, then the ENV data will be numeric. If it is null or a string, then the type changes to string.
Steps to Reproduce
Add the ENV settings
and run the command
./spark config:check DatabaseExpected Output
Correct typing
Anything else?
Errors can manifest themselves in other places. There aren't any because it's a native type?int is specified for synchronous.
I noticed the same thing in routing, when route parameters can be matched with the types in the controller.