rendering with strict=true does not throw for missing nested variables in context

Open
#23 1 comment 0 reactions 0 assignees View on GitHub

@hubermat is already working on this.

Since Oct 6, 2023.

  • #24 by @hubermat — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
php
Domain
backend

Research direction

Start at Context::findVariableInContext and compare its nested-variable handling with Context::get('bogusvariable', true). Verify the referenced pull request before starting work; done means a missing nested variable under strict checking throws the expected exception while existing nested lookups continue to work.

Written by the indexing model from the issue text.

Description

When I have the following nested context:

[
  'person' => [
    'firstName' => 'Foo',
    'lastName' => 'Bar',
    'zip' => '12345'
  ]
]

and want to get variables from this context with strict checking (should throw an exception, if the variable does not exist), it throws an exception correctly for $context->get('bogusvariable', true), but not for $context->get('person.city', true).
From looking at the code, I found out that for nested variables the check for $strict is missing in Context::findVariableInContext.

Linked pull request fixes this issue.

Dominant language
PHP
Stars
77
Forks
34
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from salesforce/handlebars-php

All issues in salesforce/handlebars-php

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.