phptal / PHPTAL

PHP Template Attribute Language — template engine for XSS-proof well-formed XHTML and HTML5 pages
http://phptal.org
GNU Lesser General Public License v2.1
175 stars 43 forks source link

Undefined property: PHPTAL_Php_CodeWriter::$_indentation #48

Closed herndlm closed 8 years ago

herndlm commented 8 years ago

Hi there,

I'm using the latest PHPTAL 1.3.0 via pear and have a project that catches notices and I get the following:

Array
(
    [type] => 8
    [message] => Undefined property: PHPTAL_Php_CodeWriter::$_indentation
    [file] => /usr/share/pear/PHPTAL/Php/CodeWriter.php
    [line] => 143
)

There seem to be cases where this property never gets created but the "indent" method tries to access and modify it. Can I help debugging this or do you have a fix for me?

Potherca commented 8 years ago

Hi! Thanks for taking the time to report this.

I've delved into this a bit. Looking in the code of PHPTAL_Php_CodeWriter, the private property $_indentation is set to 0 when the class is instantiated. The bug you describe has been reported and fixed previously in 2013.

Can you confirm the source-code you have does indeed have private $_indentation = 0; on line 502 of PHPTAL_Php_CodeWriter.php?

If this is indeed the case, do you happen to have a reproducible use-case so we can confirm this behaviour?

herndlm commented 8 years ago

Hi, thx for looking into this. Yes, this is set to 0 as in

$ grep -n '$_indentation' /usr/share/pear/PHPTAL/Php/CodeWriter.php
502:    private $_indentation = 0;

I don't have a use-case right now, but I'll try to find / create one. Thx again

EDIT: sorry the error was from our live system and I did the grep on the testing system. looks like phptal is not up-to-date on the live system (we have 1.2.2 there). sorry for bothering you

herndlm commented 8 years ago

Fyi while upgrading via pear we noticed that http://phptal.org/latest.tar.gz does currently not point to the latest (1.3.0) version but to 1.2.2 instead. Also we had to download the file manually because pear threw some SSL errors and "pear upgrade" did also not work because of conflicting files. Uninstalling and a fresh "pear install" finally worked. frustrating pear..

Potherca commented 8 years ago

sorry for bothering you

Things should work and it can be frustrating when they don't. We are here to help so no need to apologise!

Although @Ocramius and myself are active maintainers of this repository, we do not have access/control over http://phptal.com/. I'll take this up with @pornel in a separate issue and see what we can do to resolve this.

In closing: there has been some discussion on eventually dropping PEAR support in favour of Composer. This is bound to happen at some point in the future, so it might be worth the effort of preparing for that outcome.