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

The __call method of class Model prevents calling private method isFillable #110

Closed
yohancreemers opened this issue Jan 25, 2017 · 2 comments

Comments

@yohancreemers
Copy link
Contributor

yohancreemers commented Jan 25, 2017

The __call method of class Model (added in 8f4e812) prevents calling private method isFillable.

Code example:

$account = new Account($connection);
if ($account->isFillable('Description') )
{
	$account->Description = $sDescription;
}

Is there a reason why isFillable shouldn't be accessible on an instance?
Possible solutions to make the code example work again:

  1. Change isFillable in a public function, so it's call isn't handled by __call.
  2. Let __call test if $name doesn't refer to a method, before handling it as a property.

What's your opinion?

@GewoonRoy
Copy link

When calling $account->Description = $sDescription it will call the __set method of class Model which will then call the isFillable method automatically to check if the given attribute is fillable. So it would not be necessary to call it outside of this instance.

It is possible to check the Account for the expected attributes after creating the instance. But in my opinion this would be overhead.

@yohancreemers
Copy link
Contributor Author

Thanks @GewoonRoy, you're right.
There is indeed no need to test if the attribute is fillable before setting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants