From 1245ecacc9c9f8b15c76725cf03551e266497227 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 11 Nov 2021 14:31:47 +0100 Subject: [PATCH 1/6] Prepare release --- ChangeLog.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 150eeaa..5d84c29 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,12 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. +## [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 @@ -12,11 +18,12 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt ### Fixed -* Fixed [#29](https://github.com/sebastianbergmann/exporter/pull/29): Second parameter for `str_repeat()` must be an integer +* [#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 +[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 From a4954d6b20574fd320cbd1cc5f8f60f051536923 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 11 Nov 2021 14:33:59 +0100 Subject: [PATCH 2/6] Do not use deprecated --no-suggest option --- build.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/build.xml b/build.xml index c835c8a..dca0cc7 100644 --- a/build.xml +++ b/build.xml @@ -13,7 +13,6 @@ - From dd7b15e57f2f8cbc0ce8b613802049705a037750 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 11 Nov 2021 14:46:33 +0100 Subject: [PATCH 3/6] Revert "Fix CS/WS issues" This reverts commit 55a5916c01d190268a923e779ba3eff4fdb614be. --- src/Exporter.php | 136 +++++++++++-------------- tests/ExporterTest.php | 218 +++++++++++++++++++---------------------- 2 files changed, 160 insertions(+), 194 deletions(-) diff --git a/src/Exporter.php b/src/Exporter.php index 91e725f..41714d9 100644 --- a/src/Exporter.php +++ b/src/Exporter.php @@ -1,6 +1,6 @@ * @@ -9,31 +9,7 @@ */ 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 is_array; -use function is_float; -use function is_object; -use function is_resource; -use function is_scalar; -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. @@ -49,7 +25,7 @@ use SplObjectStorage; 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: @@ -89,11 +65,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) ); @@ -103,11 +79,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(). @@ -121,34 +97,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 ? '...' : '' ); } @@ -163,7 +139,7 @@ class Exporter */ public function toArray($value) { - if (!is_object($value)) { + if (!\is_object($value)) { return (array) $value; } @@ -181,7 +157,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]; } @@ -196,9 +172,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(), ]; @@ -209,7 +185,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 @@ -233,33 +209,33 @@ class Exporter return 'false'; } - if (is_float($value) && (float) ((int) $value) === $value) { - return "{$value}.0"; + if (\is_float($value) && (float) ((int) $value) === $value) { + return "$value.0"; } if ($this->isClosedResource($value)) { 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( '', "\n", - str_replace( + \str_replace( ["\r\n", "\n\r", "\r", "\n"], ['\r\n', '\n\r', '\r', '\n'], $value @@ -268,13 +244,13 @@ class Exporter "'"; } - $whitespace = str_repeat(' ', (int) (4 * $indentation)); + $whitespace = \str_repeat(' ', (int)(4 * $indentation)); if (!$processed) { $processed = new Context; } - if (is_array($value)) { + if (\is_array($value)) { if (($key = $processed->contains($value)) !== false) { return 'Array &' . $key; } @@ -283,9 +259,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), @@ -296,23 +272,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), @@ -323,28 +299,32 @@ 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); + 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; + 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) @@ -352,7 +332,7 @@ class Exporter /* * PHP 7.2 introduced "resource (closed)". */ - if (gettype($value) === 'resource (closed)') { + if (\gettype($value) === 'resource (closed)') { return true; } @@ -360,7 +340,7 @@ class Exporter * If gettype did not work, attempt to determine whether this is * a closed resource in another way. */ - $isResource = is_resource($value); + $isResource = \is_resource($value); $isNotNonResource = $this->isResource($value); if ($isResource === false && $isNotNonResource === true) { @@ -369,7 +349,7 @@ class Exporter if ($isNotNonResource === true) { try { - $resourceType = @get_resource_type($value); + $resourceType = @\get_resource_type($value); if ($resourceType === 'Unknown') { return true; diff --git a/tests/ExporterTest.php b/tests/ExporterTest.php index 8bc99ef..c507019 100644 --- a/tests/ExporterTest.php +++ b/tests/ExporterTest.php @@ -1,6 +1,6 @@ * @@ -9,22 +9,8 @@ */ namespace SebastianBergmann\Exporter; -use const PHP_VERSION; -use function array_map; -use function chr; -use function fclose; -use function fopen; -use function implode; -use function mb_internal_encoding; -use function mb_language; -use function preg_replace; -use function range; -use Error; -use Exception; use PHPUnit\Framework\TestCase; use SebastianBergmann\RecursionContext\Context; -use SplObjectStorage; -use stdClass; /** * @covers SebastianBergmann\Exporter\Exporter @@ -43,12 +29,12 @@ class ExporterTest extends TestCase public function exportProvider() { - $obj2 = new stdClass; + $obj2 = new \stdClass; $obj2->foo = 'bar'; $obj3 = (object) [1, 2, "Test\r\n", 4, 5, 6, 7, 8]; - $obj = new stdClass; + $obj = new \stdClass; //@codingStandardsIgnoreStart $obj->null = null; //@codingStandardsIgnoreEnd @@ -62,12 +48,12 @@ class ExporterTest extends TestCase $obj->array = ['foo' => 'bar']; $obj->self = $obj; - $storage = new SplObjectStorage; + $storage = new \SplObjectStorage; $storage->attach($obj2); $storage->foo = $obj2; - $resource = fopen('php://memory', 'r'); - fclose($resource); + $resource = \fopen('php://memory', 'r'); + \fclose($resource); return [ 'export null' => [null, 'null'], @@ -76,11 +62,11 @@ class ExporterTest extends TestCase 'export int 1' => [1, '1'], 'export float 1.0' => [1.0, '1.0'], 'export float 1.2' => [1.2, '1.2'], - 'export stream' => [fopen('php://memory', 'r'), 'resource(%d) of type (stream)'], + 'export stream' => [\fopen('php://memory', 'r'), 'resource(%d) of type (stream)'], 'export stream (closed)' => [$resource, 'resource (closed)'], 'export numeric string' => ['1', "'1'"], 'export multidimentional array' => [[[1, 2, 3], [3, 4, 5]], - <<<'EOF' + << Array &1 ( 0 => 1 @@ -97,39 +83,39 @@ EOF ], // \n\r and \r is converted to \n 'export multiline text' => ["this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext", - <<<'EOF' -'this\n -is\n -a\n -very\n -very\n -very\n -very\n -very\n -very\r -long\n\r + << [new stdClass, 'stdClass Object &%x ()'], + 'export empty stdclass' => [new \stdClass, 'stdClass Object &%x ()'], 'export non empty stdclass' => [$obj, - <<<'EOF' + << null 'boolean' => true 'integer' => 1 'double' => 1.2 'string' => '1' - 'text' => 'this\n -is\n -a\n -very\n -very\n -very\n -very\n -very\n -very\r -long\n\r + 'text' => 'this\\n +is\\n +a\\n +very\\n +very\\n +very\\n +very\\n +very\\n +very\\r +long\\n\\r text' 'object' => stdClass Object &%x ( 'foo' => 'bar' @@ -144,7 +130,7 @@ EOF ], 'export empty array' => [[], 'Array &%d ()'], 'export splObjectStorage' => [$storage, - <<<'EOF' + << stdClass Object &%x ( 'foo' => 'bar' @@ -157,11 +143,11 @@ SplObjectStorage Object &%x ( EOF ], 'export stdClass with numeric properties' => [$obj3, - <<<'EOF' + << 1 1 => 2 - 2 => 'Test\r\n + 2 => 'Test\\r\\n ' 3 => 4 4 => 5 @@ -172,24 +158,24 @@ stdClass Object &%x ( EOF ], [ - chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5), - 'Binary String: 0x000102030405', + \chr(0) . \chr(1) . \chr(2) . \chr(3) . \chr(4) . \chr(5), + 'Binary String: 0x000102030405' ], [ - implode('', array_map('chr', range(0x0e, 0x1f))), - 'Binary String: 0x0e0f101112131415161718191a1b1c1d1e1f', + \implode('', \array_map('chr', \range(0x0e, 0x1f))), + 'Binary String: 0x0e0f101112131415161718191a1b1c1d1e1f' ], [ - chr(0x00) . chr(0x09), - 'Binary String: 0x0009', + \chr(0x00) . \chr(0x09), + 'Binary String: 0x0009' ], [ '', - "''", + "''" ], 'export Exception without trace' => [ - new Exception('The exception message', 42), - <<<'EOF' + new \Exception('The exception message', 42), + << 'The exception message' 'string' => '' @@ -201,8 +187,8 @@ Exception Object &%x ( EOF ], 'export Error without trace' => [ - new Error('The exception message', 42), - <<<'EOF' + new \Error('The exception message', 42), + << 'The exception message' 'string' => '' @@ -219,7 +205,7 @@ EOF /** * @dataProvider exportProvider */ - public function testExport($value, $expected): void + public function testExport($value, $expected) { $this->assertStringMatchesFormat( $expected, @@ -227,13 +213,13 @@ EOF ); } - public function testExport2(): void + public function testExport2() { - if (PHP_VERSION === '5.3.3') { + if (\PHP_VERSION === '5.3.3') { $this->markTestSkipped('Skipped due to "Nesting level too deep - recursive dependency?" fatal error'); } - $obj = new stdClass; + $obj = new \stdClass; $obj->foo = 'bar'; $array = [ @@ -251,7 +237,7 @@ EOF $array['self'] = &$array; - $expected = <<<'EOF' + $expected = << 0 'null' => null @@ -259,16 +245,16 @@ Array &%d ( 'integer' => 1 'double' => 1.2 'string' => '1' - 'text' => 'this\n -is\n -a\n -very\n -very\n -very\n -very\n -very\n -very\r -long\n\r + 'text' => 'this\\n +is\\n +a\\n +very\\n +very\\n +very\\n +very\\n +very\\n +very\\r +long\\n\\r text' 'object' => stdClass Object &%x ( 'foo' => 'bar' @@ -284,16 +270,16 @@ text' 'integer' => 1 'double' => 1.2 'string' => '1' - 'text' => 'this\n -is\n -a\n -very\n -very\n -very\n -very\n -very\n -very\r -long\n\r + 'text' => 'this\\n +is\\n +a\\n +very\\n +very\\n +very\\n +very\\n +very\\n +very\\r +long\\n\\r text' 'object' => stdClass Object &%x 'objectagain' => stdClass Object &%x @@ -313,7 +299,7 @@ EOF; public function shortenedExportProvider() { - $obj = new stdClass; + $obj = new \stdClass; $obj->foo = 'bar'; $array = [ @@ -329,7 +315,7 @@ EOF; 'shortened export numeric string' => ['1', "'1'"], // \n\r and \r is converted to \n 'shortened export multilinestring' => ["this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext", "'this\\nis\\na\\nvery\\nvery\\nvery...\\rtext'"], - 'shortened export empty stdClass' => [new stdClass, 'stdClass Object ()'], + 'shortened export empty stdClass' => [new \stdClass, 'stdClass Object ()'], 'shortened export not empty stdClass' => [$obj, 'stdClass Object (...)'], 'shortened export empty array' => [[], 'Array ()'], 'shortened export not empty array' => [$array, 'Array (...)'], @@ -339,7 +325,7 @@ EOF; /** * @dataProvider shortenedExportProvider */ - public function testShortenedExport($value, $expected): void + public function testShortenedExport($value, $expected) { $this->assertSame( $expected, @@ -350,42 +336,42 @@ EOF; /** * @requires extension mbstring */ - public function testShortenedExportForMultibyteCharacters(): void + public function testShortenedExportForMultibyteCharacters() { - $oldMbLanguage = mb_language(); - mb_language('Japanese'); - $oldMbInternalEncoding = mb_internal_encoding(); - mb_internal_encoding('UTF-8'); + $oldMbLanguage = \mb_language(); + \mb_language('Japanese'); + $oldMbInternalEncoding = \mb_internal_encoding(); + \mb_internal_encoding('UTF-8'); try { $this->assertSame( - "'いろはにほへとちりぬるをわかよたれそつねならむうゐのおくや...しゑひもせす'", - $this->trimNewline($this->exporter->shortenedExport('いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす')) + "'いろはにほへとちりぬるをわかよたれそつねならむうゐのおくや...しゑひもせす'", + $this->trimNewline($this->exporter->shortenedExport('いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす')) ); - } catch (Exception $e) { - mb_internal_encoding($oldMbInternalEncoding); - mb_language($oldMbLanguage); + } catch (\Exception $e) { + \mb_internal_encoding($oldMbInternalEncoding); + \mb_language($oldMbLanguage); throw $e; } - mb_internal_encoding($oldMbInternalEncoding); - mb_language($oldMbLanguage); + \mb_internal_encoding($oldMbInternalEncoding); + \mb_language($oldMbLanguage); } public function provideNonBinaryMultibyteStrings() { return [ - [implode('', array_map('chr', range(0x09, 0x0d))), 9], - [implode('', array_map('chr', range(0x20, 0x7f))), 96], - [implode('', array_map('chr', range(0x80, 0xff))), 128], + [\implode('', \array_map('chr', \range(0x09, 0x0d))), 9], + [\implode('', \array_map('chr', \range(0x20, 0x7f))), 96], + [\implode('', \array_map('chr', \range(0x80, 0xff))), 128], ]; } /** * @dataProvider provideNonBinaryMultibyteStrings */ - public function testNonBinaryStringExport($value, $expectedLength): void + public function testNonBinaryStringExport($value, $expectedLength) { $this->assertRegExp( "~'.{{$expectedLength}}'\$~s", @@ -393,24 +379,29 @@ EOF; ); } - public function testNonObjectCanBeReturnedAsArray(): void + public function testNonObjectCanBeReturnedAsArray() { $this->assertEquals([true], $this->exporter->toArray(true)); } - public function testIgnoreKeysInValue(): void + public function testIgnoreKeysInValue() { // Find out what the actual use case was with the PHP bug - $array = []; + $array = []; $array["\0gcdata"] = ''; $this->assertEquals([], $this->exporter->toArray((object) $array)); } + private function trimNewline($string) + { + return \preg_replace('/[ ]*\n/', "\n", $string); + } + /** * @dataProvider shortenedRecursiveExportProvider */ - public function testShortenedRecursiveExport(array $value, string $expected): void + public function testShortenedRecursiveExport(array $value, string $expected) { $this->assertEquals($expected, $this->exporter->shortenedRecursiveExport($value)); } @@ -426,25 +417,20 @@ EOF; 'export float 1.2' => [[1.2], '1.2'], 'export numeric string' => [['1'], "'1'"], 'export with numeric array key' => [[2 => 1], '1'], - 'export with assoc array key' => [['foo' => 'bar'], '\'bar\''], + 'export with assoc array key' => [['foo' => 'bar'], '\'bar\''], 'export multidimentional array' => [[[1, 2, 3], [3, 4, 5]], 'array(1, 2, 3), array(3, 4, 5)'], - 'export object' => [[new stdClass], 'stdClass Object ()'], + 'export object' => [[new \stdClass], 'stdClass Object ()'], ]; } - public function testShortenedRecursiveOccurredRecursion(): void + public function testShortenedRecursiveOccurredRecursion() { $recursiveValue = [1]; - $context = new Context(); + $context = new Context(); $context->add($recursiveValue); $value = [$recursiveValue]; $this->assertEquals('*RECURSION*', $this->exporter->shortenedRecursiveExport($value, $context)); } - - private function trimNewline($string) - { - return preg_replace('/[ ]*\n/', "\n", $string); - } } From 44131c410c6af1cb368b6a68140bb6447d9e4244 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 11 Nov 2021 14:47:20 +0100 Subject: [PATCH 4/6] PHP 7.0 does not support void return type --- tests/ExporterTest.php | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/tests/ExporterTest.php b/tests/ExporterTest.php index c507019..9dcd2c5 100644 --- a/tests/ExporterTest.php +++ b/tests/ExporterTest.php @@ -17,16 +17,6 @@ use SebastianBergmann\RecursionContext\Context; */ class ExporterTest extends TestCase { - /** - * @var Exporter - */ - private $exporter; - - protected function setUp(): void - { - $this->exporter = new Exporter; - } - public function exportProvider() { $obj2 = new \stdClass; @@ -209,7 +199,7 @@ EOF { $this->assertStringMatchesFormat( $expected, - $this->trimNewline($this->exporter->export($value)) + $this->trimNewline((new Exporter)->export($value)) ); } @@ -293,7 +283,7 @@ EOF; $this->assertStringMatchesFormat( $expected, - $this->trimNewline($this->exporter->export($array)) + $this->trimNewline((new Exporter)->export($array)) ); } @@ -329,7 +319,7 @@ EOF; { $this->assertSame( $expected, - $this->trimNewline($this->exporter->shortenedExport($value)) + $this->trimNewline((new Exporter)->shortenedExport($value)) ); } @@ -346,7 +336,7 @@ EOF; try { $this->assertSame( "'いろはにほへとちりぬるをわかよたれそつねならむうゐのおくや...しゑひもせす'", - $this->trimNewline($this->exporter->shortenedExport('いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす')) + $this->trimNewline((new Exporter)->shortenedExport('いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす')) ); } catch (\Exception $e) { \mb_internal_encoding($oldMbInternalEncoding); @@ -375,13 +365,13 @@ EOF; { $this->assertRegExp( "~'.{{$expectedLength}}'\$~s", - $this->exporter->export($value) + (new Exporter)->export($value) ); } public function testNonObjectCanBeReturnedAsArray() { - $this->assertEquals([true], $this->exporter->toArray(true)); + $this->assertEquals([true], (new Exporter)->toArray(true)); } public function testIgnoreKeysInValue() @@ -390,7 +380,7 @@ EOF; $array = []; $array["\0gcdata"] = ''; - $this->assertEquals([], $this->exporter->toArray((object) $array)); + $this->assertEquals([], (new Exporter)->toArray((object) $array)); } private function trimNewline($string) @@ -403,7 +393,7 @@ EOF; */ public function testShortenedRecursiveExport(array $value, string $expected) { - $this->assertEquals($expected, $this->exporter->shortenedRecursiveExport($value)); + $this->assertEquals($expected, (new Exporter)->shortenedRecursiveExport($value)); } public function shortenedRecursiveExportProvider() @@ -431,6 +421,6 @@ EOF; $value = [$recursiveValue]; - $this->assertEquals('*RECURSION*', $this->exporter->shortenedRecursiveExport($value, $context)); + $this->assertEquals('*RECURSION*', (new Exporter)->shortenedRecursiveExport($value, $context)); } } From 0c32ea2e40dbf59de29f3b49bf375176ce7dd8db Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 11 Nov 2021 14:51:24 +0100 Subject: [PATCH 5/6] Do not run PHP-CS-Fixer in CI (until I figure out which change(s) cause the code to not work with PHP 7.0) --- .github/workflows/ci.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa5df6a..4b3acfb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,18 +7,6 @@ on: name: "CI" jobs: - coding-guidelines: - name: "Coding Guidelines" - - runs-on: "ubuntu-latest" - - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - - name: "Run friendsofphp/php-cs-fixer" - run: "php ./tools/php-cs-fixer fix --dry-run --show-progress=dots --using-cache=no --verbose" - tests: name: "Tests" From 65e8b7db476c5dd267e65eea9cab77584d3cfff9 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 11 Nov 2021 15:18:36 +0100 Subject: [PATCH 6/6] Prepare release --- ChangeLog.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 580be5a..c691e81 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,12 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. +## [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 @@ -48,6 +54,7 @@ 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.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