Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- "8.3"
- "8.4"
- "8.5"
- "8.6"
php_invoker: [true, false]
coverage: [false]
experimental: [false]
Expand Down
1 change: 1 addition & 0 deletions PHPUnit/Autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ function ($class)
'phpunit_util_getopt' => '/Util/Getopt.php',
'phpunit_util_globalstate' => '/Util/GlobalState.php',
'phpunit_util_invalidargumenthelper' => '/Util/InvalidArgumentHelper.php',
'phpunit_util_invoker' => '/Util/Invoker.php',
'phpunit_util_log_json' => '/Util/Log/JSON.php',
'phpunit_util_log_junit' => '/Util/Log/JUnit.php',
'phpunit_util_log_tap' => '/Util/Log/TAP.php',
Expand Down
2 changes: 1 addition & 1 deletion PHPUnit/Extensions/RepeatedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function __construct(PHPUnit_Framework_Test $test, $timesRepeat = 1, $fil
{
parent::__construct($test);

if (is_integer($timesRepeat) &&
if (is_int($timesRepeat) &&
$timesRepeat >= 0) {
$this->timesRepeat = $timesRepeat;
} else {
Expand Down
4 changes: 2 additions & 2 deletions PHPUnit/Framework/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ abstract class PHPUnit_Framework_Assert
*/
public static function assertArrayHasKey($key, $array, $message = '')
{
if (!(is_integer($key) || is_string($key))) {
if (!(is_int($key) || is_string($key))) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(
1, 'integer or string'
);
Expand All @@ -97,7 +97,7 @@ public static function assertArrayHasKey($key, $array, $message = '')
*/
public static function assertArrayNotHasKey($key, $array, $message = '')
{
if (!(is_integer($key) || is_string($key))) {
if (!(is_int($key) || is_string($key))) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(
1, 'integer or string'
);
Expand Down
2 changes: 1 addition & 1 deletion PHPUnit/Framework/Comparator/Double.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PHPUnit_Framework_Comparator_Double extends PHPUnit_Framework_Comparator_N
*/
public function accepts($expected, $actual)
{
return (is_double($expected) || is_double($actual)) && is_numeric($expected) && is_numeric($actual);
return (is_float($expected) || is_float($actual)) && is_numeric($expected) && is_numeric($actual);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion PHPUnit/Framework/Comparator/Numeric.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PHPUnit_Framework_Comparator_Numeric extends PHPUnit_Framework_Comparator_
public function accepts($expected, $actual)
{
// all numerical values, but not if one of them is a double
return is_numeric($expected) && is_numeric($actual) && !(is_double($expected) || is_double($actual));
return is_numeric($expected) && is_numeric($actual) && !(is_float($expected) || is_float($actual));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion PHPUnit/Framework/Constraint/IsIdentical.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function __construct($value)
*/
public function evaluate($other, $description = '', $returnResult = FALSE)
{
if (is_double($this->value) && is_double($other) &&
if (is_float($this->value) && is_float($other) &&
!is_infinite($this->value) && !is_infinite($other) &&
!is_nan($this->value) && !is_nan($other)) {
$success = abs($this->value - $other) < self::EPSILON;
Expand Down
2 changes: 1 addition & 1 deletion PHPUnit/Framework/Constraint/IsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function matches($other)

case 'integer':
case 'int': {
return is_integer($other);
return is_int($other);
}

case 'float': {
Expand Down
8 changes: 4 additions & 4 deletions PHPUnit/Framework/TestResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public function run(PHPUnit_Framework_Test $test)
break;
}

$invoker = new PHP_Invoker;
$invoker = new PHPUnit_Util_Invoker;
$invoker->invoke(array($test, 'runBare'), array(), $_timeout);
} else {
$test->runBare();
Expand Down Expand Up @@ -920,7 +920,7 @@ public function wasSuccessful()
*/
public function setTimeoutForSmallTests($timeout)
{
if (is_integer($timeout)) {
if (is_int($timeout)) {
$this->timeoutForSmallTests = $timeout;
} else {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer');
Expand All @@ -936,7 +936,7 @@ public function setTimeoutForSmallTests($timeout)
*/
public function setTimeoutForMediumTests($timeout)
{
if (is_integer($timeout)) {
if (is_int($timeout)) {
$this->timeoutForMediumTests = $timeout;
} else {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer');
Expand All @@ -952,7 +952,7 @@ public function setTimeoutForMediumTests($timeout)
*/
public function setTimeoutForLargeTests($timeout)
{
if (is_integer($timeout)) {
if (is_int($timeout)) {
$this->timeoutForLargeTests = $timeout;
} else {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer');
Expand Down
2 changes: 1 addition & 1 deletion PHPUnit/TextUI/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
$suite->setBackupStaticAttributes(TRUE);
}

if (is_integer($arguments['repeat'])) {
if (is_int($arguments['repeat'])) {
$test = new PHPUnit_Extensions_RepeatedTest(
$suite,
$arguments['repeat'],
Expand Down
106 changes: 106 additions & 0 deletions PHPUnit/Util/Invoker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php
/**
* PHPUnit
*
* Copyright (c) 2001-2014, Sebastian Bergmann <sebastian@phpunit.de>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Sebastian Bergmann nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package PHPUnit
* @subpackage Util
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://www.phpunit.de/
* @since File available since Release 3.7.45
*/

declare(ticks = 1);

// php-invoker is optional, so the class is only declared when it is installed - including this file
// without it (e.g. code coverage with processUncoveredFilesFromWhitelist) must not fail
if (class_exists('PHP_Invoker')) {
/**
* PHP_Invoker from the optional php-invoker 1.1 package, with invoke() using is_int()
* instead of is_integer(), which is deprecated since PHP 8.6. php-invoker 1.1 is no longer maintained.
*
* Only instantiated after class_exists('PHP_Invoker'), so php-invoker stays optional.
*
* @package PHPUnit
* @subpackage Util
* @author Sebastian Bergmann <sebastian@phpunit.de>
* @copyright 2001-2014 Sebastian Bergmann <sebastian@phpunit.de>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @link http://www.phpunit.de/
* @since Class available since Release 3.7.45
*/
class PHPUnit_Util_Invoker extends PHP_Invoker
{
/**
* Invokes a callable and raises an exception when the execution does not
* finish before the specified timeout.
*
* @param callable $callable
* @param array $arguments
* @param int $timeout in seconds
* @return mixed
* @throws InvalidArgumentException
*/
public function invoke($callable, array $arguments, $timeout)
{
if (!is_callable($callable)) {
throw new InvalidArgumentException;
}

if (!is_int($timeout)) {
throw new InvalidArgumentException;
}

pcntl_signal(SIGALRM, array($this, 'callback'), TRUE);
pcntl_alarm($timeout);

$this->timeout = $timeout;

try {
$result = call_user_func_array($callable, $arguments);
}

catch (Exception $e) {
pcntl_alarm(0);
throw $e;
}

pcntl_alarm(0);

return $result;
}
}
}
6 changes: 5 additions & 1 deletion PHPUnit/Util/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,11 @@ public static function toArray($object)
// Format the output similarly to print_r() in this case
if ($object instanceof SplObjectStorage) {
foreach ($object as $key => $value) {
$array[spl_object_hash($value)] = array(
// same value as spl_object_hash(), which is deprecated since PHP 8.6
$hash = PHP_VERSION_ID >= 80600
? sprintf('%016x%016x', spl_object_id($value), 0)
: spl_object_hash($value);
$array[$hash] = array(
'obj' => $value,
'inf' => $object->getInfo(),
);
Expand Down
10 changes: 8 additions & 2 deletions PHPUnit/Util/Type/ExportContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ protected function addObject($value)
$this->objects->offsetSet($value, null);
}

return spl_object_hash($value);
// same value as spl_object_hash(), which is deprecated since PHP 8.6
return PHP_VERSION_ID >= 80600
? sprintf('%016x%016x', spl_object_id($value), 0)
: spl_object_hash($value);
}

/**
Expand Down Expand Up @@ -181,7 +184,10 @@ protected function containsArray(array &$value)
protected function containsObject($value)
{
if ($this->objects->offsetExists($value)) {
return spl_object_hash($value);
// same value as spl_object_hash(), which is deprecated since PHP 8.6
return PHP_VERSION_ID >= 80600
? sprintf('%016x%016x', spl_object_id($value), 0)
: spl_object_hash($value);
}

return false;
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PHPUnit 3.7.x php 5.3-8.5 compatible
# PHPUnit 3.7.x php 5.3-8.6 compatible

This version of PHPUnit bases on release 3.7.38 and is adjusted for compatibility with PHP 5.3-8.5.
This version of PHPUnit bases on release 3.7.38 and is adjusted for compatibility with PHP 5.3-8.6.
The package was created especially for testing https://github.com/zf1s packages.

All credits go to original PHPUnit author and contributors.
14 changes: 10 additions & 4 deletions Tests/Framework/ConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,9 @@ public function isEqualProvider()
$a = new stdClass;
$a->foo = 'bar';
$b = new stdClass;
$ahash = spl_object_hash($a);
$bhash = spl_object_hash($b);
// same values as spl_object_hash(), which is deprecated since PHP 8.6
$ahash = PHP_VERSION_ID >= 80600 ? sprintf('%016x%016x', spl_object_id($a), 0) : spl_object_hash($a);
$bhash = PHP_VERSION_ID >= 80600 ? sprintf('%016x%016x', spl_object_id($b), 0) : spl_object_hash($b);

$c = new stdClass;
$c->foo = 'bar';
Expand All @@ -737,8 +738,13 @@ public function isEqualProvider()
$storage1->offsetSet($b);
$storage2 = new SplObjectStorage;
$storage2->offsetSet($b);
$storage1hash = spl_object_hash($storage1);
$storage2hash = spl_object_hash($storage2);
// same values as spl_object_hash(), which is deprecated since PHP 8.6
$storage1hash = PHP_VERSION_ID >= 80600
? sprintf('%016x%016x', spl_object_id($storage1), 0)
: spl_object_hash($storage1);
$storage2hash = PHP_VERSION_ID >= 80600
? sprintf('%016x%016x', spl_object_id($storage2), 0)
: spl_object_hash($storage2);

$dom1 = new DOMDocument;
$dom1->preserveWhiteSpace = FALSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,9 @@ protected static function generateMockedMethodDefinition($templateDir, $classNam
'method_name' => $methodName,
'modifier' => $modifier,
'reference' => $reference,
'clone_arguments' => $cloneArguments ? 'TRUE' : 'FALSE'
'clone_arguments' => $cloneArguments ? 'TRUE' : 'FALSE',
// returning a value from a destructor is deprecated since PHP 8.6
'return_result' => strtolower($methodName) == '__destruct' ? '' : 'return $result;'
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
)
);

return $result;
{return_result}
}
Loading