Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.7.38-1 compat version for php 5.3-7.3 #1

Merged
merged 8 commits into from
May 8, 2019
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
38 changes: 18 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
language: php

php:
- 5.3.3
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3

env:
- INSTALL_PHP_INVOKER=0
- INSTALL_PHP_INVOKER=1
- INSTALL_PHP_INVOKER=0
- INSTALL_PHP_INVOKER=1

matrix:
include:
- php: 5.3
dist: precise
env: INSTALL_PHP_INVOKER=0
- php: 5.3
dist: precise
env: INSTALL_PHP_INVOKER=1

before_script:
- sh -c "if [ '$INSTALL_PHP_INVOKER' = '1' ]; then composer require --dev --prefer-source phpunit/php-invoker:\>=1.1.0,\<1.2.0; else composer install --dev --prefer-source; fi"

script: ./phpunit.php --configuration ./build/travis-ci.xml

matrix:
allow_failures:
- php: hhvm

notifications:
email: false
irc:
channels:
- "irc.freenode.org#phpunit"
use_notice: true
1 change: 1 addition & 0 deletions PHPUnit/Autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ function ($class)
'phpunit_util_testdox_resultprinter_text' => '/Util/TestDox/ResultPrinter/Text.php',
'phpunit_util_testsuiteiterator' => '/Util/TestSuiteIterator.php',
'phpunit_util_type' => '/Util/Type.php',
'phpunit_util_type_exportcontext' => '/Util/Type/ExportContext.php',
'phpunit_util_xml' => '/Util/XML.php'
);

Expand Down
6 changes: 3 additions & 3 deletions PHPUnit/Framework/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,7 @@ public static function assertSelectEquals($selector, $content, $count, $actual,

// assert any elements exist if true, assert no elements exist if false
else if (is_bool($count)) {
$any = count($tags) > 0 && $tags[0] instanceof DOMNode;
$any = $tags && count($tags) > 0 && $tags[0] instanceof DOMNode;

if ($count) {
self::assertTrue($any, $message);
Expand Down Expand Up @@ -2094,7 +2094,7 @@ public static function assertTag($matcher, $actual, $message = '', $isHtml = TRU
{
$dom = PHPUnit_Util_XML::load($actual, $isHtml);
$tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml);
$matched = count($tags) > 0 && $tags[0] instanceof DOMNode;
$matched = $tags && count($tags) > 0 && $tags[0] instanceof DOMNode;

self::assertTrue($matched, $message);
}
Expand All @@ -2117,7 +2117,7 @@ public static function assertNotTag($matcher, $actual, $message = '', $isHtml =
{
$dom = PHPUnit_Util_XML::load($actual, $isHtml);
$tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml);
$matched = count($tags) > 0 && $tags[0] instanceof DOMNode;
$matched = $tags && count($tags) > 0 && $tags[0] instanceof DOMNode;

self::assertFalse($matched, $message);
}
Expand Down
2 changes: 1 addition & 1 deletion PHPUnit/Framework/Comparator/DOMDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function accepts($expected, $actual)
* fails. Contains information about the
* specific errors that lead to the failure.
*/
public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE)
public function assertEquals($expected, $actual, $delta = 0, $canonicalize = FALSE, $ignoreCase = FALSE, array &$processed = array())
{
if ($expected->C14N() !== $actual->C14N()) {
throw new PHPUnit_Framework_ComparisonFailure(
Expand Down
4 changes: 2 additions & 2 deletions PHPUnit/TextUI/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,15 @@ protected function handleArguments(array $argv)
'tokenizer', 'No code coverage will be generated.'
);

continue;
break;
}

if (!extension_loaded('xdebug')) {
$this->showExtensionNotLoadedMessage(
'Xdebug', 'No code coverage will be generated.'
);

continue;
break;
}

switch ($option[0]) {
Expand Down
70 changes: 36 additions & 34 deletions PHPUnit/Util/Getopt.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public static function getopt(array $args, $short_options, $long_options = NULL)
reset($args);
array_map('trim', $args);

while (list($i, $arg) = each($args)) {
while (false !== $arg = current($args)) {
$i = key($args);
next($args);
if ($arg == '') {
continue;
}
Expand All @@ -88,20 +90,23 @@ public static function getopt(array $args, $short_options, $long_options = NULL)
}

if ($arg[0] != '-' ||
(strlen($arg) > 1 && $arg[1] == '-' && !$long_options)) {
$non_opts = array_merge($non_opts, array_slice($args, $i));
break;
}

elseif (strlen($arg) > 1 && $arg[1] == '-') {
(strlen($arg) > 1 && $arg[1] == '-' && !$long_options)
) {
$non_opts[] = $args[$i];
continue;
} elseif (strlen($arg) > 1 && $arg[1] == '-') {
self::parseLongOption(
substr($arg, 2), $long_options, $opts, $args
substr($arg, 2),
$long_options,
$opts,
$args
);
}

else {
} else {
self::parseShortOption(
substr($arg, 1), $short_options, $opts, $args
substr($arg, 1),
$short_options,
$opts,
$args
);
}
}
Expand All @@ -118,32 +123,25 @@ protected static function parseShortOption($arg, $short_options, &$opts, &$args)
$opt_arg = NULL;

if (($spec = strstr($short_options, $opt)) === FALSE ||
$arg[$i] == ':') {
$arg[$i] == ':'
) {
throw new PHPUnit_Framework_Exception(
"unrecognized option -- $opt"
);
}

if (strlen($spec) > 1 && $spec[1] == ':') {
if (strlen($spec) > 2 && $spec[2] == ':') {
if ($i + 1 < $argLen) {
$opts[] = array($opt, substr($arg, $i + 1));
break;
}
} else {
if ($i + 1 < $argLen) {
$opts[] = array($opt, substr($arg, $i + 1));
break;
}

else if (list(, $opt_arg) = each($args)) {
}

else {
if ($i + 1 < $argLen) {
$opts[] = array($opt, substr($arg, $i + 1));
break;
}
if (!(strlen($spec) > 2 && $spec[2] == ':')) {
if (false === $opt_arg = current($args)) {
throw new PHPUnit_Framework_Exception(
"option requires an argument -- $opt"
);
}
next($args);
}
}

Expand Down Expand Up @@ -183,11 +181,13 @@ protected static function parseLongOption($arg, $long_options, &$opts, &$args)

if (substr($long_opt, -1) == '=') {
if (substr($long_opt, -2) != '==') {
if (!strlen($opt_arg) &&
!(list(, $opt_arg) = each($args))) {
throw new PHPUnit_Framework_Exception(
"option --$opt requires an argument"
);
if (!strlen($opt_arg)) {
if (false === $opt_arg = current($args)) {
throw new PHPUnit_Framework_Exception(
"option --$opt requires an argument"
);
}
next($args);
}
}
}
Expand All @@ -198,7 +198,9 @@ protected static function parseLongOption($arg, $long_options, &$opts, &$args)
);
}

$opts[] = array('--' . $opt, $opt_arg);
$full_option = '--' . preg_replace('/={1,2}$/', '', $long_opt);
$opts[] = array($full_option, $opt_arg);

return;
}

Expand Down
2 changes: 1 addition & 1 deletion PHPUnit/Util/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public static function getExpectedException($className, $methodName)
*/
protected static function _parseAnnotationContent($message)
{
if (strpos($message, '::') !== FALSE && count(explode('::', $message) == 2)) {
if (strpos($message, '::') !== FALSE && count(explode('::', $message)) == 2) {
if (defined($message)) {
$message = constant($message);
}
Expand Down
94 changes: 43 additions & 51 deletions PHPUnit/Util/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,15 @@ public static function export($value, $indentation = 0)
*
* @param mixed $value The value to export
* @param integer $indentation The indentation level of the 2nd+ line
* @param array $processedObjects Contains all objects that were already
* rendered
* @param PHPUnit_Util_Type_ExportContext $processed Contains all objects
* and arrays that have
* previously been
* rendered
* @return string
* @since Method available since Release 3.6.0
* @see PHPUnit_Util_Type::export
*/
protected static function recursiveExport($value, $indentation, &$processedObjects = array())
protected static function recursiveExport(&$value, $indentation, $processed = null)
{
if ($value === NULL) {
return 'null';
Expand All @@ -125,6 +127,10 @@ protected static function recursiveExport($value, $indentation, &$processedObjec
return 'false';
}

if (is_float($value) && floatval(intval($value)) === $value) {
return "$value.0";
}

if (is_string($value)) {
// Match for most non printable chars somewhat taking multibyte chars into account
if (preg_match('/[^\x09-\x0d\x20-\xff]/', $value)) {
Expand All @@ -136,71 +142,57 @@ protected static function recursiveExport($value, $indentation, &$processedObjec
"'";
}

$origValue = $value;

if (is_object($value)) {
if (in_array($value, $processedObjects, TRUE)) {
return sprintf(
'%s Object (*RECURSION*)',

get_class($value)
);
}

$processedObjects[] = $value;
$whitespace = str_repeat(' ', 4 * $indentation);

// Convert object to array
$value = self::toArray($value);
if (!$processed) {
$processed = new PHPUnit_Util_Type_ExportContext;
}

if (is_array($value)) {
$whitespace = str_repeat(' ', $indentation);

// There seems to be no other way to check arrays for recursion
// http://www.php.net/manual/en/language.types.array.php#73936
preg_match_all('/\n \[(\w+)\] => Array\s+\*RECURSION\*/', print_r($value, TRUE), $matches);
$recursiveKeys = array_unique($matches[1]);

// Convert to valid array keys
// Numeric integer strings are automatically converted to integers
// by PHP
foreach ($recursiveKeys as $key => $recursiveKey) {
if ((string)(integer)$recursiveKey === $recursiveKey) {
$recursiveKeys[$key] = (integer)$recursiveKey;
}
if (($key = $processed->contains($value)) !== false) {
return "Array &$key";
}

$content = '';

foreach ($value as $key => $val) {
if (in_array($key, $recursiveKeys, TRUE)) {
$val = 'Array (*RECURSION*)';
}
$key = $processed->add($value);
if (count($value) > 0) {
$output = "Array &$key (\n";

else {
$val = self::recursiveExport($val, $indentation+1, $processedObjects);
foreach ($value as $k => $v) {
$k = self::export($k);
$output .= "$whitespace $k => ".self::recursiveExport($v, $indentation + 1, $processed)."\n";
}

$content .= $whitespace . ' ' . self::export($key) . ' => ' . $val . "\n";
return "$output$whitespace)";
} else {
return "Array &$key ()";
}
}

if (strlen($content) > 0) {
$content = "\n" . $content . $whitespace;
if (is_object($value)) {
$class = get_class($value);

if ($hash = $processed->contains($value)) {
return "$class Object &$hash";
}

return sprintf(
"%s (%s)",
$hash = $processed->add($value);
$array = self::toArray($value);
if (count($array) > 0) {
$output = "$class Object &$hash (\n";

is_object($origValue) ? get_class($origValue) . ' Object' : 'Array',
$content
);
}
foreach ($array as $k => $v) {
$k = self::export($k);
$output .= "$whitespace $k => ".self::recursiveExport($v, $indentation + 1, $processed)."\n";
}

return "$output$whitespace)";
} else {
return "$class Object &$hash ()";
}

if (is_double($value) && (double)(integer)$value === $value) {
return $value . '.0';
}

return (string)$value;
return var_export($value, true);
}

/**
Expand Down
Loading