Skip to content
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

fix(UndefinedConstraint): add attribute #[AllowDynamicProperties] #695

Merged

Conversation

rtm-ctrlz
Copy link
Contributor

This change will workaround deprecation warning while applying defaults with php8.2

php8.2 deprecations

example code

use JsonSchema\Constraints\Constraint;
use JsonSchema\Validator;

$schema = [
    'type'                 => 'object',
    'required'             => ['prop1'],
    'additionalProperties' => false,
    'properties'           => [
        'prop1' => [
            'type'                 => 'object',
            'required'             => ['prop2'],
            'additionalProperties' => false,
            'properties'           => [
                'prop2' => [
                    'type'    => 'array',
                    'items'   => [
                        'type' => 'string',
                    ],
                    'default' => ['test'],
                ],
            ],
        ],
    ],
];

$data      = new stdClass();
$validator = new Validator();
$validator->validate(
    $data,
    $schema,
    Constraint::CHECK_MODE_APPLY_DEFAULTS
);
  • php 5.3-8.1 - no warning
  • php 8.2 - deprecation warning
PHP Deprecated:  Creation of dynamic property JsonSchema\Constraints\UndefinedConstraint::$prop2 is deprecated in ...

This change is safe for all php versions >=5.3.0 - online check with 3v4l.org

…o allow applying defaults without deprecation warning
@taka-oyama
Copy link

@erayd May we please get this merged so we don't see the deprecation warning on PHP 8.2?

@erayd erayd merged commit 9336297 into jsonrainbow:master Sep 5, 2023
@taka-oyama
Copy link

Thank you!

@taka-oyama
Copy link

Hi @erayd, sorry to bother you again, but would it be possible to get a release for this fix?

I made the release description below to make it easier for you. Thanks.


Release: v5.2.13

- fix(UndefinedConstraint): add attribute #[AllowDynamicProperties] (#695)

@taka-oyama
Copy link

@Seldaek Hi, sorry to bother you, but would it be possible to create a release that contains this fix? (Asking because I noticed you made the latest two releases)

@erayd
Copy link
Contributor

erayd commented Sep 20, 2023

Would it be possible to get a release for this fix?

@taka-oyama This is actually waiting for a backport release. You've put this PR on the master branch, which is where it's supposed to go (thank you 🙂), but note that the master branch is the v6 track, which doesn't have a release yet. I'm desperately short on time, but hoping to find a moment to do this over the weekend. If @Seldaek beats me to it [please do if you have the time!], he's welcome to, but I'm aware he is also quite busy.

Once backported to 5.x.x, we can roll a release for it.

@taka-oyama
Copy link

Thank you for letting me know! Very grateful for the response 🙏🏻

@Seldaek
Copy link
Contributor

Seldaek commented Sep 20, 2023

@erayd sorry but I'll have to pass :)

@taka-oyama
Copy link

I created a backport pull request #695 for your convenience.

erayd pushed a commit that referenced this pull request Sep 26, 2023
… without deprecation warning (#695) (#701)

Co-authored-by: Ilya Urvachev <rtm@ctrlz.ru>
@erayd
Copy link
Contributor

erayd commented Sep 26, 2023

Thanks @taka-oyama 🙂. Merged & released as v5.2.13.

@rtm-ctrlz rtm-ctrlz deleted the fix/php8.2/dynamic-property-for-defaults branch January 23, 2024 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants