Skip to content

Commit c24fd43

Browse files
Tybazeakhumphrey
authored andcommitted
PHP 8.1 > Compatibility
sfYamlInline, backport fix from Symfony1. Doctrine_Hydrator_Graph fix array_map, rtrim(): Passing null to parameter #1 ($string) of type string is deprecated I emmit the hypothese that this array_map was broken, because array_map result is not assigned. Doctrine_Migration_Diff:333, str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated Doctrine_Migration_Builder:78:, is_dir(): Passing null to parameter #1 ($filename) of type string is deprecated Doctrine_Validator_Notblank, allow null value HydrationListener, in HydrateTestCase.php, fix strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated internal_method_return_types https://wiki.php.net/rfc/internal_method_return_types see 2b2d173 for details Doctrine_Collection_OnDemand Doctrine_Validator_Exception PHP 8.1 PDO stringify is now disable by default. Activate it for Mysql + Sqlite https://www.php.net/manual/en/migration81.incompatible.php#migration81.incompatible.pdo.mysql PHP 8.1 Fix: Warning: strtotime() : Epoch doesn't fit in a PHP integer in Doctrine_Record. This is only happening on 32bit system, because int 32bit could not map the whole strtotime date scope. Example value: "0000-00-00 00:00:00" Before 8.1 strtotime returns false, after it return false but also raise a Warning. @ is slightly lowering performance, it should not trigger any unwanted error, as if format is invalid strtotime should return "false" As this old project need BC for old system, seems the best fix. PHP 8.1 > Automatic conversion of false to array is deprecated Fix Doctrine_Record _invokedSaveHooks cannot assign array value to boolean Declaration to array instead of boolean PHP 8.1 > Serializable Phase Out https://wiki.php.net/rfc/phase_out_serializable PHP 7.4 add a new Serialize mecanism PHP 8.1 made old method, "Serializable implementation" deprecated PHP 9.0 (no release date at this moment) will drop the support. Temporary Fix: Adding both method serialize/unserialize and __serialize/__unserialize In order to be compatible with future PHP 9.0, once it will be release, we will have to drop the support to PHP Version before 7.4. Currently a lot of Unix distribution in LTS are running a PHP Version older than 7.4 so moving to the final solution of "add return type" should break a lot of setup for the moment. PHP 8.1 > internal_method_return_types https://wiki.php.net/rfc/internal_method_return_types PHP 8.0 added return type for abstract methods on Iterator, ArrayAccess, Countable, IteratorAggregate PHP 8.1 made non implementation as a Deprecated Warning PHP 9.0 (no release date at this moment) will drop the support. Temporary Fix : adding this Attribute Will drop the Deprecated warning. Adding return type will break compatibility before PHP 7.4, Return type has been added on PHP 7.0, but "mixed" special type is required, and it has been added on PHP 7.4. In order to be compatible with future PHP 9.0, once it will be release, we will have to drop the support to PHP Version before 7.4 Currently a lot of Unix distribution in LTS are running a PHP Version older than 7.4 so moving to the final solution of "add return type" should break a lot of setup for the moment. Update Travis to PHP up to 8.1 PHP 8.0 > Doctrine_Query:36, uncaught TypeError: Unsupported operand types: string % int Doctrine_Parser_Xml:89, htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated https://wiki.php.net/rfc/internal_method_return_types for Doctrine_Node Doctrine_Adapter_Mock Doctrine_EventListener_TestLogger Doctrine_Parser_Xml Doctrine_Ticket_1254_TestCase, replace stftime() by date() with format adaptation.
1 parent 73c8411 commit c24fd43

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

lib/Doctrine/Collection/OnDemand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function next(): void
9292

9393
public function valid(): bool
9494
{
95-
if ( ! is_null($this->_current) && $this->_current !== false) {
95+
if (!is_null($this->_current) && $this->_current !== false) {
9696
return true;
9797
}
9898
return false;

lib/Doctrine/Connection/Sqlite.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function connect()
9898

9999
$connected = parent::connect();
100100

101-
if(!$hasConfigureStringify) {
101+
if (!$hasConfigureStringify) {
102102
// PHP8.1 require default to true to keep BC
103103
// https://www.php.net/manual/en/migration81.incompatible.php#migration81.incompatible.pdo.sqlite
104104
// Can be overwritten by user later
@@ -144,4 +144,4 @@ public function dropDatabase()
144144

145145
$this->export->dropDatabase($info['database']);
146146
}
147-
}
147+
}

lib/Doctrine/Record.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,8 @@ public function unserialize($serialized)
822822
*
823823
* @return array
824824
*/
825-
public function __serialize() {
826-
825+
public function __serialize()
826+
{
827827
$event = new Doctrine_Event($this, Doctrine_Event::RECORD_SERIALIZE);
828828

829829
$this->preSerialize($event);
@@ -1563,8 +1563,8 @@ protected function _isValueModified($type, $old, $new)
15631563
} else if (in_array($type, array('integer', 'int')) && is_numeric($old) && is_numeric($new)) {
15641564
return $old != $new;
15651565
} else if ($type == 'timestamp' || $type == 'date') {
1566-
$oldStrToTime = strtotime((string) $old);
1567-
$newStrToTime = strtotime((string) $new);
1566+
$oldStrToTime = @strtotime((string) $old);
1567+
$newStrToTime = @strtotime((string) $new);
15681568
if ($oldStrToTime && $newStrToTime) {
15691569
return $oldStrToTime !== $newStrToTime;
15701570
} else {

lib/Doctrine/Table.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3205,10 +3205,10 @@ public function __serialize() {
32053205
/**
32063206
* Unserializes a Doctrine_Record instance for php 7.4+
32073207
*
3208-
* @param array $data
3208+
* @param array $serialized
32093209
*/
3210-
public function __unserialize($data) {
3211-
3210+
public function __unserialize($data)
3211+
{
32123212
$this->_identifier = $data[0];
32133213
$this->_identifierType = $data[1];
32143214
$this->_columns = $data[2];

lib/Doctrine/Validator/Notblank.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ class Doctrine_Validator_Notblank extends Doctrine_Validator_Driver
4141
*/
4242
public function validate($value)
4343
{
44-
return (null !== $value && '' !== trim($value));
44+
return (null !== $value && '' !== trim((string) $value));
4545
}
46-
}
46+
}

0 commit comments

Comments
 (0)