Skip to content

Type check first parameter for Json::stringToObject() #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: 2.0-dev
Choose a base branch
from
Draft
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
15 changes: 14 additions & 1 deletion src/Format/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use Joomla\Registry\Factory;
use Joomla\Registry\FormatInterface;
use RuntimeException;

/**
* JSON format handler for Registry.
Expand Down Expand Up @@ -50,9 +49,23 @@ public function objectToString($object, array $options = [])
*
* @throws \RuntimeException
* @since 1.0.0
* @since __DEPLOY_VERSION__ Passing non-string values as first parameter is deprecated and will issue an
* E_USER_DEPRECATED warning. It will cause an error in 3.0.
*/
public function stringToObject($data, array $options = ['processSections' => false])
{
if (!\is_string($data)) {
\trigger_error(
\sprintf(
'Passing non-string values as first parameter to %s is deprecated and will cause an error in 3.0',
__METHOD__
),
E_USER_DEPRECATED
);

$data = (string) $data;
}

$data = \trim($data);

if (empty($data)) {
Expand Down