Code Monkey home page Code Monkey logo

Comments (4)

meetmatt avatar meetmatt commented on August 30, 2024

Hi,

  1. I agree with you, it seems like this check doesn't make sense any more after 6bb3025

2a. I can only imagine a strange case when due to race condition the template file does no longer exist after it has been checked on L149 but before it's actually included. With require you will still get an exception in this case. But I'm sure there must have been a more simple reason, also it's possible that the check was added later, didn't check the actual commit log.

2b. try/catch wraps the required template, rather than extract, and is used to not allow template to render partially in case it throws an exception (e.g. somewhere in the middle of the included template you have a fatal error). As you may see in both catch blocks the output buffer gets cleaned before re-throwing the initial exception.

from php-view.

meetmatt avatar meetmatt commented on August 30, 2024

2b. Actually I found a case when extract will throw an exception: when the data contains "this" key. It will result in "Fatal error: Uncaught Error: Cannot re-assign $this".

from php-view.

akrabat avatar akrabat commented on August 30, 2024

2a. Given that include and require are identical when the file exists, it makes no odds which is used. include was the original author's preference.

from php-view.

akrabat avatar akrabat commented on August 30, 2024
  1. It turns out that func_get_arg(0) picks up the value of the first parameter at the point that it's called, not at the point it was passed into the function. See https://3v4l.org/nGGOk

We could use extract($data, EXTR_SKIP);, which would silently ignore $data['template'], but I think that would result in confusion compared to an explicit error.

from php-view.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.