upgraded dependencies

This commit is contained in:
RafficMohammed
2023-01-08 01:59:16 +05:30
parent 51056e3aad
commit f9ae387337
6895 changed files with 133617 additions and 178680 deletions

View File

@@ -2,6 +2,42 @@
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
@@ -30,6 +66,12 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* 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

View File

@@ -1,8 +1,24 @@
Exporter
========
# sebastian/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:
@@ -156,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

@@ -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": [
{
@@ -27,16 +27,19 @@
}
],
"config": {
"platform": {
"php": "7.3.0"
},
"optimize-autoloader": true,
"sort-packages": true
},
"prefer-stable": true,
"require": {
"php": ">=7.0",
"sebastian/recursion-context": "^3.0"
"php": ">=7.3",
"sebastian/recursion-context": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"phpunit/phpunit": "^9.3",
"ext-mbstring": "*"
},
"autoload": {
@@ -46,7 +49,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.1.x-dev"
"dev-master": "4.0-dev"
}
}
}

View File

@@ -1,6 +1,6 @@
<?php declare(strict_types=1);
/*
* This file is part of exporter package.
* This file is part of sebastian/exporter.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
@@ -9,7 +9,32 @@
*/
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.
@@ -25,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:
@@ -65,11 +90,11 @@ class Exporter
$context->add($data);
foreach ($array as $key => $value) {
if (\is_array($value)) {
if (is_array($value)) {
if ($context->contains($data[$key]) !== false) {
$result[] = '*RECURSION*';
} else {
$result[] = \sprintf(
$result[] = sprintf(
'array(%s)',
$this->shortenedRecursiveExport($data[$key], $context)
);
@@ -79,11 +104,11 @@ class Exporter
}
}
return \implode(', ', $result);
return implode(', ', $result);
}
/**
* 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().
@@ -97,34 +122,34 @@ class Exporter
*/
public function shortenedExport($value)
{
if (\is_string($value)) {
$string = \str_replace("\n", '', $this->export($value));
if (is_string($value)) {
$string = str_replace("\n", '', $this->export($value));
if (\function_exists('mb_strlen')) {
if (\mb_strlen($string) > 40) {
$string = \mb_substr($string, 0, 30) . '...' . \mb_substr($string, -7);
if (function_exists('mb_strlen')) {
if (mb_strlen($string) > 40) {
$string = mb_substr($string, 0, 30) . '...' . mb_substr($string, -7);
}
} else {
if (\strlen($string) > 40) {
$string = \substr($string, 0, 30) . '...' . \substr($string, -7);
if (strlen($string) > 40) {
$string = substr($string, 0, 30) . '...' . substr($string, -7);
}
}
return $string;
}
if (\is_object($value)) {
return \sprintf(
if (is_object($value)) {
return sprintf(
'%s Object (%s)',
\get_class($value),
\count($this->toArray($value)) > 0 ? '...' : ''
get_class($value),
count($this->toArray($value)) > 0 ? '...' : ''
);
}
if (\is_array($value)) {
return \sprintf(
if (is_array($value)) {
return sprintf(
'Array (%s)',
\count($value) > 0 ? '...' : ''
count($value) > 0 ? '...' : ''
);
}
@@ -139,7 +164,7 @@ class Exporter
*/
public function toArray($value)
{
if (!\is_object($value)) {
if (!is_object($value)) {
return (array) $value;
}
@@ -157,7 +182,7 @@ class Exporter
// private $property => "\0Classname\0property"
// protected $property => "\0*\0property"
// public $property => "property"
if (\preg_match('/^\0.+\0(.+)$/', (string) $key, $matches)) {
if (preg_match('/^\0.+\0(.+)$/', (string) $key, $matches)) {
$key = $matches[1];
}
@@ -172,9 +197,9 @@ 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) {
if ($value instanceof SplObjectStorage) {
foreach ($value as $key => $val) {
$array[\spl_object_hash($val)] = [
$array[spl_object_hash($val)] = [
'obj' => $val,
'inf' => $value->getInfo(),
];
@@ -185,7 +210,7 @@ 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
@@ -209,10 +234,10 @@ class Exporter
return 'false';
}
if (\is_float($value)) {
$precisionBackup = \ini_get('precision');
if (is_float($value)) {
$precisionBackup = ini_get('precision');
\ini_set('precision', '-1');
ini_set('precision', '-1');
try {
$valueStr = (string) $value;
@@ -223,33 +248,33 @@ class Exporter
return $valueStr;
} finally {
\ini_set('precision', $precisionBackup);
ini_set('precision', $precisionBackup);
}
}
if ($this->isClosedResource($value)) {
if (gettype($value) === 'resource (closed)') {
return 'resource (closed)';
}
if (\is_resource($value)) {
return \sprintf(
if (is_resource($value)) {
return sprintf(
'resource(%d) of type (%s)',
$value,
\get_resource_type($value)
get_resource_type($value)
);
}
if (\is_string($value)) {
if (is_string($value)) {
// Match for most non printable chars somewhat taking multibyte chars into account
if (\preg_match('/[^\x09-\x0d\x1b\x20-\xff]/', $value)) {
return 'Binary String: 0x' . \bin2hex($value);
if (preg_match('/[^\x09-\x0d\x1b\x20-\xff]/', $value)) {
return 'Binary String: 0x' . bin2hex($value);
}
return "'" .
\str_replace(
str_replace(
'<lf>',
"\n",
\str_replace(
str_replace(
["\r\n", "\n\r", "\r", "\n"],
['\r\n<lf>', '\n\r<lf>', '\r<lf>', '\n<lf>'],
$value
@@ -258,13 +283,13 @@ class Exporter
"'";
}
$whitespace = \str_repeat(' ', (int)(4 * $indentation));
$whitespace = str_repeat(' ', 4 * $indentation);
if (!$processed) {
$processed = new Context;
}
if (\is_array($value)) {
if (is_array($value)) {
if (($key = $processed->contains($value)) !== false) {
return 'Array &' . $key;
}
@@ -273,9 +298,9 @@ class Exporter
$key = $processed->add($value);
$values = '';
if (\count($array) > 0) {
if (count($array) > 0) {
foreach ($array as $k => $v) {
$values .= \sprintf(
$values .= sprintf(
'%s %s => %s' . "\n",
$whitespace,
$this->recursiveExport($k, $indentation),
@@ -286,23 +311,23 @@ class Exporter
$values = "\n" . $values . $whitespace;
}
return \sprintf('Array &%s (%s)', $key, $values);
return sprintf('Array &%s (%s)', $key, $values);
}
if (\is_object($value)) {
$class = \get_class($value);
if (is_object($value)) {
$class = get_class($value);
if ($hash = $processed->contains($value)) {
return \sprintf('%s Object &%s', $class, $hash);
return sprintf('%s Object &%s', $class, $hash);
}
$hash = $processed->add($value);
$values = '';
$array = $this->toArray($value);
if (\count($array) > 0) {
if (count($array) > 0) {
foreach ($array as $k => $v) {
$values .= \sprintf(
$values .= sprintf(
'%s %s => %s' . "\n",
$whitespace,
$this->recursiveExport($k, $indentation),
@@ -313,68 +338,9 @@ class Exporter
$values = "\n" . $values . $whitespace;
}
return \sprintf('%s Object &%s (%s)', $class, $hash, $values);
return sprintf('%s Object &%s (%s)', $class, $hash, $values);
}
return \var_export($value, true);
}
/**
* Determines whether a variable represents a resource, either open or closed.
*
* @param mixed $actual The variable to test.
*
* @return bool
*/
private function isResource($value)
{
return $value !== null
&& \is_scalar($value) === false
&& \is_array($value) === false
&& \is_object($value) === false;
}
/**
* Determines whether a variable represents a closed resource.
*
* @param mixed $actual The variable to test.
*
* @return bool
*/
private function isClosedResource($value)
{
/*
* PHP 7.2 introduced "resource (closed)".
*/
if (\gettype($value) === 'resource (closed)') {
return true;
}
/*
* If gettype did not work, attempt to determine whether this is
* a closed resource in another way.
*/
$isResource = \is_resource($value);
$isNotNonResource = $this->isResource($value);
if ($isResource === false && $isNotNonResource === true) {
return true;
}
if ($isNotNonResource === true) {
try {
$resourceType = @\get_resource_type($value);
if ($resourceType === 'Unknown') {
return true;
}
} catch (TypeError $e) {
// Ignore. Not a resource.
} catch (Exception $e) {
// Ignore. Not a resource.
}
}
return false;
return var_export($value, true);
}
}