Skip to content

Commit

Permalink
Merge pull request #101 from xavierleune/fix/php84
Browse files Browse the repository at this point in the history
Fix for PHP8.4: Implicitly marking parameter %s as nullable is deprecated
  • Loading branch information
vgreb authored Jan 9, 2025
2 parents 94e9d2e + 8f6a43b commit 2e99f2b
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 34 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
3.10.1 (unreleased):
* Fix for PHP8.4: "Implicitly marking parameter %s as nullable is deprecated"

3.10.0 (2025-01-06):
* Drop PHP 7
* Remove hard dependency to pimple, add it in suggest
Expand Down
2 changes: 1 addition & 1 deletion src/Ting/ConnectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ConnectionPool implements ConnectionPoolInterface
/**
* @param DriverLoggerInterface $logger
*/
public function __construct(DriverLoggerInterface $logger = null)
public function __construct(?DriverLoggerInterface $logger = null)
{
$this->logger = $logger;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Ting/Driver/DriverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function setCharset($charset);
* @return mixed
* @throws QueryException
*/
public function execute($sql, array $params = [], CollectionInterface $collection = null);
public function execute($sql, array $params = [], ?CollectionInterface $collection = null);

/**
* @param string $sql
Expand Down Expand Up @@ -114,7 +114,7 @@ public function getInsertedId();
*/
public function getAffectedRows();

public function setLogger(DriverLoggerInterface $logger = null);
public function setLogger(?DriverLoggerInterface $logger = null);

/**
* @param array $connectionConfig
Expand Down
4 changes: 2 additions & 2 deletions src/Ting/Driver/Mysqli/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function setCharset($charset)
/**
* @param DriverLoggerInterface $logger
*/
public function setLogger(DriverLoggerInterface $logger = null)
public function setLogger(?DriverLoggerInterface $logger = null)
{
$this->logger = $logger;
$this->objectHash = spl_object_hash($this);
Expand Down Expand Up @@ -269,7 +269,7 @@ public function ifIsError(callable $callback)
* @return mixed|CollectionInterface
* @throws QueryException
*/
public function execute($sql, array $params = [], CollectionInterface $collection = null)
public function execute($sql, array $params = [], ?CollectionInterface $collection = null)
{
$sql = preg_replace_callback(
'/' . $this->parameterMatching . '/',
Expand Down
4 changes: 2 additions & 2 deletions src/Ting/Driver/Mysqli/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(protected $driverStatement, array $paramsOrder, prot
* @return bool|CollectionInterface
* @throws QueryException
*/
public function execute(array $params, CollectionInterface $collection = null)
public function execute(array $params, ?CollectionInterface $collection = null)
{
$types = '';
$values = [];
Expand Down Expand Up @@ -114,7 +114,7 @@ public function execute(array $params, CollectionInterface $collection = null)
* @param DriverLoggerInterface $logger
* @return void
*/
public function setLogger(DriverLoggerInterface $logger = null)
public function setLogger(?DriverLoggerInterface $logger = null)
{
if ($logger !== null) {
$this->logger = $logger;
Expand Down
4 changes: 2 additions & 2 deletions src/Ting/Driver/Pgsql/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function setDatabase($database)
return $this;
}

public function setLogger(DriverLoggerInterface $logger = null)
public function setLogger(?DriverLoggerInterface $logger = null)
{
$this->logger = $logger;
$this->objectHash = spl_object_hash($this);
Expand All @@ -204,7 +204,7 @@ public function setLogger(DriverLoggerInterface $logger = null)
* @return CollectionInterface|mixed|resource
* @throws QueryException
*/
public function execute($originalSQL, array $params = [], CollectionInterface $collection = null)
public function execute($originalSQL, array $params = [], ?CollectionInterface $collection = null)
{
[$sql, $paramsOrder] = $this->convertParameters($originalSQL);

Expand Down
6 changes: 3 additions & 3 deletions src/Ting/Driver/Pgsql/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function setQuery($query)
* @param DriverLoggerInterface $logger
* @return void
*/
public function setLogger(DriverLoggerInterface $logger = null)
public function setLogger(?DriverLoggerInterface $logger = null)
{
$this->logger = $logger;
}
Expand All @@ -98,7 +98,7 @@ public function setLogger(DriverLoggerInterface $logger = null)
* @return bool|mixed
* @throws QueryException
*/
public function execute(array $params, CollectionInterface $collection = null)
public function execute(array $params, ?CollectionInterface $collection = null)
{
$values = [];
foreach (array_keys($this->paramsOrder) as $key) {
Expand Down Expand Up @@ -132,7 +132,7 @@ public function execute(array $params, CollectionInterface $collection = null)
*
* @internal
*/
public function setCollectionWithResult($resultResource, CollectionInterface $collection = null)
public function setCollectionWithResult($resultResource, ?CollectionInterface $collection = null)
{
$result = new Result();
$result->setConnectionName($this->connectionName);
Expand Down
4 changes: 2 additions & 2 deletions src/Ting/Driver/StatementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public function __construct($driverStatement, array $paramsOrder, $connectionNam
* @return mixed
* @throws QueryException
*/
public function execute(array $params, CollectionInterface $collection = null);
public function execute(array $params, ?CollectionInterface $collection = null);

/**
* @param DriverLoggerInterface $logger
* @return void
*/
public function setLogger(DriverLoggerInterface $logger = null);
public function setLogger(?DriverLoggerInterface $logger = null);
}
6 changes: 3 additions & 3 deletions src/Ting/MetadataRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function findMetadataForTable(
$schema,
$table,
\Closure $callbackFound,
\Closure $callbackNotFound = null
?\Closure $callbackNotFound = null
) {

$connectionKey = $connectionName . '#' . $table;
Expand Down Expand Up @@ -116,7 +116,7 @@ public function findMetadataForTable(
public function findMetadataForRepository(
$repositoryName,
\Closure $callbackFound,
\Closure $callbackNotFound = null
?\Closure $callbackNotFound = null
) {
if (isset($this->metadataList[$repositoryName]) === true) {
$callbackFound($this->metadataList[$repositoryName]);
Expand All @@ -134,7 +134,7 @@ public function findMetadataForRepository(
*
* @internal
*/
public function findMetadataForEntity($entity, \Closure $callbackFound, \Closure $callbackNotFound = null)
public function findMetadataForEntity($entity, \Closure $callbackFound, ?\Closure $callbackNotFound = null)
{
if (is_object($entity)) {
$entity = $entity::class;
Expand Down
2 changes: 1 addition & 1 deletion src/Ting/Query/Cached/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function prepareExecute()
* @return CollectionInterface
* @throws QueryException
*/
public function query(CollectionInterface $collection = null)
public function query(?CollectionInterface $collection = null)
{
$this->checkTtl();

Expand Down
2 changes: 1 addition & 1 deletion src/Ting/Query/Cached/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function setForce($value)
* @throws Exception
* @throws QueryException
*/
public function query(CollectionInterface $collection = null)
public function query(?CollectionInterface $collection = null)
{
$this->checkTtl();

Expand Down
2 changes: 1 addition & 1 deletion src/Ting/Query/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function prepareExecute()
* @return CollectionInterface
* @throws QueryException
*/
public function query(CollectionInterface $collection = null)
public function query(?CollectionInterface $collection = null)
{
if ($collection === null) {
$collection = $this->collectionFactory->get();
Expand Down
4 changes: 2 additions & 2 deletions src/Ting/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Query implements QueryInterface
* @param Connection $connection
* @param CollectionFactoryInterface $collectionFactory
*/
public function __construct(protected $sql, Connection $connection, CollectionFactoryInterface $collectionFactory = null)
public function __construct(protected $sql, Connection $connection, ?CollectionFactoryInterface $collectionFactory = null)
{
$this->connection = $connection;
$this->collectionFactory = $collectionFactory;
Expand Down Expand Up @@ -92,7 +92,7 @@ public function setParams(array $params)
* @throws Exception
* @throws QueryException
*/
public function query(CollectionInterface $collection = null)
public function query(?CollectionInterface $collection = null)
{
if ($collection === null) {
$collection = $this->collectionFactory->get();
Expand Down
8 changes: 4 additions & 4 deletions src/Ting/Query/QueryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class QueryFactory implements QueryFactoryInterface
* @param CollectionFactoryInterface $collectionFactory
* @return Query
*/
public function get($sql, Connection $connection, CollectionFactoryInterface $collectionFactory = null)
public function get($sql, Connection $connection, ?CollectionFactoryInterface $collectionFactory = null)
{
return new Query($sql, $connection, $collectionFactory);
}
Expand All @@ -48,7 +48,7 @@ public function get($sql, Connection $connection, CollectionFactoryInterface $co
* @param CollectionFactoryInterface $collectionFactory
* @return PreparedQuery
*/
public function getPrepared($sql, Connection $connection, CollectionFactoryInterface $collectionFactory = null)
public function getPrepared($sql, Connection $connection, ?CollectionFactoryInterface $collectionFactory = null)
{
return new PreparedQuery($sql, $connection, $collectionFactory);
}
Expand All @@ -64,7 +64,7 @@ public function getCached(
$sql,
Connection $connection,
Cache $cache,
CollectionFactoryInterface $collectionFactory = null
?CollectionFactoryInterface $collectionFactory = null
) {
$cachedQuery = new Cached\Query($sql, $connection, $collectionFactory);
$cachedQuery->setCache($cache);
Expand All @@ -82,7 +82,7 @@ public function getCachedPrepared(
$sql,
Connection $connection,
Cache $cache,
CollectionFactoryInterface $collectionFactory = null
?CollectionFactoryInterface $collectionFactory = null
) {
$cachedPreparedQuery = new Cached\PreparedQuery($sql, $connection, $collectionFactory);
$cachedPreparedQuery->setCache($cache);
Expand Down
8 changes: 4 additions & 4 deletions src/Ting/Query/QueryFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ interface QueryFactoryInterface
* @param CollectionFactoryInterface $collectionFactory
* @return Query
*/
public function get($sql, Connection $connection, CollectionFactoryInterface $collectionFactory = null);
public function get($sql, Connection $connection, ?CollectionFactoryInterface $collectionFactory = null);

/**
* @param string $sql
* @param Connection $connection
* @param CollectionFactoryInterface $collectionFactory
* @return PreparedQuery
*/
public function getPrepared($sql, Connection $connection, CollectionFactoryInterface $collectionFactory = null);
public function getPrepared($sql, Connection $connection, ?CollectionFactoryInterface $collectionFactory = null);

/**
* @param string $sql
Expand All @@ -58,7 +58,7 @@ public function getCached(
$sql,
Connection $connection,
Cache $cache,
CollectionFactoryInterface $collectionFactory = null
?CollectionFactoryInterface $collectionFactory = null
);

/**
Expand All @@ -72,6 +72,6 @@ public function getCachedPrepared(
$sql,
Connection $connection,
Cache $cache,
CollectionFactoryInterface $collectionFactory = null
?CollectionFactoryInterface $collectionFactory = null
);
}
4 changes: 2 additions & 2 deletions src/Ting/Query/QueryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface QueryInterface
* @param Connection $connection
* @param CollectionFactoryInterface $collectionFactory
*/
public function __construct($sql, Connection $connection, CollectionFactoryInterface $collectionFactory = null);
public function __construct($sql, Connection $connection, ?CollectionFactoryInterface $collectionFactory = null);

/**
* Execute a reading query (SELECT, SHOW, etc.)
Expand All @@ -46,7 +46,7 @@ public function __construct($sql, Connection $connection, CollectionFactoryInter
*
* @template T of object
*/
public function query(CollectionInterface $collection = null);
public function query(?CollectionInterface $collection = null);

/**
* Execute a writing query (UPDATE, INSERT, etc.)
Expand Down
2 changes: 1 addition & 1 deletion src/Ting/Repository/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function () use ($class): void {
*
* @template U
*/
public function getCollection(HydratorInterface $hydrator = null)
public function getCollection(?HydratorInterface $hydrator = null)
{
return $this->collectionFactory->get($hydrator);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Ting/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function set($id, \Closure $callable, $factory = false)
return $this;
}

public function get($id, array $options = null)
public function get($id, ?array $options = null)
{
if ($options !== null) {
if (isset($this->serviceOptions[$id]) && $this->serviceOptions[$id] !== $options) {
Expand Down

0 comments on commit 2e99f2b

Please sign in to comment.