Skip to content

added CachingIterator::__toString()#175

Merged
dg merged 1 commit intonette:masterfrom
vlastavesely:string
Feb 8, 2018
Merged

added CachingIterator::__toString()#175
dg merged 1 commit intonette:masterfrom
vlastavesely:string

Conversation

@vlastavesely
Copy link
Copy Markdown
Contributor

When an iterator has been used in a template just as {$iterator} and not
as {$iterator->counter} (as documented), it has thrown a kind of confusing
error:

Fatal error: Method Latte\Runtime\CachingIterator::__toString() must not
throw an exception, caught BadMethodCallException: Latte\Runtime\CachingIterator
does not fetch string value (see CachingIterator::__construct) in PATH on line 0

This patch allows conversion to a string by returning the current counter.

  • bug fix? yes
  • BC break? no

When an iterator has been used in a template just as `{$iterator}` and not
as `{$iterator->counter}` (as documented), it has thrown a kind of confusing
error:

  Fatal error: Method Latte\Runtime\CachingIterator::__toString() must not
  throw an exception, caught BadMethodCallException: Latte\Runtime\CachingIterator
  does not fetch string value (see CachingIterator::__construct) in *PATH* on line 0

This patch allows conversion to a string by returning the current counter.
@dg
Copy link
Copy Markdown
Member

dg commented Feb 8, 2018

Thanks

@dg dg merged commit da5dcda into nette:master Feb 8, 2018
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

Successfully merging this pull request may close these issues.

2 participants