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

instanceof cannot be called on return value of a function Smarty-3.1.39 #677

Open
oschonrock opened this issue Oct 1, 2021 · 4 comments

Comments

@oschonrock
Copy link

oschonrock commented Oct 1, 2021

this works

{if $object instanceof SomeClass}yes{/if}

This does not (eventhough it used to under php 7.4 and Smarty 3.1.14). Problem occurs with php8.0 and pph7.4

{if get_object() instanceof SomeClass}yes{/if}

workaround is:

{$object = get_object()}
{if $object instanceof SomeClass}yes{/if}

somewhat related to
#191

@oschonrock oschonrock changed the title instanceof cannot be called on return value of a function under php 8.0 and Smarty-3.1.39 instanceof cannot be called on return value of a function Smarty-3.1.39 Oct 1, 2021
@sergant210
Copy link

It is bad practice to use application logic in views.

@oschonrock
Copy link
Author

How is get_object() instanceof any more "application logic" than $object instanceof?

The point is: It used to work in smarty 3.1.14 and it does not in 3.1.39. So it is a regression, unless it has been intentionally removed?

@sergant210
Copy link

instanceof is application logic. Do this check in the controller.

@oschonrock
Copy link
Author

oschonrock commented Oct 15, 2021

It's a null check. This is pure opinion/style.

We have been using smarty for 18years.

instanceof has worked since v3. It works in 3.1.14 and in 3.1.39

but f() instanceof works only in the former.

Is this an intentional removal of a feature in a minor version change, or is this a regression which you are justifying with an opinion about style?

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

No branches or pull requests

2 participants