Skip to content

Commit

Permalink
Fix a few PHP 8.4 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
mrook committed Feb 18, 2025
1 parent b66666c commit c1512fb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/Phing/Parser/ExpatParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public function __construct(Reader $reader, $filename = null)
}
$this->parser = xml_parser_create();
$this->location = new Location();
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, [$this, 'startElement'], [$this, 'endElement']);
xml_set_character_data_handler($this->parser, [$this, 'characters']);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Phing/Task/Ext/PhpUnit/PHPUnitTestRunner9.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function run(TestSuite $suite)

/* Set PHPUnit error handler */
if ($this->useCustomErrorHandler) {
set_error_handler([$this, 'handleError'], E_ALL | E_STRICT);
set_error_handler([$this, 'handleError']);
}

$this->injectFilters($suite);
Expand Down
5 changes: 3 additions & 2 deletions src/Phing/Util/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Phing\Util;

use http\Exception\RuntimeException;
use function filter_var;
use function is_bool;
use function is_string;
Expand Down Expand Up @@ -148,10 +149,10 @@ public static function substring($string, $startpos, $endpos = -1)
$len = strlen($string);
$endpos = (int) ((-1 === $endpos) ? $len - 1 : $endpos);
if ($startpos > $len - 1 || $startpos < 0) {
trigger_error("substring(), Startindex out of bounds must be 0<n<{$len}", E_USER_ERROR);
throw new \RuntimeException("substring(), Startindex out of bounds must be 0<n<{$len}");
}
if ($endpos > $len - 1 || $endpos < $startpos) {
trigger_error("substring(), Endindex out of bounds must be {$startpos}<n<" . ($len - 1), E_USER_ERROR);
throw new \RuntimeException("substring(), Endindex out of bounds must be {$startpos}<n<" . ($len - 1));
}
if ($startpos === $endpos) {
return (string) $string[$startpos];
Expand Down
2 changes: 1 addition & 1 deletion tests/Phing/Test/Task/Optional/RSTTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class RSTTaskTest extends BuildFileTest
public function setUp(): void
{
//needed for PEAR's System class
error_reporting(error_reporting() & ~E_STRICT & ~E_DEPRECATED);
error_reporting(error_reporting() & ~E_DEPRECATED);

chdir(PHING_TEST_BASE . '/etc/tasks/ext/rst');
$this->configureProject(
Expand Down
4 changes: 2 additions & 2 deletions tests/Phing/Test/Util/StringHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ public function substringProvider()
*/
public function testSubstringError($string, $start, $end, $message)
{
$this->expectError();
$this->expectErrorMessage($message);
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage($message);
StringHelper::substring($string, $start, $end);
}

Expand Down

0 comments on commit c1512fb

Please sign in to comment.