Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php declare(strict_types=1); class dotNotationUtilTest extends PHPUnit\Framework\TestCa..

Decoded Output download

<?php
declare(strict_types=1);

class dotNotationUtilTest extends PHPUnit\Framework\TestCase {

	/**
	 * @return Traversable<array{array<string,mixed>,string,string}>
	 */
	public function provideJsonDots(): Traversable {
		$json = <<<json
		{
			"hello": "world",
			"deeper": {
				"hello": "again"
			},
			"items": [
				{
					"meta": {"title": "first"}
				},
				{
					"meta": {"title": "second"}
				}
			]
		}
		json;
		$array = json_decode($json, true);

		yield [$array, 'hello', 'world'];
		yield [$array, 'deeper.hello', 'again'];
		yield [$array, 'items.0.meta.title', 'first'];
		yield [$array, 'items[0].meta.title', 'first'];
		yield [$array, 'items.1.meta.title', 'second'];
		yield [$array, 'items[1].meta.title', 'second'];
	}

	/**
	 * @dataProvider provideJsonDots
	 * @param array<string,mixed> $array
	 */
	public function testJsonDots(array $array, string $key, string $expected): void {
		$value = FreshRSS_dotNotation_Util::get($array, $key);
		self::assertEquals($expected, $value);
	}
}
 ?>

Did this file decode correctly?

Original Code

<?php
declare(strict_types=1);

class dotNotationUtilTest extends PHPUnit\Framework\TestCase {

	/**
	 * @return Traversable<array{array<string,mixed>,string,string}>
	 */
	public function provideJsonDots(): Traversable {
		$json = <<<json
		{
			"hello": "world",
			"deeper": {
				"hello": "again"
			},
			"items": [
				{
					"meta": {"title": "first"}
				},
				{
					"meta": {"title": "second"}
				}
			]
		}
		json;
		$array = json_decode($json, true);

		yield [$array, 'hello', 'world'];
		yield [$array, 'deeper.hello', 'again'];
		yield [$array, 'items.0.meta.title', 'first'];
		yield [$array, 'items[0].meta.title', 'first'];
		yield [$array, 'items.1.meta.title', 'second'];
		yield [$array, 'items[1].meta.title', 'second'];
	}

	/**
	 * @dataProvider provideJsonDots
	 * @param array<string,mixed> $array
	 */
	public function testJsonDots(array $array, string $key, string $expected): void {
		$value = FreshRSS_dotNotation_Util::get($array, $key);
		self::assertEquals($expected, $value);
	}
}

Function Calls

None

Variables

None

Stats

MD5 1cb9c01dce4ebf2411532476fede181a
Eval Count 0
Decode Time 100 ms