Make the library PHP7 compatible

Unfortunatelly this commit breaks Backward Compatibility.
This commit is contained in:
Dmitriy Simushev 2016-02-20 13:31:45 +00:00
parent ea23f1dba9
commit 70575e4eed
16 changed files with 43 additions and 42 deletions

View File

@ -12,7 +12,7 @@ namespace JustBlackBird\HandlebarsHelpers\Comparison;
use Handlebars\Context;
use Handlebars\Helper as HelperInterface;
use Handlebars\String;
use Handlebars\StringWrapper;
use Handlebars\Template;
/**
@ -48,10 +48,11 @@ class IfAnyHelper implements HelperInterface
foreach ($parsed_args as $parsed_arg) {
$value = $context->get($parsed_arg);
if ($value instanceof String) {
// Casting any object of \Handlebars\String will have false
// positive result even for those with empty internal strings.
// Thus we need to check internal string of such objects.
if ($value instanceof StringWrapper) {
// Casting any object of \Handlebars\StringWrapper will have
// false positive result even for those with empty internal
// strings. Thus we need to check internal string of such
// objects.
$value = $value->getString();
}

View File

@ -41,12 +41,12 @@ class Helpers extends BaseHelpers
$this->add('ifOdd', new Comparison\IfOddHelper());
$this->add('unlessEqual', new Comparison\UnlessEqualHelper());
// String helpers
$this->add('lowercase', new String\LowercaseHelper());
$this->add('uppercase', new String\UppercaseHelper());
$this->add('repeat', new String\RepeatHelper());
$this->add('replace', new String\ReplaceHelper());
$this->add('truncate', new String\TruncateHelper());
// Text helpers
$this->add('lowercase', new Text\LowercaseHelper());
$this->add('uppercase', new Text\UppercaseHelper());
$this->add('repeat', new Text\RepeatHelper());
$this->add('replace', new Text\ReplaceHelper());
$this->add('truncate', new Text\TruncateHelper());
// Layout helpers
$storage = new Layout\BlockStorage();

View File

@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/
namespace JustBlackBird\HandlebarsHelpers\String;
namespace JustBlackBird\HandlebarsHelpers\Text;
use Handlebars\Helpers as BaseHelpers;

View File

@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/
namespace JustBlackBird\HandlebarsHelpers\String;
namespace JustBlackBird\HandlebarsHelpers\Text;
use Handlebars\Context;
use Handlebars\Helper as HelperInterface;

View File

@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/
namespace JustBlackBird\HandlebarsHelpers\String;
namespace JustBlackBird\HandlebarsHelpers\Text;
use Handlebars\Context;
use Handlebars\Helper as HelperInterface;

View File

@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/
namespace JustBlackBird\HandlebarsHelpers\String;
namespace JustBlackBird\HandlebarsHelpers\Text;
use Handlebars\Context;
use Handlebars\Helper as HelperInterface;

View File

@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/
namespace JustBlackBird\HandlebarsHelpers\String;
namespace JustBlackBird\HandlebarsHelpers\Text;
use Handlebars\Context;
use Handlebars\Helper as HelperInterface;

View File

@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/
namespace JustBlackBird\HandlebarsHelpers\String;
namespace JustBlackBird\HandlebarsHelpers\Text;
use Handlebars\Context;
use Handlebars\Helper as HelperInterface;

View File

@ -61,7 +61,7 @@ class IfAnyHelperTest extends \PHPUnit_Framework_TestCase
'b' => null,
'c' => array(),
'd' => '',
'e' => new \Handlebars\String(''),
'e' => new \Handlebars\StringWrapper(''),
),
'false',
),

View File

@ -53,12 +53,12 @@ class HelpersTest extends \PHPUnit_Framework_TestCase
array('ifOdd', '\\JustBlackBird\\HandlebarsHelpers\\Comparison\\IfOddHelper'),
array('unlessEqual', '\\JustBlackBird\\HandlebarsHelpers\\Comparison\\UnlessEqualHelper'),
// String helpers
array('lowercase', '\\JustBlackBird\\HandlebarsHelpers\\String\\LowercaseHelper'),
array('uppercase', '\\JustBlackBird\\HandlebarsHelpers\\String\\UppercaseHelper'),
array('repeat', '\\JustBlackBird\\HandlebarsHelpers\\String\\RepeatHelper'),
array('replace', '\\JustBlackBird\\HandlebarsHelpers\\String\\ReplaceHelper'),
array('truncate', '\\JustBlackBird\\HandlebarsHelpers\\String\\TruncateHelper'),
// Text helpers
array('lowercase', '\\JustBlackBird\\HandlebarsHelpers\\Text\\LowercaseHelper'),
array('uppercase', '\\JustBlackBird\\HandlebarsHelpers\\Text\\UppercaseHelper'),
array('repeat', '\\JustBlackBird\\HandlebarsHelpers\\Text\\RepeatHelper'),
array('replace', '\\JustBlackBird\\HandlebarsHelpers\\Text\\ReplaceHelper'),
array('truncate', '\\JustBlackBird\\HandlebarsHelpers\\Text\\TruncateHelper'),
// Layout helpers
array('block', '\\JustBlackBird\\HandlebarsHelpers\\Layout\\BlockHelper'),

View File

@ -8,12 +8,12 @@
* file that was distributed with this source code.
*/
namespace JustBlackBird\HandlebarsHelpers\Tests\String;
namespace JustBlackBird\HandlebarsHelpers\Tests\Text;
use JustBlackBird\HandlebarsHelpers\String\Helpers;
use JustBlackBird\HandlebarsHelpers\Text\Helpers;
/**
* Test class for String Helpers Set.
* Test class for Text Helpers Set.
*
* @author Dmitriy Simushev <simushevds@gmail.com>
*/
@ -38,11 +38,11 @@ class HelpersTest extends \PHPUnit_Framework_TestCase
public function helpersProvider()
{
return array(
array('lowercase', '\\JustBlackBird\\HandlebarsHelpers\\String\\LowercaseHelper'),
array('uppercase', '\\JustBlackBird\\HandlebarsHelpers\\String\\UppercaseHelper'),
array('repeat', '\\JustBlackBird\\HandlebarsHelpers\\String\\RepeatHelper'),
array('replace', '\\JustBlackBird\\HandlebarsHelpers\\String\\ReplaceHelper'),
array('truncate', '\\JustBlackBird\\HandlebarsHelpers\\String\\TruncateHelper'),
array('lowercase', '\\JustBlackBird\\HandlebarsHelpers\\Text\\LowercaseHelper'),
array('uppercase', '\\JustBlackBird\\HandlebarsHelpers\\Text\\UppercaseHelper'),
array('repeat', '\\JustBlackBird\\HandlebarsHelpers\\Text\\RepeatHelper'),
array('replace', '\\JustBlackBird\\HandlebarsHelpers\\Text\\ReplaceHelper'),
array('truncate', '\\JustBlackBird\\HandlebarsHelpers\\Text\\TruncateHelper'),
);
}
}

View File

@ -8,9 +8,9 @@
* file that was distributed with this source code.
*/
namespace JustBlackBird\HandlebarsHelpers\Tests\String;
namespace JustBlackBird\HandlebarsHelpers\Tests\Text;
use JustBlackBird\HandlebarsHelpers\String\LowercaseHelper;
use JustBlackBird\HandlebarsHelpers\Text\LowercaseHelper;
/**
* Test class for "lowercase" helper.

View File

@ -8,9 +8,9 @@
* file that was distributed with this source code.
*/
namespace JustBlackBird\HandlebarsHelpers\Tests\String;
namespace JustBlackBird\HandlebarsHelpers\Tests\Text;
use JustBlackBird\HandlebarsHelpers\String\RepeatHelper;
use JustBlackBird\HandlebarsHelpers\Text\RepeatHelper;
/**
* Test class for "repeat" helper.

View File

@ -8,9 +8,9 @@
* file that was distributed with this source code.
*/
namespace JustBlackBird\HandlebarsHelpers\Tests\String;
namespace JustBlackBird\HandlebarsHelpers\Tests\Text;
use JustBlackBird\HandlebarsHelpers\String\ReplaceHelper;
use JustBlackBird\HandlebarsHelpers\Text\ReplaceHelper;
/**
* Test class for "replace" helper.

View File

@ -8,9 +8,9 @@
* file that was distributed with this source code.
*/
namespace JustBlackBird\HandlebarsHelpers\Tests\String;
namespace JustBlackBird\HandlebarsHelpers\Tests\Text;
use JustBlackBird\HandlebarsHelpers\String\TruncateHelper;
use JustBlackBird\HandlebarsHelpers\Text\TruncateHelper;
/**
* Test class for "truncate" helper.

View File

@ -8,9 +8,9 @@
* file that was distributed with this source code.
*/
namespace JustBlackBird\HandlebarsHelpers\Tests\String;
namespace JustBlackBird\HandlebarsHelpers\Tests\Text;
use JustBlackBird\HandlebarsHelpers\String\UppercaseHelper;
use JustBlackBird\HandlebarsHelpers\Text\UppercaseHelper;
/**
* Test class for "uppercase" helper.