Skip to content
Open
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
10 changes: 5 additions & 5 deletions docs/book/v3/adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ The [JSON](https://wikipedia.org/wiki/JavaScript_Object_Notation) adapter provid

Available options include:

| Option | Data Type | Default Value |
|---------------------------|-----------------------------|---------------------------------|
| `cycle_check` | `boolean` | `false` |
| `object_decode_type` | `Laminas\Json\Json::TYPE_*` | `Laminas\Json\Json::TYPE_ARRAY` |
| `enable_json_expr_finder` | `boolean` | `false` |
| Option | Data Type | Default Value | Notes |
|---------------------------|-----------------------------|---------------------------------|-------------------------------------------------------|
| `cycle_check` | `boolean` | `false` | **Deprecated**. Will be remvoed in v4 |
| `object_decode_type` | `Laminas\Json\Json::TYPE_*` | `Laminas\Json\Json::TYPE_ARRAY` | **Deprecated**. Will be replaced by assoc_array in v4 |
| `enable_json_expr_finder` | `boolean` | `false` | **Deprecated**. Will be remvoed in v4 |

## The PhpCode Adapter

Expand Down
27 changes: 26 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="6.14.3@d0b040a91f280f071c1abcb1b77ce3822058725a">
<files psalm-version="6.15.1@28dc127af1b5aecd52314f6f645bafc10d0e11f9">
<file src="src/Adapter/Json.php">
<DeprecatedMethod>
<code><![CDATA[getCycleCheck]]></code>
<code><![CDATA[getEnableJsonExprFinder]]></code>
<code><![CDATA[getObjectDecodeType]]></code>
<code><![CDATA[getObjectDecodeType]]></code>
</DeprecatedMethod>
<MoreSpecificImplementedParamType>
<code><![CDATA[$options]]></code>
</MoreSpecificImplementedParamType>
Expand All @@ -9,11 +15,30 @@
</NonInvariantDocblockPropertyType>
</file>
<file src="src/Adapter/JsonOptions.php">
<DeprecatedMethod>
<code><![CDATA[getObjectDecodeType]]></code>
<code><![CDATA[setObjectDecodeType]]></code>
</DeprecatedMethod>
<PossiblyUnusedMethod>
<code><![CDATA[setAssocArray]]></code>
<code><![CDATA[setCycleCheck]]></code>
<code><![CDATA[setEnableJsonExprFinder]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/Adapter/JsonTest.php">
<DeprecatedMethod>
<code><![CDATA[getCycleCheck]]></code>
<code><![CDATA[getEnableJsonExprFinder]]></code>
<code><![CDATA[getObjectDecodeType]]></code>
<code><![CDATA[setObjectDecodeType]]></code>
</DeprecatedMethod>
</file>
<file src="test/GenericSerializerFactoryTest.php">
<DeprecatedMethod>
<code><![CDATA[getCycleCheck]]></code>
<code><![CDATA[getCycleCheck]]></code>
</DeprecatedMethod>
</file>
<file src="src/Adapter/PhpSerialize.php">
<MoreSpecificImplementedParamType>
<code><![CDATA[$options]]></code>
Expand Down
30 changes: 30 additions & 0 deletions src/Adapter/JsonOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,53 @@ final class JsonOptions extends AdapterOptions
/** @var LaminasJson::TYPE_* */
protected int $objectDecodeType = LaminasJson::TYPE_ARRAY;

public function setAssocArray(bool $flag): void
{
$this->setObjectDecodeType($flag ? LaminasJson::TYPE_ARRAY : LaminasJson::TYPE_OBJECT);
}

public function isAssocArray(): bool
{
return $this->getObjectDecodeType() === LaminasJson::TYPE_ARRAY;
}

/**
* @deprecated Since 3.3.0 - This method will be removed in version 4.0 without replacement.
*/
public function setCycleCheck(bool $flag): void
{
$this->cycleCheck = $flag;
}

/**
* @deprecated Since 3.3.0 - This method will be removed in version 4.0 without replacement.
*/
public function getCycleCheck(): bool
{
return $this->cycleCheck;
}

/**
* @deprecated Since 3.3.0 - This method will be removed in version 4.0 without replacement.
*/
public function setEnableJsonExprFinder(bool $flag): void
{
$this->enableJsonExprFinder = $flag;
}

/**
* @deprecated Since 3.3.0 - This method will be removed in version 4.0 without replacement.
*/
public function getEnableJsonExprFinder(): bool
{
return $this->enableJsonExprFinder;
}

/**
* @deprecated Use the `setAssocArray` method
*
* @see setAssocArray()
*
* @param LaminasJson::TYPE_* $type
* @throws Exception\InvalidArgumentException
*/
Expand All @@ -57,6 +83,10 @@ public function setObjectDecodeType(int $type): void
}

/**
* @deprecated Use the `isAssocArray` method
*
* @see isAssocArray()
*
* @return LaminasJson::TYPE_*
*/
public function getObjectDecodeType(): int
Expand Down
1 change: 1 addition & 0 deletions test/Adapter/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function testAdapterAcceptsOptions(): void
self::assertEquals(true, $adapter->getOptions()->getCycleCheck());
self::assertEquals(true, $adapter->getOptions()->getEnableJsonExprFinder());
self::assertEquals(1, $adapter->getOptions()->getObjectDecodeType());
self::assertEquals(true, $adapter->getOptions()->isAssocArray());
}

public function testSerializeString(): void
Expand Down