Skip to content

Conversation

@MGatner
Copy link
Member

@MGatner MGatner commented Feb 22, 2021

Description
This one is a bit obscure but currently Factories is failing to check the instanceOf option for classes that match an existing shared instance. An example:

namespace Bar\Models
class UserModel
{
}

=======

namespace Foo\Models;
class UserModel
{
}

=======

$model = Factories::model('UserModel'); // Bar\Models\UserModel
$model = Factories::model('UserModel', ['instanceOf' => 'Foo\Models\UserModel']); // Bar\Models\UserModel

This PR adds a test to demonstrate the issue and fixes it by running shared instances through the verifyInstanceOf() method.

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • n/a User guide updated
  • Conforms to style guide

@MGatner MGatner merged commit 42f6667 into codeigniter4:develop Feb 23, 2021
@MGatner MGatner deleted the bugfix-factories-instance branch February 23, 2021 23:41
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.

2 participants