Skip to content

Commit

Permalink
Merge pull request #1 from donkeyDau/hotfix/php7-comp
Browse files Browse the repository at this point in the history
PHP7 compatibility preg_replace with /e flag
Thanks @donkeyDau
  • Loading branch information
adriengibrat committed May 3, 2016
2 parents b721b1e + 51b1351 commit 7cd5857
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function set ( $name, $value = false, $safe = false ) {
$this->set( $_name, $_value, $value );
return $this;
}
public function indent ( $indent = 1, $indentation = "\t" ) {
public function indent ( $indent = 1, $indentation = " " ) {
$this->_indent = implode( '', array_fill( 0, $indent, $indentation ) );
return $this;
}
Expand All @@ -114,7 +114,7 @@ public function exchangeArray ( $array ) {
return parent::exchangeArray( $array );
}
public function __toString () {
return $this->cached( $this->id() ) ?: $this->cache();
return $this->cached( $this->id() ) ?: $this->caching();
}
protected function id ( $id = null ) {
if ( $id === false )
Expand All @@ -123,11 +123,11 @@ protected function id ( $id = null ) {
return $id;
return $this->_id ?: ( $this->_id = md5( serialize( $this ) ) );
}
public function indent ( $indent = 1, $indentation = "\t" ) {
public function indent ( $indent = 1, $indentation = " " ) {
$this->id( false );
return parent::indent( $indent, $indentation );
}
public function cache ( $id = null ) {
public function caching ( $id = null ) {
return self::$_cache[ $this->id( $id ) ] = $this->render();
}
public function cached ( $id = null ) {
Expand All @@ -146,10 +146,10 @@ static public function init ( $template = null ) {
return new self( $template );
}
public function __toString () {
return parent::cached( $this->id() ) ?: parent::cache();
return parent::cached( $this->id() ) ?: parent::caching();
}
public function __call ( $method, $arguments ) {
$method = __NAMESPACE__ . '\\' . preg_replace('/(^|_)([a-z])/uie', '"$1".strtoupper("$2")', $method );
$method = __NAMESPACE__ . '\\' . preg_replace_callback('/(^|_)([a-z])/ui', create_function ('$matches', 'return "$matches[1]".strtoupper($matches[2]);'), $method );
if ( class_exists( $method ) && is_callable( $method . '::init' ) )
return call_user_func_array( $method . '::init', $arguments );
}
Expand All @@ -169,7 +169,7 @@ protected function render () {
ob_end_clean();
return $this->_indent( $buffer );
}
public function cache ( $id = null, $path = null ) {
public function caching ( $id = null, $path = null ) {
self::$_cache[ $cache = $this->id( $id ) ] = $this->render();
if ( $path !== false )
if ( file_put_contents( $this->_path ( $cache, $path, '.html' ), self::$_cache[ $cache ] ) === false )
Expand Down

0 comments on commit 7cd5857

Please sign in to comment.