Update composer dependencies

This commit is contained in:
Kijin Sung 2021-01-06 21:42:06 +09:00
parent bb9a56bcac
commit aabc7ac55e
690 changed files with 61555 additions and 37954 deletions

View file

@ -185,7 +185,7 @@ class ElementNode extends Node
public function removeChild(Node $child)
{
foreach ($this->children as $key => $value) {
if ($value == $child) {
if ($value === $child) {
unset($this->children[$key]);
}
}

View file

@ -0,0 +1,30 @@
<?php
class FnValidatorTest extends PHPUnit_Framework_TestCase
{
/**
* Test custom functional validator implementations.
*
* @param JBBCode\validators\FnValidator $validator
* @dataProvider validatorProvider
*/
public function testValidator($validator)
{
$this->assertTrue($validator->validate('1234567890'));
$this->assertFalse($validator->validate('QWERTZUIOP'));
}
/**
* Provide custom numeric string validator implementations.
*
*/
public function validatorProvider()
{
return array(
array(new JBBCode\validators\FnValidator('is_numeric')),
array(new JBBCode\validators\FnValidator(function ($input) {
return is_numeric($input);
})),
);
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace JBBCode\validators;
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'InputValidator.php';
/**
* An InputValidator that allows for shortcut implementation
* of a validator using callable types (a function or a \Closure).
*
* @author Kubo2
* @since Feb 2020
*/
class FnValidator implements \JBBCode\InputValidator
{
/**
* @var callable
*/
private $validator;
/**
* Construct a custom validator from a callable.
* @param callable $validator
*/
public function __construct(callable $validator)
{
$this->validator = $validator;
}
/**
* Returns true iff the given input is valid, false otherwise.
* @param string $input
* @return boolean
*/
public function validate($input)
{
$validator = $this->validator; // FIXME: for PHP>=7.0 replace with ($this->validator)($input)
return (bool) $validator($input);
}
}