Skip to content

Commit

Permalink
Merge pull request #60 from Recras/php84
Browse files Browse the repository at this point in the history
PHP 8.4 compatibility
  • Loading branch information
timmipetit authored Dec 6, 2024
2 parents 1f8f84f + 0c743e4 commit dff4c17
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 34 deletions.
14 changes: 7 additions & 7 deletions lib/Doctrine/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* @param Doctrine_Table<T>|class-string<T> $table
* @param string|null $keyColumn
*/
public function __construct($table, $keyColumn = null)
public function __construct($table, ?string $keyColumn = null)
{
if ( ! ($table instanceof Doctrine_Table)) {
$table = Doctrine_Core::getTable($table);
Expand Down Expand Up @@ -125,7 +125,7 @@ public static function initNullObject(Doctrine_Null $null)
* @throws Doctrine_Manager_Exception
* @throws Doctrine_Connection_Exception
*/
public static function create($table, $keyColumn = null, $class = null)
public static function create($table, ?string$keyColumn = null, ?string $class = null)
{
if (is_null($class)) {
if ( ! $table instanceof Doctrine_Table) {
Expand Down Expand Up @@ -465,7 +465,7 @@ public function set($key, $record)
* @param string $key optional key for the record
* @return boolean
*/
public function add($record, $key = null)
public function add($record, ?string $key = null)
{
if (isset($this->referenceField)) {
$value = $this->reference->get($this->relation->getLocalFieldName());
Expand Down Expand Up @@ -542,7 +542,7 @@ public function merge(Doctrine_Collection $coll)
* @param string|null $name
* @return Doctrine_Query|void
*/
public function loadRelated($name = null)
public function loadRelated(?string $name = null)
{
$list = array();
$query = $this->_table->createQuery();
Expand Down Expand Up @@ -923,7 +923,7 @@ protected function compareRecords($a, $b)
* @param bool $processDiff
* @return $this
*/
public function save(Doctrine_Connection $conn = null, $processDiff = true)
public function save(?Doctrine_Connection $conn = null, bool $processDiff = true)
{
if ($conn == null) {
$conn = $this->_table->getConnection();
Expand Down Expand Up @@ -959,7 +959,7 @@ public function save(Doctrine_Connection $conn = null, $processDiff = true)
* @param bool $processDiff
* @return $this
*/
public function replace(Doctrine_Connection $conn = null, $processDiff = true)
public function replace(?Doctrine_Connection $conn = null, bool $processDiff = true)
{
if ($conn == null) {
$conn = $this->_table->getConnection();
Expand Down Expand Up @@ -994,7 +994,7 @@ public function replace(Doctrine_Connection $conn = null, $processDiff = true)
* @param bool $clearColl
* @return $this
*/
public function delete(Doctrine_Connection $conn = null, $clearColl = true)
public function delete(?Doctrine_Connection $conn = null, bool $clearColl = true)
{
if ($conn == null) {
$conn = $this->_table->getConnection();
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Locator.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Doctrine_Locator implements Countable, IteratorAggregate
*
* @param array
*/
public function __construct(array $defaults = null)
public function __construct(?array $defaults = null)
{
if (null !== $defaults) {
foreach ($defaults as $name => $resource) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ public function query($query, $params = array(), $hydrationMode = null)
* @return Doctrine_Query Copy of the Doctrine_Query instance.
* @phpstan-return Doctrine_Query<T>
*/
public function copy(Doctrine_Query $query = null)
public function copy(?Doctrine_Query $query = null)
{
if ( ! $query) {
$query = $this;
Expand Down Expand Up @@ -2319,4 +2319,4 @@ public function fromComponent(string $componentname, string $componentalias)
{
return $this->from($componentname . ' ' . $componentalias);
}
}
}
4 changes: 2 additions & 2 deletions lib/Doctrine/Query/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ abstract class Doctrine_Query_Abstract
* @param Doctrine_Connection The connection object the query will use.
* @param Doctrine_Hydrator_Abstract The hydrator that will be used for generating result sets.
*/
public function __construct(Doctrine_Connection $connection = null,
Doctrine_Hydrator_Abstract $hydrator = null)
public function __construct(?Doctrine_Connection $connection = null,
?Doctrine_Hydrator_Abstract $hydrator = null)
{
if ($connection === null) {
$connection = Doctrine_Manager::getInstance()->getCurrentConnection();
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Query/Part.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class Doctrine_Query_Part
/**
* @param Doctrine_Query $query the query object associated with this parser
*/
public function __construct($query, Doctrine_Query_Tokenizer $tokenizer = null)
public function __construct($query, ?Doctrine_Query_Tokenizer $tokenizer = null)
{
$this->query = $query;

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/RawSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
* @param Doctrine_Connection $connection The connection object the query will use.
* @param Doctrine_Hydrator_Abstract $hydrator The hydrator that will be used for generating result sets.
*/
function __construct(Doctrine_Connection $connection = null, Doctrine_Hydrator_Abstract $hydrator = null) {
function __construct(?Doctrine_Connection $connection = null, ?Doctrine_Hydrator_Abstract $hydrator = null) {
parent::__construct($connection, $hydrator);

// Fix #1472. It's alid to disable QueryCache since there's no DQL for RawSql.
Expand Down
10 changes: 5 additions & 5 deletions lib/Doctrine/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public function oid()
* @param Doctrine_Event $event event raised
* @return Doctrine_Event the event generated using the type, if not specified
*/
public function invokeSaveHooks(string $when, string $type, Doctrine_Event $event = null)
public function invokeSaveHooks(string $when, string $type, ? Doctrine_Event $event = null)
{
$func = $when . ucfirst($type);

Expand Down Expand Up @@ -1766,7 +1766,7 @@ public function resetPendingUnlinks()
* @param Doctrine_Connection $conn optional connection parameter
* @throws Exception if record is not valid and validation is active
*/
public function save(Doctrine_Connection $conn = null)
public function save(?Doctrine_Connection $conn = null)
{
if ($conn === null) {
$conn = $this->_table->getConnection();
Expand All @@ -1783,7 +1783,7 @@ public function save(Doctrine_Connection $conn = null)
* @param Doctrine_Connection $conn optional connection parameter
* @return TRUE if the record was saved sucessfully without errors, FALSE otherwise.
*/
public function trySave(Doctrine_Connection $conn = null) {
public function trySave(?Doctrine_Connection $conn = null) {
try {
$this->save($conn);
return true;
Expand All @@ -1809,7 +1809,7 @@ public function trySave(Doctrine_Connection $conn = null) {
* @throws Doctrine_Connection_Exception if something fails at database level
* @return integer number of rows affected
*/
public function replace(Doctrine_Connection $conn = null)
public function replace(?Doctrine_Connection $conn = null)
{
if ($conn === null) {
$conn = $this->_table->getConnection();
Expand Down Expand Up @@ -2210,7 +2210,7 @@ public function getIterator()
*
* @return boolean true if successful
*/
public function delete(Doctrine_Connection $conn = null)
public function delete(?Doctrine_Connection $conn = null)
{
if ($conn == null) {
$conn = $this->_table->getConnection();
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -2043,7 +2043,7 @@ public function enumIndex($fieldName, $value)
* @phpstan-param T $record
* @return Doctrine_Validator_ErrorStack $errorStack
*/
public function validateField($fieldName, $value, Doctrine_Record $record = null)
public function validateField($fieldName, $value, ?Doctrine_Record $record = null)
{
if ($record instanceof Doctrine_Record) {
$errorStack = $record->getErrorStack();
Expand Down Expand Up @@ -2196,7 +2196,7 @@ public function removeColumn($fieldName)
* @param string[]|null $fieldNames
* @return array<int,string> numeric array
*/
public function getColumnNames(array $fieldNames = null)
public function getColumnNames(?array $fieldNames = null)
{
if ($fieldNames === null) {
return array_keys($this->_columns);
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Tree/Interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface Doctrine_Tree_Interface {
*
* @param Doctrine_Record $record instance of Doctrine_Record
*/
public function createRoot(Doctrine_Record $record = null);
public function createRoot(?Doctrine_Record $record = null);

/**
* returns root node
Expand All @@ -64,4 +64,4 @@ public function fetchTree($options = array(), $hydrationMode = null);
* @return iterator instance of Doctrine_Node_<Implementation>_PreOrderIterator
*/
public function fetchBranch($pk, $options = array(), $hydrationMode = null);
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/Tree/NestedSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function setTableDefinition(): void
*
* @param object $record instance of Doctrine_Record
*/
public function createRoot(Doctrine_Record $record = null)
public function createRoot(?Doctrine_Record $record = null)
{
if ($this->getAttribute('hasManyRoots')) {
if ( ! $record || ( ! $record->exists() && ! $record->getNode()->getRootValue())
Expand Down
4 changes: 2 additions & 2 deletions tests/DoctrineTest/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function shouldBeRun($testCase, $filter)
}
return true;
}
public function run(DoctrineTest_Reporter $reporter = null, $filter = null)
public function run(?DoctrineTest_Reporter $reporter = null, $filter = null)
{
set_time_limit(900);

Expand Down Expand Up @@ -107,4 +107,4 @@ public function getTestCases()
{
return $this->_testCases;
}
}
}
4 changes: 2 additions & 2 deletions tests/DoctrineTest/UnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function _fail($message = "")
self::$_passesAndFails['fails'][$class] = $class;
}

public function run(DoctrineTest_Reporter $reporter = null, $filter = null)
public function run(?DoctrineTest_Reporter $reporter = null, $filter = null)
{
foreach (get_class_methods($this) as $method) {
if (substr($method, 0, 4) === 'test') {
Expand Down Expand Up @@ -249,4 +249,4 @@ public function getNumFixedFails()
{
return count($this->getFixedFails());
}
}
}
4 changes: 2 additions & 2 deletions tests/Ticket/1830TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function init()
$this->prepareData();
}

public function run(DoctrineTest_Reporter $reporter = null, $filter = null)
public function run(?DoctrineTest_Reporter $reporter = null, $filter = null)
{
parent::run($reporter, $filter);
$this->manager->closeConnection($this->connection);
Expand Down Expand Up @@ -92,4 +92,4 @@ public function setUp()
$i18n0 = new Doctrine_Template_I18n(array('fields' => array(0 => 'title')));
$this->actAs($i18n0);
}
}
}
4 changes: 2 additions & 2 deletions tests/Ticket/1876bTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function init()
$this->prepareData();
}

public function run(DoctrineTest_Reporter $reporter = null, $filter = null)
public function run(?DoctrineTest_Reporter $reporter = null, $filter = null)
{
parent::run($reporter, $filter);
$this->manager->closeConnection($this->connection);
Expand Down Expand Up @@ -128,4 +128,4 @@ public function setUp() {

$this->actAs('SoftDelete');
}
}
}
2 changes: 1 addition & 1 deletion tests/Ticket/1935TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function init()
$this->prepareData();
}

public function run(DoctrineTest_Reporter $reporter = null, $filter = null)
public function run(?DoctrineTest_Reporter $reporter = null, $filter = null)
{
parent::run($reporter, $filter);
$this->manager->closeConnection($this->connection);
Expand Down
2 changes: 1 addition & 1 deletion tests/models/RecordHookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class RecordHookTest extends Doctrine_Record
{
protected $_messages = array();

public function setTableDefinition()
public function setTableDefinition(): void
{
$this->hasColumn('name', 'string', null, array('primary' => true));
}
Expand Down

0 comments on commit dff4c17

Please sign in to comment.