Skip to content

PHP8.4 upgrade#2

Open
oleche wants to merge 5 commits into
php7from
php8
Open

PHP8.4 upgrade#2
oleche wants to merge 5 commits into
php7from
php8

Conversation

@oleche
Copy link
Copy Markdown

@oleche oleche commented Jan 12, 2026

Summary of Changes

The upgrade involves the following categories of changes:

  1. Interface Method Signatures - Adding return types to match PHP 8.4 requirements
  2. Nullable Parameter Types - Using explicit ?Type syntax instead of implicit = null
  3. Serializable Interface - Replacing deprecated Serializable interface with __serialize() and __unserialize()
  4. Iterator Interface - Adding proper return types to Iterator methods
  5. Countable Interface - Adding int return type to count() methods
  6. ArrayAccess Interface - Adding proper return types to offset methods
  7. IteratorAggregate Interface - Adding \Traversable return type to getIterator()
  8. __toString() Method - Adding string return type
  9. Deprecated Features - Fixing deprecated language constructs
  10. Method Signature Compatibility - Ensuring child classes match parent signatures

Detailed Changes by File

lib/Doctrine/Access.php

  • offsetExists($offset)offsetExists(mixed $offset): bool
  • offsetGet($offset)offsetGet(mixed $offset): mixed
  • offsetSet($offset, $value)offsetSet(mixed $offset, mixed $value): void
  • offsetUnset($offset)offsetUnset(mixed $offset): void
  • Changed return $this->remove($offset) to just $this->remove($offset) in offsetUnset() (void return)

lib/Doctrine/Adapter/Mock.php

  • count()count(): int

lib/Doctrine/AuditLog.php

  • setTableDefinition()setTableDefinition(): void

lib/Doctrine/Cli.php

  • __construct(array $config = array(), Doctrine_Cli_Formatter $formatter = null)__construct(array $config = array(), ?Doctrine_Cli_Formatter $formatter = null)

lib/Doctrine/Cli/AnsiColorFormatter.php

  • Fixed string interpolation: ">> %-${width}s %s"">> %-{$width}s %s"

lib/Doctrine/Collection.php

  • Removed Serializable from implements clause
  • serialize()__serialize(): array (returns array instead of string)
  • unserialize($serialized)__unserialize(array $data): void
  • key()key(): mixed
  • count()count(): int
  • save(Doctrine_Connection $conn = null, ...)save(?Doctrine_Connection $conn = null, ...)
  • replace(Doctrine_Connection $conn = null, ...)replace(?Doctrine_Connection $conn = null, ...)
  • delete(Doctrine_Connection $conn = null, ...)delete(?Doctrine_Connection $conn = null, ...)
  • getIterator()getIterator(): \Traversable
  • __toString()__toString(): string

lib/Doctrine/Collection/Iterator.php

  • rewind()rewind(): void
  • key()key(): mixed
  • current()current(): mixed
  • next()next(): void

lib/Doctrine/Collection/Iterator/Expandable.php

  • valid()valid(): bool
  • Added missing return false; at end of method

lib/Doctrine/Collection/Iterator/Normal.php

  • valid()valid(): bool

lib/Doctrine/Collection/Iterator/Offset.php

  • valid()valid(): bool
  • Added method body with return false;

lib/Doctrine/Collection/Offset.php

  • getIterator()getIterator(): \Traversable

lib/Doctrine/Collection/OnDemand.php

  • rewind()rewind(): void
  • key()key(): mixed
  • current()current(): mixed
  • next()next(): void
  • valid()valid(): bool

lib/Doctrine/Column.php

  • count()count(): int
  • getIterator()getIterator(): \Traversable

lib/Doctrine/Connection.php

  • Removed Serializable from implements clause
  • Added protected $exported = array(); property
  • getIterator()getIterator(): \Traversable
  • count()count(): int
  • __toString()__toString(): string
  • serialize()__serialize(): array
  • unserialize($serialized)__unserialize(array $data): void

lib/Doctrine/Connection/Profiler.php

  • getIterator()getIterator(): \Traversable
  • count()count(): int

lib/Doctrine/Connection/Statement.php

  • Fixed nullable parameter handling in fetch() method

lib/Doctrine/Expression.php

  • count()count(): int

lib/Doctrine/File.php

  • setUp()setUp(): void

lib/Doctrine/File/Index.php

  • setTableDefinition()setTableDefinition(): void
  • setUp()setUp(): void

lib/Doctrine/Formatter.php

  • Added null coalescing for str_replace() parameter

lib/Doctrine/Hydrator/Graph.php

  • Fixed dynamic property creation deprecation

lib/Doctrine/I18n.php

  • setTableDefinition()setTableDefinition(): void

lib/Doctrine/Import/Builder.php

  • Generated setTableDefinition() now includes : void return type
  • Generated setUp() now includes : void return type

lib/Doctrine/Locator.php

  • count()count(): int
  • getIterator()getIterator(): \Traversable

lib/Doctrine/Manager.php

  • Removed Serializable from implements clause
  • count()count(): int
  • getIterator()getIterator(): \Traversable
  • __toString()__toString(): string
  • serialize()__serialize(): array
  • unserialize($serialized)__unserialize(array $data): void

lib/Doctrine/Node.php

  • getIterator($type = null, $options = null)getIterator($type = null, $options = null): \Traversable

lib/Doctrine/Node/MaterializedPath/LevelOrderIterator.php

  • rewind()rewind(): void
  • key()key(): mixed
  • current()current(): mixed
  • next()next(): void
  • valid()valid(): bool

lib/Doctrine/Node/MaterializedPath/PostOrderIterator.php

  • rewind()rewind(): void
  • key()key(): mixed
  • current()current(): mixed
  • next()next(): void
  • valid()valid(): bool

lib/Doctrine/Node/MaterializedPath/PreOrderIterator.php

  • rewind()rewind(): void
  • key()key(): mixed
  • current()current(): mixed
  • next()next(): void
  • valid()valid(): bool

lib/Doctrine/Node/NestedSet/PreOrderIterator.php

  • rewind()rewind(): void
  • key()key(): mixed
  • current()current(): mixed
  • next()next(): void
  • valid()valid(): bool

lib/Doctrine/Null.php

  • count()count(): int

lib/Doctrine/Pager/Layout.php

  • count()count(): int

lib/Doctrine/Query.php

  • count(array $params = array())count(array $params = array()): int

lib/Doctrine/Query/Abstract.php

  • Fixed nullable parameter types
  • getIterator()getIterator(): \Traversable

lib/Doctrine/Query/Having.php

  • count()count(): int

lib/Doctrine/Query/Part.php

  • count()count(): int

lib/Doctrine/Query/Tokenizer.php

  • Changed continue to continue 2 where targeting switch inside loop

lib/Doctrine/RawSql.php

  • Changed continue to continue 2 where targeting switch inside loop

lib/Doctrine/Record.php

  • Removed Serializable from implements clause
  • serialize()__serialize(): array
  • unserialize($serialized)__unserialize(array $data): void
  • count()count(): int
  • getIterator()getIterator(): \Traversable
  • __toString()__toString(): string
  • Fixed $_invokedSaveHooks initialization from false to []
  • Various nullable parameter type fixes

lib/Doctrine/Record/Abstract.php

  • setTableDefinition()setTableDefinition(): void
  • setUp()setUp(): void

lib/Doctrine/Record/Iterator.php

  • rewind()rewind(): void
  • key()key(): mixed
  • current()current(): mixed
  • next()next(): void
  • valid()valid(): bool

lib/Doctrine/Relation.php

  • count()count(): int
  • getIterator()getIterator(): \Traversable
  • __toString()__toString(): string

lib/Doctrine/Search.php

  • setTableDefinition()setTableDefinition(): void

lib/Doctrine/Search/Record.php

  • setTableDefinition()setTableDefinition(): void
  • setUp()setUp(): void

lib/Doctrine/Table.php

  • count()count(): int
  • __toString()__toString(): string
  • validateField($fieldName, $value, Doctrine_Record $record = null)validateField($fieldName, $value, ?Doctrine_Record $record = null)
  • getColumnNames(array $fieldNames = null)getColumnNames(?array $fieldNames = null)
  • Fixed explode() with null parameter using null coalescing

lib/Doctrine/Table/Repository.php

  • count()count(): int
  • getIterator()getIterator(): \Traversable

lib/Doctrine/Template.php

  • setUp()setUp(): void
  • setTableDefinition()setTableDefinition(): void

lib/Doctrine/Template/Geographical.php

  • setTableDefinition()setTableDefinition(): void

lib/Doctrine/Template/I18n.php

  • setUp()setUp(): void

lib/Doctrine/Template/NestedSet.php

  • setUp()setUp(): void
  • setTableDefinition()setTableDefinition(): void

lib/Doctrine/Template/Searchable.php

  • setUp()setUp(): void

lib/Doctrine/Template/Sluggable.php

  • setTableDefinition()setTableDefinition(): void

lib/Doctrine/Template/SoftDelete.php

  • setTableDefinition()setTableDefinition(): void

lib/Doctrine/Template/Timestampable.php

  • setTableDefinition()setTableDefinition(): void

lib/Doctrine/Template/Versionable.php

  • setUp()setUp(): void

lib/Doctrine/Tree.php

  • setTableDefinition()setTableDefinition(): void

lib/Doctrine/Tree/Interface.php

  • createRoot(Doctrine_Record $record = null)createRoot(?Doctrine_Record $record = null)

lib/Doctrine/Tree/NestedSet.php

  • setTableDefinition()setTableDefinition(): void
  • createRoot(Doctrine_Record $record = null)createRoot(?Doctrine_Record $record = null)

lib/Doctrine/Validator.php

  • Added array type check before string casting in isValidType() to prevent "Array to string conversion" warning

lib/Doctrine/Validator/Driver.php

  • __toString()__toString(): string

lib/Doctrine/Validator/ErrorStack.php

  • getIterator()getIterator(): \Traversable
  • count()count(): int

lib/Doctrine/Validator/Exception.php

  • getIterator()getIterator(): \Traversable
  • count()count(): int

lib/Doctrine/Validator/Notblank.php

  • Fixed order of null check to prevent trim() on null

Breaking Changes

These changes maintain backward compatibility for user code, but any code that extends Doctrine classes may need to update method signatures to match the new return types.

Classes extending Doctrine_Record

Child classes must update:

  • setTableDefinition()setTableDefinition(): void
  • setUp()setUp(): void

Classes extending Doctrine_Template

Child classes must update:

  • setTableDefinition()setTableDefinition(): void
  • setUp()setUp(): void

Classes implementing Iterator

Must add return types to all Iterator methods:

  • rewind(): void
  • current(): mixed
  • key(): mixed
  • next(): void
  • valid(): bool

Classes implementing Countable

Must add return type:

  • count(): int

Classes implementing IteratorAggregate

Must add return type:

  • getIterator(): \Traversable

Classes implementing ArrayAccess

Must add return types:

  • offsetExists(mixed $offset): bool
  • offsetGet(mixed $offset): mixed
  • offsetSet(mixed $offset, mixed $value): void
  • offsetUnset(mixed $offset): void

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant