Skip to content

Commit

Permalink
Fixes deprecated warnings in PHP 8.4 (#1877)
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich authored Dec 4, 2024
1 parent 25ae9b1 commit 1bc2df6
Show file tree
Hide file tree
Showing 30 changed files with 79 additions and 79 deletions.
2 changes: 1 addition & 1 deletion src/Phing/ComponentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function addDataTypeDefinition($typeName, $typeClass, $classpath = null):
}
}

public static function getElementName(Project $p = null, $o = null, $brief = false)
public static function getElementName(?Project $p = null, $o = null, $brief = false)
{
return null === $p
? self::getUnmappedElementName($o, $brief)
Expand Down
4 changes: 2 additions & 2 deletions src/Phing/Exception/ExitStatusException.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class ExitStatusException extends BuildException
*
* @param null|int|string $arg1
* @param int $arg2
* @param Location $arg3
* @param Location|null $arg3
*/
public function __construct($arg1 = null, $arg2 = 0, Location $arg3 = null)
public function __construct($arg1 = null, $arg2 = 0, ?Location $arg3 = null)
{
$methodArgsNum = func_num_args();
if (1 === $methodArgsNum) {
Expand Down
4 changes: 2 additions & 2 deletions src/Phing/Filter/ConcatFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ class ConcatFilter extends BaseParamFilterReader implements ChainableReader
private $appendReader;

/**
* @param Reader $in
* @param Reader|null $in
*/
public function __construct(Reader $in = null)
public function __construct(?Reader $in = null)
{
parent::__construct($in);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Phing/Filter/SortFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ class SortFilter extends BaseParamFilterReader implements ChainableReader
/**
* Creates a new filtered reader.
*
* @param Reader $in
* @param Reader|null $in
* A Reader object providing the underlying stream. Must not be
* <code>null</code>.
*/
public function __construct(Reader $in = null)
public function __construct(?Reader $in = null)
{
parent::__construct($in);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Phing/Io/FilterReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class FilterReader extends Reader
protected $in;

/**
* @param Reader $in
* @param Reader|null $in
*/
public function __construct(Reader $in = null)
public function __construct(?Reader $in = null)
{
$this->in = $in;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Phing/Listener/DefaultLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class DefaultLogger implements StreamRequiredBuildLogger
/**
* Construct a new default logger.
*/
public function __construct(Clock $clock = null)
public function __construct(?Clock $clock = null)
{
$this->projectTimerMap = new ProjectTimerMap();
if (null === $clock) {
Expand Down
2 changes: 1 addition & 1 deletion src/Phing/Listener/StatisticsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class StatisticsListener implements SubBuildListener
*/
private $statisticsReport;

public function __construct(Clock $clock = null)
public function __construct(?Clock $clock = null)
{
$this->projectTimerMap = new ProjectTimerMap();
$this->statisticsReport = new StatisticsReport();
Expand Down
2 changes: 1 addition & 1 deletion src/Phing/Listener/XmlLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class XmlLogger implements BuildLogger
/**
* Constructs a new BuildListener that logs build events to an XML file.
*/
public function __construct(Clock $clock = null)
public function __construct(?Clock $clock = null)
{
if (null === $clock) {
$this->clock = new DefaultClock();
Expand Down
16 changes: 8 additions & 8 deletions src/Phing/Phing.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ class Phing
<?xml version="1.0" encoding="UTF-8" ?>
<project name="" description="" default="">
<target name="" description="">
</target>
</project>
XML;
public const PHING_HOME = 'phing.home';
Expand Down Expand Up @@ -248,17 +248,17 @@ public static function fire($args): void
*
* This method encapsulates the complete build lifecycle.
*
* @param array $args the commandline args passed to phing shell script
* @param array $additionalUserProperties Any additional properties to be passed to Phing (alternative front-end might implement this).
* These additional properties will be available using the getDefinedProperty() method and will
* be added to the project's "user" properties
* @param array $args the commandline args passed to phing shell script
* @param array|null $additionalUserProperties Any additional properties to be passed to Phing (alternative front-end might implement this).
* These additional properties will be available using the getDefinedProperty() method and will
* be added to the project's "user" properties
*
* @throws Exception - if there is an error during build
*
* @see runBuild()
* @see execute()
*/
public static function start($args, array $additionalUserProperties = null)
public static function start($args, ?array $additionalUserProperties = null)
{
try {
$m = new self();
Expand Down
16 changes: 8 additions & 8 deletions src/Phing/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,11 @@ public function executeTarget($targetName)
/**
* Helper function.
*
* @param File $rootDir
* @param File|null $rootDir
*
* @throws IOException
*/
public function resolveFile(string $fileName, File $rootDir = null): File
public function resolveFile(string $fileName, ?File $rootDir = null): File
{
if (null === $rootDir) {
return $this->fileUtils->resolveFile($this->basedir, $fileName);
Expand Down Expand Up @@ -999,7 +999,7 @@ public function log($msg, $level = Project::MSG_INFO)
* @param int $level
* @param mixed $obj
*/
public function logObject($obj, $msg, $level, Exception $t = null)
public function logObject($obj, $msg, $level, ?Exception $t = null)
{
$this->fireMessageLogged($obj, $msg, $level, $t);

Expand Down Expand Up @@ -1128,14 +1128,14 @@ public function fireMessageLoggedEvent(BuildEvent $event, $message, $priority)
}

/**
* @param string $message
* @param int $priority
* @param Exception $t
* @param mixed $object
* @param string $message
* @param int $priority
* @param Exception|null $t
* @param mixed $object
*
* @throws Exception
*/
public function fireMessageLogged($object, $message, $priority, Exception $t = null)
public function fireMessageLogged($object, $message, $priority, ?Exception $t = null)
{
$event = new BuildEvent($object);
if (null !== $t) {
Expand Down
2 changes: 1 addition & 1 deletion src/Phing/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Target implements TaskContainer
private $project;
private $location;

public function __construct(Target $other = null)
public function __construct(?Target $other = null)
{
if (null !== $other) {
$this->name = $other->name;
Expand Down
2 changes: 1 addition & 1 deletion src/Phing/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function getWrapper()
* @see BuildEvent
* @see BuildListener
*/
public function log($msg, $level = Project::MSG_INFO, Exception $t = null)
public function log($msg, $level = Project::MSG_INFO, ?Exception $t = null)
{
if (null !== $this->getProject()) {
$this->getProject()->logObject($this, $msg, $level, $t);
Expand Down
4 changes: 2 additions & 2 deletions src/Phing/Task/Ext/GrowlNotifyTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ class GrowlNotifyTask extends Task
/**
* Initializes task with default options.
*
* @param Net_Growl $growl (optional) mock instance
* @param Net_Growl|null $growl (optional) mock instance
*/
public function __construct(Net_Growl $growl = null)
public function __construct(?Net_Growl $growl = null)
{
parent::__construct();
$this->growl = $growl;
Expand Down
2 changes: 1 addition & 1 deletion src/Phing/Task/Ext/Http/HttpGetTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function setQuiet($v): void
* @param int $msgLevel
* @param Exception|null $t
*/
public function log($msg, $msgLevel = Project::MSG_INFO, Exception $t = null)
public function log($msg, $msgLevel = Project::MSG_INFO, ?Exception $t = null)
{
if (!$this->quiet || $msgLevel <= Project::MSG_ERR) {
parent::log($msg, $msgLevel, $t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ public function addSkippedTest(Test $test, Throwable $e, float $time): void
/**
* @param $type
* @param Test $test
* @param Exception $e
* @param Exception|null $e
*/
private function formatError($type, Test $test, Exception $e = null)
private function formatError($type, Test $test, ?Exception $e = null)
{
if ($test != null) {
$this->endTest($test, time());
Expand Down
8 changes: 4 additions & 4 deletions src/Phing/Task/System/AppendTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,11 @@ private function getFilteredReader(Reader $r)
/**
* Append an array of files in a directory.
*
* @param Writer $writer the FileWriter that is appending to target file
* @param array $files array of files to delete; can be of zero length
* @param File $dir directory to work from
* @param Writer $writer the FileWriter that is appending to target file
* @param array $files array of files to delete; can be of zero length
* @param File|null $dir directory to work from
*/
private function appendFiles(Writer $writer, $files, File $dir = null): void
private function appendFiles(Writer $writer, $files, ?File $dir = null): void
{
if (!empty($files)) {
$this->log(
Expand Down
8 changes: 4 additions & 4 deletions src/Phing/Task/System/EchoProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,13 @@ protected function textSaveProperties(Properties $props, OutputStream $os, $head
}

/**
* @param Exception $exception
* @param string $message
* @param int $level
* @param Exception|null $exception
* @param string $message
* @param int $level
*
* @throws BuildException
*/
private function failOnErrorAction(Exception $exception = null, $message = '', $level = Project::MSG_INFO)
private function failOnErrorAction(?Exception $exception = null, $message = '', $level = Project::MSG_INFO)
{
if ($this->failonerror) {
throw new BuildException(
Expand Down
2 changes: 1 addition & 1 deletion src/Phing/Task/System/PhingTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class PhingTask extends Task
*/
private $locals;

public function __construct(Task $owner = null)
public function __construct(?Task $owner = null)
{
if (null !== $owner) {
$this->bindToOwner($owner);
Expand Down
4 changes: 2 additions & 2 deletions src/Phing/Task/System/PropertyTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ class PropertyTask extends Task
private $required = false;

/**
* @param FileParserFactoryInterface $fileParserFactory
* @param FileParserFactoryInterface|null $fileParserFactory
*/
public function __construct(FileParserFactoryInterface $fileParserFactory = null)
public function __construct(?FileParserFactoryInterface $fileParserFactory = null)
{
parent::__construct();
$this->fileParserFactory = $fileParserFactory ?? new FileParserFactory();
Expand Down
14 changes: 7 additions & 7 deletions src/Phing/Type/AbstractFileSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ public function setDir($dir)
}

/**
* @param Project $p
* @param Project|null $p
*
* @throws BuildException
*/
public function getDir(Project $p = null)
public function getDir(?Project $p = null)
{
if (null === $p) {
$p = $this->getProject();
Expand Down Expand Up @@ -368,13 +368,13 @@ public function setErrorOnMissingDir(bool $errorOnMissingDir)
/**
* returns a reference to the dirscanner object belonging to this fileset.
*
* @param Project $p
* @param Project|null $p
*
* @throws BuildException
*
* @return DirectoryScanner
*/
public function getDirectoryScanner(Project $p = null)
public function getDirectoryScanner(?Project $p = null)
{
if (null === $p) {
$p = $this->getProject();
Expand Down Expand Up @@ -406,7 +406,7 @@ public function getDirectoryScanner(Project $p = null)
return $ds;
}

public function dieOnCircularReference(&$stk, Project $p = null)
public function dieOnCircularReference(&$stk, ?Project $p = null)
{
if ($this->checked) {
return;
Expand Down Expand Up @@ -572,11 +572,11 @@ public function getIterator(...$options): ArrayIterator
/**
* feed dirscanner with infos defined by this fileset.
*
* @param Project $p
* @param Project|null $p
*
* @throws BuildException
*/
protected function setupDirectoryScanner(DirectoryScanner $ds, Project $p = null)
protected function setupDirectoryScanner(DirectoryScanner $ds, ?Project $p = null)
{
if (null === $p) {
$p = $this->getProject();
Expand Down
10 changes: 5 additions & 5 deletions src/Phing/Type/Commandline.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ public static function quoteArgument($argument, $escape = false)
/**
* Crack a command line.
*
* @param string $toProcess the command line to process
* @param string|null $toProcess the command line to process
*
* @throws BuildException
*
* @return string[] the command line broken into strings.
* An empty or null toProcess parameter results in a zero sized array.
*/
public static function translateCommandline(string $toProcess = null): array
public static function translateCommandline(?string $toProcess = null): array
{
if (null === $toProcess || '' === $toProcess) {
return [];
Expand Down Expand Up @@ -382,12 +382,12 @@ public function describeCommand($args = null)
* verbose output before a call to
* <code>Runtime.exec(String[])</code>.
*
* @param array $args arguments to use (default is to use current class args)
* @param int $offset ignore entries before this index
* @param array|null $args arguments to use (default is to use current class args)
* @param int $offset ignore entries before this index
*
* @return string
*/
public function describeArguments(array $args = null, $offset = 0)
public function describeArguments(?array $args = null, $offset = 0)
{
if (null === $args) {
$args = $this->getArguments();
Expand Down
6 changes: 3 additions & 3 deletions src/Phing/Type/DataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ public function setChecked($checked)
* The general contract of this method is that it shouldn't do
* anything if checked is true and set it to true on exit.
*
* @param array $stk
* @param Project $p
* @param array $stk
* @param Project|null $p
*
* @throws BuildException
*/
public function dieOnCircularReference(&$stk, Project $p = null)
public function dieOnCircularReference(&$stk, ?Project $p = null)
{
if ($this->checked || !$this->isReference()) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/Phing/Type/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,12 @@ public function size()
* Overrides the version of DataType to recurse on all DataType
* child elements that may have been added.
*
* @param array $stk
* @param Project $p
* @param array $stk
* @param Project|null $p
*
* @throws BuildException
*/
public function dieOnCircularReference(&$stk, Project $p = null)
public function dieOnCircularReference(&$stk, ?Project $p = null)
{
if ($this->checked) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Phing/Type/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getProject(): Phing\Project
*
* @return object
*/
public function getReferencedObject(Project $fallback = null)
public function getReferencedObject(?Project $fallback = null)
{
$project = $fallback ?? $this->project;

Expand Down
Loading

0 comments on commit 1bc2df6

Please sign in to comment.