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

Set dynamic properties with predicate #13

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

veewee
Copy link
Owner

@veewee veewee commented Jun 12, 2024

Q A
Type bug/
BC Break no
Fixed issues

Summary

The new predicate system in properties_set did not take into account new properties on dynamic classes.
This PR fixes that:

$x = new \stdClass();
$x->foo = 'foo';

$actual = properties_set($x, ['bar' => 'bar']);

static::assertNotSame($x, $actual);
static::assertInstanceOf(\stdClass::class, $actual);
static::assertSame($actual->foo, 'foo');
static::assertSame($actual->bar, 'bar');
$x = new \stdClass();
$x->foo = 'foo';

$actual = properties_set(
    $x,
    [
        'foo' => 'baz',
        'bar' => 'bar',
    ],
    static fn (ReflectedProperty $property): bool => false
);

static::assertNotSame($x, $actual);
static::assertInstanceOf(\stdClass::class, $actual);
static::assertSame($actual->foo, 'foo');
static::assertSame($actual->bar, 'bar');

@veewee veewee force-pushed the set-dynamic-props-with-predicate branch from 0beb132 to ed58316 Compare June 12, 2024 07:36
@veewee veewee force-pushed the set-dynamic-props-with-predicate branch from ed58316 to 05ad673 Compare June 12, 2024 07:43
@veewee veewee merged commit 93e22ef into main Jun 12, 2024
18 checks passed
@veewee veewee deleted the set-dynamic-props-with-predicate branch June 12, 2024 07:44
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.

1 participant