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

Error on missing object property #5

Closed
juvid opened this issue Dec 8, 2021 · 4 comments
Closed

Error on missing object property #5

juvid opened this issue Dec 8, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@juvid
Copy link

juvid commented Dec 8, 2021

Hello!

If I assign an object (e.g. a Laravel Eloquent model) as a variable and in the template I reference to a non-existent property of the object, the renderer throws an error instead of the UndefinedSymbolException, so I don't know, which property is missing.

TypeError(code: 0): array_key_exists(): Argument # 2 ($array) must be of type array, App\Models\Product given at /var/www/vendor/wol-soft/php-micro-template/src/Render.php:243

Thank You

@wol-soft
Copy link
Owner

wol-soft commented Dec 9, 2021

Hi @juvid,

are you trying to access public properties of the object? That would be a feature which is currently not supported. The library currently only supports calling methods on assigned objects.

Cheers

@juvid
Copy link
Author

juvid commented Dec 9, 2021

Hi,
yes, I am trying to access a public property with value null (isset() = false). If it exists and not null it works perfect, thanks to ArrayAccess implementation. Only the array_key_exists function throws a type error in the previous case.

@wol-soft
Copy link
Owner

wol-soft commented Dec 9, 2021

Hi,

I've added a patch for the issue in 1.7.0 as well as the possibility to directly access public object properties from the template.

Cheers.

@wol-soft wol-soft added the bug Something isn't working label Dec 9, 2021
@juvid
Copy link
Author

juvid commented Dec 9, 2021

Thank you for the fast response, works great.

@juvid juvid closed this as completed Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants