mirror of
https://github.com/Mibew/handlebars.php-helpers.git
synced 2025-04-14 16:47:23 +03:00
Make the library PHP7 compatible
Unfortunatelly this commit breaks Backward Compatibility.
This commit is contained in:
parent
ea23f1dba9
commit
70575e4eed
@ -12,7 +12,7 @@ namespace JustBlackBird\HandlebarsHelpers\Comparison;
|
|||||||
|
|
||||||
use Handlebars\Context;
|
use Handlebars\Context;
|
||||||
use Handlebars\Helper as HelperInterface;
|
use Handlebars\Helper as HelperInterface;
|
||||||
use Handlebars\String;
|
use Handlebars\StringWrapper;
|
||||||
use Handlebars\Template;
|
use Handlebars\Template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,10 +48,11 @@ class IfAnyHelper implements HelperInterface
|
|||||||
foreach ($parsed_args as $parsed_arg) {
|
foreach ($parsed_args as $parsed_arg) {
|
||||||
$value = $context->get($parsed_arg);
|
$value = $context->get($parsed_arg);
|
||||||
|
|
||||||
if ($value instanceof String) {
|
if ($value instanceof StringWrapper) {
|
||||||
// Casting any object of \Handlebars\String will have false
|
// Casting any object of \Handlebars\StringWrapper will have
|
||||||
// positive result even for those with empty internal strings.
|
// false positive result even for those with empty internal
|
||||||
// Thus we need to check internal string of such objects.
|
// strings. Thus we need to check internal string of such
|
||||||
|
// objects.
|
||||||
$value = $value->getString();
|
$value = $value->getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,12 +41,12 @@ class Helpers extends BaseHelpers
|
|||||||
$this->add('ifOdd', new Comparison\IfOddHelper());
|
$this->add('ifOdd', new Comparison\IfOddHelper());
|
||||||
$this->add('unlessEqual', new Comparison\UnlessEqualHelper());
|
$this->add('unlessEqual', new Comparison\UnlessEqualHelper());
|
||||||
|
|
||||||
// String helpers
|
// Text helpers
|
||||||
$this->add('lowercase', new String\LowercaseHelper());
|
$this->add('lowercase', new Text\LowercaseHelper());
|
||||||
$this->add('uppercase', new String\UppercaseHelper());
|
$this->add('uppercase', new Text\UppercaseHelper());
|
||||||
$this->add('repeat', new String\RepeatHelper());
|
$this->add('repeat', new Text\RepeatHelper());
|
||||||
$this->add('replace', new String\ReplaceHelper());
|
$this->add('replace', new Text\ReplaceHelper());
|
||||||
$this->add('truncate', new String\TruncateHelper());
|
$this->add('truncate', new Text\TruncateHelper());
|
||||||
|
|
||||||
// Layout helpers
|
// Layout helpers
|
||||||
$storage = new Layout\BlockStorage();
|
$storage = new Layout\BlockStorage();
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JustBlackBird\HandlebarsHelpers\String;
|
namespace JustBlackBird\HandlebarsHelpers\Text;
|
||||||
|
|
||||||
use Handlebars\Helpers as BaseHelpers;
|
use Handlebars\Helpers as BaseHelpers;
|
||||||
|
|
@ -8,7 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JustBlackBird\HandlebarsHelpers\String;
|
namespace JustBlackBird\HandlebarsHelpers\Text;
|
||||||
|
|
||||||
use Handlebars\Context;
|
use Handlebars\Context;
|
||||||
use Handlebars\Helper as HelperInterface;
|
use Handlebars\Helper as HelperInterface;
|
@ -8,7 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JustBlackBird\HandlebarsHelpers\String;
|
namespace JustBlackBird\HandlebarsHelpers\Text;
|
||||||
|
|
||||||
use Handlebars\Context;
|
use Handlebars\Context;
|
||||||
use Handlebars\Helper as HelperInterface;
|
use Handlebars\Helper as HelperInterface;
|
@ -8,7 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JustBlackBird\HandlebarsHelpers\String;
|
namespace JustBlackBird\HandlebarsHelpers\Text;
|
||||||
|
|
||||||
use Handlebars\Context;
|
use Handlebars\Context;
|
||||||
use Handlebars\Helper as HelperInterface;
|
use Handlebars\Helper as HelperInterface;
|
@ -8,7 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JustBlackBird\HandlebarsHelpers\String;
|
namespace JustBlackBird\HandlebarsHelpers\Text;
|
||||||
|
|
||||||
use Handlebars\Context;
|
use Handlebars\Context;
|
||||||
use Handlebars\Helper as HelperInterface;
|
use Handlebars\Helper as HelperInterface;
|
@ -8,7 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace JustBlackBird\HandlebarsHelpers\String;
|
namespace JustBlackBird\HandlebarsHelpers\Text;
|
||||||
|
|
||||||
use Handlebars\Context;
|
use Handlebars\Context;
|
||||||
use Handlebars\Helper as HelperInterface;
|
use Handlebars\Helper as HelperInterface;
|
@ -61,7 +61,7 @@ class IfAnyHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
'b' => null,
|
'b' => null,
|
||||||
'c' => array(),
|
'c' => array(),
|
||||||
'd' => '',
|
'd' => '',
|
||||||
'e' => new \Handlebars\String(''),
|
'e' => new \Handlebars\StringWrapper(''),
|
||||||
),
|
),
|
||||||
'false',
|
'false',
|
||||||
),
|
),
|
||||||
|
@ -53,12 +53,12 @@ class HelpersTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('ifOdd', '\\JustBlackBird\\HandlebarsHelpers\\Comparison\\IfOddHelper'),
|
array('ifOdd', '\\JustBlackBird\\HandlebarsHelpers\\Comparison\\IfOddHelper'),
|
||||||
array('unlessEqual', '\\JustBlackBird\\HandlebarsHelpers\\Comparison\\UnlessEqualHelper'),
|
array('unlessEqual', '\\JustBlackBird\\HandlebarsHelpers\\Comparison\\UnlessEqualHelper'),
|
||||||
|
|
||||||
// String helpers
|
// Text helpers
|
||||||
array('lowercase', '\\JustBlackBird\\HandlebarsHelpers\\String\\LowercaseHelper'),
|
array('lowercase', '\\JustBlackBird\\HandlebarsHelpers\\Text\\LowercaseHelper'),
|
||||||
array('uppercase', '\\JustBlackBird\\HandlebarsHelpers\\String\\UppercaseHelper'),
|
array('uppercase', '\\JustBlackBird\\HandlebarsHelpers\\Text\\UppercaseHelper'),
|
||||||
array('repeat', '\\JustBlackBird\\HandlebarsHelpers\\String\\RepeatHelper'),
|
array('repeat', '\\JustBlackBird\\HandlebarsHelpers\\Text\\RepeatHelper'),
|
||||||
array('replace', '\\JustBlackBird\\HandlebarsHelpers\\String\\ReplaceHelper'),
|
array('replace', '\\JustBlackBird\\HandlebarsHelpers\\Text\\ReplaceHelper'),
|
||||||
array('truncate', '\\JustBlackBird\\HandlebarsHelpers\\String\\TruncateHelper'),
|
array('truncate', '\\JustBlackBird\\HandlebarsHelpers\\Text\\TruncateHelper'),
|
||||||
|
|
||||||
// Layout helpers
|
// Layout helpers
|
||||||
array('block', '\\JustBlackBird\\HandlebarsHelpers\\Layout\\BlockHelper'),
|
array('block', '\\JustBlackBird\\HandlebarsHelpers\\Layout\\BlockHelper'),
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
* file that was distributed with this source code.
|
* 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>
|
* @author Dmitriy Simushev <simushevds@gmail.com>
|
||||||
*/
|
*/
|
||||||
@ -38,11 +38,11 @@ class HelpersTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function helpersProvider()
|
public function helpersProvider()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array('lowercase', '\\JustBlackBird\\HandlebarsHelpers\\String\\LowercaseHelper'),
|
array('lowercase', '\\JustBlackBird\\HandlebarsHelpers\\Text\\LowercaseHelper'),
|
||||||
array('uppercase', '\\JustBlackBird\\HandlebarsHelpers\\String\\UppercaseHelper'),
|
array('uppercase', '\\JustBlackBird\\HandlebarsHelpers\\Text\\UppercaseHelper'),
|
||||||
array('repeat', '\\JustBlackBird\\HandlebarsHelpers\\String\\RepeatHelper'),
|
array('repeat', '\\JustBlackBird\\HandlebarsHelpers\\Text\\RepeatHelper'),
|
||||||
array('replace', '\\JustBlackBird\\HandlebarsHelpers\\String\\ReplaceHelper'),
|
array('replace', '\\JustBlackBird\\HandlebarsHelpers\\Text\\ReplaceHelper'),
|
||||||
array('truncate', '\\JustBlackBird\\HandlebarsHelpers\\String\\TruncateHelper'),
|
array('truncate', '\\JustBlackBird\\HandlebarsHelpers\\Text\\TruncateHelper'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,9 +8,9 @@
|
|||||||
* file that was distributed with this source code.
|
* 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.
|
* Test class for "lowercase" helper.
|
@ -8,9 +8,9 @@
|
|||||||
* file that was distributed with this source code.
|
* 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.
|
* Test class for "repeat" helper.
|
@ -8,9 +8,9 @@
|
|||||||
* file that was distributed with this source code.
|
* 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.
|
* Test class for "replace" helper.
|
@ -8,9 +8,9 @@
|
|||||||
* file that was distributed with this source code.
|
* 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.
|
* Test class for "truncate" helper.
|
@ -8,9 +8,9 @@
|
|||||||
* file that was distributed with this source code.
|
* 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.
|
* Test class for "uppercase" helper.
|
Loading…
Reference in New Issue
Block a user