Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow pseudo-callable to be output as string or boolean #33

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

Closed
kylekatarnls opened this issue Apr 5, 2020 · 0 comments
Closed

Allow pseudo-callable to be output as string or boolean #33

kylekatarnls opened this issue Apr 5, 2020 · 0 comments
Assignees

Comments

@kylekatarnls
Copy link
Member

kylekatarnls commented Apr 5, 2020

Fixes BKWLD/laravel-pug#82

Observed:
When the dot fails to know if the right operand is a field/property of the left operand, it returns an array [left, right] so it can be tried as a callable if called.

  1. When this array is passed to a condition (evaluated as a boolean) it's always true even if the right operand does not match anything truthy in the left operand.
  2. When it's sent to the output (evaluated as a string), it fails because PHP cannot cast arrays to string.

Expected:

  1. When this array is passed to a condition (evaluated as a boolean) it's always true even if the right operand does not match anything truthy in the left operand.
  2. When it's sent to the output (evaluated as a string), it fails because PHP cannot cast arrays to string.

Solution proposal:
This array should be wrapped in an object that:

  • can be cast to string according to the property/field value;
  • is callable as the original array would be;
  • provies a __toBoolean method that other libraries (like Phug/Pug-php) could use to cast it as a boolean.
@kylekatarnls kylekatarnls self-assigned this Apr 5, 2020
kylekatarnls added a commit that referenced this issue Apr 5, 2020
@kylekatarnls kylekatarnls changed the title Allow pseudo-callable to be output as string Allow pseudo-callable to be output as string or boolean Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant