Skip to content

Commit

Permalink
refactor: deprecate using proxy with anonymous class
Browse files Browse the repository at this point in the history
  • Loading branch information
nikophil committed Jan 17, 2024
1 parent a20468d commit 61a26f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public function __construct(
);
}

if ((new \ReflectionClass($object::class))->isAnonymous()) {
trigger_deprecation(
'zenstruck\foundry', '1.37.0',
'Using a proxy factory with an anonymous class is deprecated and will throw an error in Foundry 2.0. Use "%s" instead.',
ObjectFactory::class,
$object::class,
);
}

$this->class = $object::class;
$this->autoRefresh = Factory::configuration()->defaultProxyAutoRefresh();
}
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/ProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function can_force_get_and_set_non_public_properties(): void

/**
* @test
* @group legacy
*/
public function can_access_wrapped_objects_properties(): void
{
Expand Down

0 comments on commit 61a26f0

Please sign in to comment.