Upgrade framework

This commit is contained in:
2023-11-14 16:54:35 +01:00
parent 1648a5cd42
commit 4fcf6fffcc
10548 changed files with 693138 additions and 466698 deletions

View File

@@ -1,9 +0,0 @@
.idea
phpunit.xml
composer.lock
composer.phar
vendor/
cache.properties
build/LICENSE
build/README.md
build/*.tgz

View File

@@ -1,23 +0,0 @@
language: php
before_script:
- composer self-update
- composer install --no-interaction --prefer-source --dev
php:
- 5.3.3
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
notifications:
email: false
webhooks:
urls:
- https://webhooks.gitter.im/e/6668f52f3dd4e3f81960
on_success: always
on_failure: always
on_start: false

78
vendor/sebastian/exporter/ChangeLog.md vendored Normal file
View File

@@ -0,0 +1,78 @@
# ChangeLog
All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
## [4.0.5] - 2022-09-14
### Fixed
* [#47](https://github.com/sebastianbergmann/exporter/pull/47): Fix `float` export precision
## [4.0.4] - 2021-11-11
### Changed
* [#37](https://github.com/sebastianbergmann/exporter/pull/37): Improve export of closed resources
## [4.0.3] - 2020-09-28
### Changed
* Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3`
## [4.0.2] - 2020-06-26
### Added
* This component is now supported on PHP 8
## [4.0.1] - 2020-06-15
### Changed
* Tests etc. are now ignored for archive exports
## [4.0.0] - 2020-02-07
### Removed
* This component is no longer supported on PHP 7.0, PHP 7.1, and PHP 7.2
## [3.1.5] - 2022-09-14
### Fixed
* [#47](https://github.com/sebastianbergmann/exporter/pull/47): Fix `float` export precision
## [3.1.4] - 2021-11-11
### Changed
* [#38](https://github.com/sebastianbergmann/exporter/pull/38): Improve export of closed resources
## [3.1.3] - 2020-11-30
### Changed
* Changed PHP version constraint in `composer.json` from `^7.0` to `>=7.0`
## [3.1.2] - 2019-09-14
### Fixed
* [#29](https://github.com/sebastianbergmann/exporter/pull/29): Second parameter for `str_repeat()` must be an integer
### Removed
* Remove HHVM-specific code that is no longer needed
[4.0.5]: https://github.com/sebastianbergmann/exporter/compare/4.0.4...4.0.5
[4.0.4]: https://github.com/sebastianbergmann/exporter/compare/4.0.3...4.0.4
[4.0.3]: https://github.com/sebastianbergmann/exporter/compare/4.0.2...4.0.3
[4.0.2]: https://github.com/sebastianbergmann/exporter/compare/4.0.1...4.0.2
[4.0.1]: https://github.com/sebastianbergmann/exporter/compare/4.0.0...4.0.1
[4.0.0]: https://github.com/sebastianbergmann/exporter/compare/3.1.2...4.0.0
[3.1.5]: https://github.com/sebastianbergmann/exporter/compare/3.1.4...3.1.5
[3.1.4]: https://github.com/sebastianbergmann/exporter/compare/3.1.3...3.1.4
[3.1.3]: https://github.com/sebastianbergmann/exporter/compare/3.1.2...3.1.3
[3.1.2]: https://github.com/sebastianbergmann/exporter/compare/3.1.1...3.1.2

View File

@@ -1,6 +1,6 @@
Exporter
Copyright (c) 2002-2015, Sebastian Bergmann <sebastian@phpunit.de>.
Copyright (c) 2002-2021, Sebastian Bergmann <sebastian@phpunit.de>.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -1,10 +1,24 @@
Exporter
========
# sebastian/exporter
[![Build Status](https://secure.travis-ci.org/sebastianbergmann/exporter.png?branch=master)](https://travis-ci.org/sebastianbergmann/exporter)
[![CI Status](https://github.com/sebastianbergmann/exporter/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/exporter/actions)
[![Type Coverage](https://shepherd.dev/github/sebastianbergmann/exporter/coverage.svg)](https://shepherd.dev/github/sebastianbergmann/exporter)
This component provides the functionality to export PHP variables for visualization.
## Installation
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
```
composer require sebastian/exporter
```
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
```
composer require --dev sebastian/exporter
```
## Usage
Exporting:
@@ -22,7 +36,6 @@ Exception Object &0000000078de0f0d000000002003a261 (
'code' => 0
'file' => '/home/sebastianbergmann/test.php'
'line' => 34
'trace' => Array &0 ()
'previous' => null
)
*/
@@ -159,14 +172,3 @@ space
LONG_STRING
);
```
## Installation
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
composer require sebastian/exporter
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
composer require --dev sebastian/exporter

View File

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="exporter">
<target name="clean" description="Cleanup build artifacts">
<delete dir="${basedir}/vendor"/>
<delete file="${basedir}/composer.lock"/>
</target>
<target name="composer" depends="clean" description="Install dependencies with Composer">
<tstamp>
<format property="thirty.days.ago" pattern="MM/dd/yyyy hh:mm aa" offset="-30" unit="day"/>
</tstamp>
<delete>
<fileset dir="${basedir}">
<include name="composer.phar" />
<date datetime="${thirty.days.ago}" when="before"/>
</fileset>
</delete>
<get src="https://getcomposer.org/composer.phar" dest="${basedir}/composer.phar" skipexisting="true"/>
<exec executable="php">
<arg value="composer.phar"/>
<arg value="install"/>
</exec>
</target>
</project>

View File

@@ -2,7 +2,7 @@
"name": "sebastian/exporter",
"description": "Provides the functionality to export PHP variables for visualization",
"keywords": ["exporter","export"],
"homepage": "http://www.github.com/sebastianbergmann/exporter",
"homepage": "https://www.github.com/sebastianbergmann/exporter",
"license": "BSD-3-Clause",
"authors": [
{
@@ -23,15 +23,23 @@
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
"email": "bschussek@gmail.com"
}
],
"config": {
"platform": {
"php": "7.3.0"
},
"optimize-autoloader": true,
"sort-packages": true
},
"prefer-stable": true,
"require": {
"php": ">=5.3.3",
"sebastian/recursion-context": "~2.0"
"php": ">=7.3",
"sebastian/recursion-context": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.4",
"phpunit/phpunit": "^9.3",
"ext-mbstring": "*"
},
"autoload": {
@@ -41,7 +49,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "4.0-dev"
}
}
}

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
bootstrap="vendor/autoload.php"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
checkForUnintentionallyCoveredCode="true"
forceCoversAnnotation="true"
verbose="true">
<testsuites>
<testsuite name="exporter">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="true">
<directory>src</directory>
</whitelist>
</filter>
</phpunit>

View File

@@ -1,16 +1,40 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the Exporter package.
* This file is part of sebastian/exporter.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Exporter;
use function bin2hex;
use function count;
use function function_exists;
use function get_class;
use function get_resource_type;
use function gettype;
use function implode;
use function ini_get;
use function ini_set;
use function is_array;
use function is_float;
use function is_object;
use function is_resource;
use function is_string;
use function mb_strlen;
use function mb_substr;
use function preg_match;
use function spl_object_hash;
use function sprintf;
use function str_repeat;
use function str_replace;
use function strlen;
use function substr;
use function var_export;
use SebastianBergmann\RecursionContext\Context;
use SplObjectStorage;
/**
* A nifty utility for visualizing PHP variables.
@@ -26,7 +50,7 @@ use SebastianBergmann\RecursionContext\Context;
class Exporter
{
/**
* Exports a value as a string
* Exports a value as a string.
*
* The output of this method is similar to the output of print_r(), but
* improved in various aspects:
@@ -38,8 +62,8 @@ class Exporter
* - Carriage returns and newlines are normalized to \n
* - Recursion and repeated rendering is treated properly
*
* @param mixed $value
* @param int $indentation The indentation level of the 2nd+ line
* @param int $indentation The indentation level of the 2nd+ line
*
* @return string
*/
public function export($value, $indentation = 0)
@@ -48,13 +72,14 @@ class Exporter
}
/**
* @param mixed $data
* @param Context $context
* @param array<mixed> $data
* @param Context $context
*
* @return string
*/
public function shortenedRecursiveExport(&$data, Context $context = null)
{
$result = array();
$result = [];
$exporter = new self();
if (!$context) {
@@ -68,17 +93,13 @@ class Exporter
if (is_array($value)) {
if ($context->contains($data[$key]) !== false) {
$result[] = '*RECURSION*';
}
else {
} else {
$result[] = sprintf(
'array(%s)',
$this->shortenedRecursiveExport($data[$key], $context)
);
}
}
else {
} else {
$result[] = $exporter->shortenedExport($value);
}
}
@@ -87,7 +108,7 @@ class Exporter
}
/**
* Exports a value into a single-line string
* Exports a value into a single-line string.
*
* The output of this method is similar to the output of
* SebastianBergmann\Exporter\Exporter::export().
@@ -95,14 +116,14 @@ class Exporter
* Newlines are replaced by the visible string '\n'.
* Contents of arrays and objects (if any) are replaced by '...'.
*
* @param mixed $value
* @return string
*
* @see SebastianBergmann\Exporter\Exporter::export
*/
public function shortenedExport($value)
{
if (is_string($value)) {
$string = $this->export($value);
$string = str_replace("\n", '', $this->export($value));
if (function_exists('mb_strlen')) {
if (mb_strlen($string) > 40) {
@@ -114,7 +135,7 @@ class Exporter
}
}
return str_replace("\n", '\n', $string);
return $string;
}
if (is_object($value)) {
@@ -139,7 +160,6 @@ class Exporter
* Converts an object to an array containing all of its private, protected
* and public properties.
*
* @param mixed $value
* @return array
*/
public function toArray($value)
@@ -148,14 +168,21 @@ class Exporter
return (array) $value;
}
$array = array();
$array = [];
foreach ((array) $value as $key => $val) {
// Exception traces commonly reference hundreds to thousands of
// objects currently loaded in memory. Including them in the result
// has a severe negative performance impact.
if ("\0Error\0trace" === $key || "\0Exception\0trace" === $key) {
continue;
}
// properties are transformed to keys in the following way:
// private $property => "\0Classname\0property"
// protected $property => "\0*\0property"
// public $property => "property"
if (preg_match('/^\0.+\0(.+)$/', $key, $matches)) {
if (preg_match('/^\0.+\0(.+)$/', (string) $key, $matches)) {
$key = $matches[1];
}
@@ -170,24 +197,12 @@ class Exporter
// Some internal classes like SplObjectStorage don't work with the
// above (fast) mechanism nor with reflection in Zend.
// Format the output similarly to print_r() in this case
if ($value instanceof \SplObjectStorage) {
// However, the fast method does work in HHVM, and exposes the
// internal implementation. Hide it again.
if (property_exists('\SplObjectStorage', '__storage')) {
unset($array['__storage']);
} elseif (property_exists('\SplObjectStorage', 'storage')) {
unset($array['storage']);
}
if (property_exists('\SplObjectStorage', '__key')) {
unset($array['__key']);
}
if ($value instanceof SplObjectStorage) {
foreach ($value as $key => $val) {
$array[spl_object_hash($val)] = array(
$array[spl_object_hash($val)] = [
'obj' => $val,
'inf' => $value->getInfo(),
);
];
}
}
@@ -195,12 +210,14 @@ class Exporter
}
/**
* Recursive implementation of export
* Recursive implementation of export.
*
* @param mixed $value The value to export
* @param int $indentation The indentation level of the 2nd+ line
* @param \SebastianBergmann\RecursionContext\Context $processed Previously processed objects
*
* @param mixed $value The value to export
* @param int $indentation The indentation level of the 2nd+ line
* @param \SebastianBergmann\RecursionContext\Context $processed Previously processed objects
* @return string
*
* @see SebastianBergmann\Exporter\Exporter::export
*/
protected function recursiveExport(&$value, $indentation, $processed = null)
@@ -217,8 +234,26 @@ class Exporter
return 'false';
}
if (is_float($value) && floatval(intval($value)) === $value) {
return "$value.0";
if (is_float($value)) {
$precisionBackup = ini_get('precision');
ini_set('precision', '-1');
try {
$valueStr = (string) $value;
if ((string) (int) $value === $valueStr) {
return $valueStr . '.0';
}
return $valueStr;
} finally {
ini_set('precision', $precisionBackup);
}
}
if (gettype($value) === 'resource (closed)') {
return 'resource (closed)';
}
if (is_resource($value)) {
@@ -236,7 +271,15 @@ class Exporter
}
return "'" .
str_replace(array("\r\n", "\n\r", "\r"), array("\n", "\n", "\n"), $value) .
str_replace(
'<lf>',
"\n",
str_replace(
["\r\n", "\n\r", "\r", "\n"],
['\r\n<lf>', '\n\r<lf>', '\r<lf>', '\n<lf>'],
$value
)
) .
"'";
}

View File

@@ -1,358 +0,0 @@
<?php
/*
* This file is part of the Exporter package.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SebastianBergmann\Exporter;
/**
* @covers SebastianBergmann\Exporter\Exporter
*/
class ExporterTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Exporter
*/
private $exporter;
protected function setUp()
{
$this->exporter = new Exporter;
}
public function exportProvider()
{
$obj2 = new \stdClass;
$obj2->foo = 'bar';
$obj3 = (object)array(1,2,"Test\r\n",4,5,6,7,8);
$obj = new \stdClass;
//@codingStandardsIgnoreStart
$obj->null = null;
//@codingStandardsIgnoreEnd
$obj->boolean = true;
$obj->integer = 1;
$obj->double = 1.2;
$obj->string = '1';
$obj->text = "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext";
$obj->object = $obj2;
$obj->objectagain = $obj2;
$obj->array = array('foo' => 'bar');
$obj->self = $obj;
$storage = new \SplObjectStorage;
$storage->attach($obj2);
$storage->foo = $obj2;
return array(
array(null, 'null'),
array(true, 'true'),
array(false, 'false'),
array(1, '1'),
array(1.0, '1.0'),
array(1.2, '1.2'),
array(fopen('php://memory', 'r'), 'resource(%d) of type (stream)'),
array('1', "'1'"),
array(array(array(1,2,3), array(3,4,5)),
<<<EOF
Array &0 (
0 => Array &1 (
0 => 1
1 => 2
2 => 3
)
1 => Array &2 (
0 => 3
1 => 4
2 => 5
)
)
EOF
),
// \n\r and \r is converted to \n
array("this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext",
<<<EOF
'this
is
a
very
very
very
very
very
very
long
text'
EOF
),
array(new \stdClass, 'stdClass Object &%x ()'),
array($obj,
<<<EOF
stdClass Object &%x (
'null' => null
'boolean' => true
'integer' => 1
'double' => 1.2
'string' => '1'
'text' => 'this
is
a
very
very
very
very
very
very
long
text'
'object' => stdClass Object &%x (
'foo' => 'bar'
)
'objectagain' => stdClass Object &%x
'array' => Array &%d (
'foo' => 'bar'
)
'self' => stdClass Object &%x
)
EOF
),
array(array(), 'Array &%d ()'),
array($storage,
<<<EOF
SplObjectStorage Object &%x (
'foo' => stdClass Object &%x (
'foo' => 'bar'
)
'%x' => Array &0 (
'obj' => stdClass Object &%x
'inf' => null
)
)
EOF
),
array($obj3,
<<<EOF
stdClass Object &%x (
0 => 1
1 => 2
2 => 'Test\n'
3 => 4
4 => 5
5 => 6
6 => 7
7 => 8
)
EOF
),
array(
chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5),
'Binary String: 0x000102030405'
),
array(
implode('', array_map('chr', range(0x0e, 0x1f))),
'Binary String: 0x0e0f101112131415161718191a1b1c1d1e1f'
),
array(
chr(0x00) . chr(0x09),
'Binary String: 0x0009'
),
array(
'',
"''"
),
);
}
/**
* @dataProvider exportProvider
*/
public function testExport($value, $expected)
{
$this->assertStringMatchesFormat(
$expected,
$this->trimNewline($this->exporter->export($value))
);
}
public function testExport2()
{
if (PHP_VERSION === '5.3.3') {
$this->markTestSkipped('Skipped due to "Nesting level too deep - recursive dependency?" fatal error');
}
$obj = new \stdClass;
$obj->foo = 'bar';
$array = array(
0 => 0,
'null' => null,
'boolean' => true,
'integer' => 1,
'double' => 1.2,
'string' => '1',
'text' => "this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext",
'object' => $obj,
'objectagain' => $obj,
'array' => array('foo' => 'bar'),
);
$array['self'] = &$array;
$expected = <<<EOF
Array &%d (
0 => 0
'null' => null
'boolean' => true
'integer' => 1
'double' => 1.2
'string' => '1'
'text' => 'this
is
a
very
very
very
very
very
very
long
text'
'object' => stdClass Object &%x (
'foo' => 'bar'
)
'objectagain' => stdClass Object &%x
'array' => Array &%d (
'foo' => 'bar'
)
'self' => Array &%d (
0 => 0
'null' => null
'boolean' => true
'integer' => 1
'double' => 1.2
'string' => '1'
'text' => 'this
is
a
very
very
very
very
very
very
long
text'
'object' => stdClass Object &%x
'objectagain' => stdClass Object &%x
'array' => Array &%d (
'foo' => 'bar'
)
'self' => Array &%d
)
)
EOF;
$this->assertStringMatchesFormat(
$expected,
$this->trimNewline($this->exporter->export($array))
);
}
public function shortenedExportProvider()
{
$obj = new \stdClass;
$obj->foo = 'bar';
$array = array(
'foo' => 'bar',
);
return array(
array(null, 'null'),
array(true, 'true'),
array(1, '1'),
array(1.0, '1.0'),
array(1.2, '1.2'),
array('1', "'1'"),
// \n\r and \r is converted to \n
array("this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext", "'this\\nis\\na\\nvery\\nvery\\nvery\\nvery...g\\ntext'"),
array(new \stdClass, 'stdClass Object ()'),
array($obj, 'stdClass Object (...)'),
array(array(), 'Array ()'),
array($array, 'Array (...)'),
);
}
/**
* @dataProvider shortenedExportProvider
*/
public function testShortenedExport($value, $expected)
{
$this->assertSame(
$expected,
$this->trimNewline($this->exporter->shortenedExport($value))
);
}
/**
* @requires extension mbstring
*/
public function testShortenedExportForMultibyteCharacters()
{
$oldMbLanguage = mb_language();
mb_language('Japanese');
$oldMbInternalEncoding = mb_internal_encoding();
mb_internal_encoding('UTF-8');
try {
$this->assertSame(
"'いろはにほへとちりぬるをわかよたれそつねならむうゐのおくや...しゑひもせす'",
$this->trimNewline($this->exporter->shortenedExport('いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす'))
);
} catch (\Exception $e) {
mb_internal_encoding($oldMbInternalEncoding);
mb_language($oldMbLanguage);
throw $e;
}
mb_internal_encoding($oldMbInternalEncoding);
mb_language($oldMbLanguage);
}
public function provideNonBinaryMultibyteStrings()
{
return array(
array(implode('', array_map('chr', range(0x09, 0x0d))), 5),
array(implode('', array_map('chr', range(0x20, 0x7f))), 96),
array(implode('', array_map('chr', range(0x80, 0xff))), 128),
);
}
/**
* @dataProvider provideNonBinaryMultibyteStrings
*/
public function testNonBinaryStringExport($value, $expectedLength)
{
$this->assertRegExp(
"~'.{{$expectedLength}}'\$~s",
$this->exporter->export($value)
);
}
public function testNonObjectCanBeReturnedAsArray()
{
$this->assertEquals(array(true), $this->exporter->toArray(true));
}
private function trimNewline($string)
{
return preg_replace('/[ ]*\n/', "\n", $string);
}
}