Use PSR-2 standard

Most changes was made by php-cs-fixer.
Also removes unused `RecursiveTreeIterator` class.
This commit is contained in:
Henrique Moody 2015-01-08 00:15:35 -02:00
parent 018c3fe63d
commit da193b75e0
192 changed files with 301 additions and 610 deletions

View file

@ -10,6 +10,9 @@ tools:
external_code_coverage: true
php_analyzer: true
php_changetracking: true
php_code_sniffer:
config:
standard: "PSR2"
php_cpd: true
php_mess_detector: true
php_pdepend: true

View file

@ -28,4 +28,3 @@ class ExceptionIterator extends RecursiveArrayIterator
return new static($this->current()->getRelated($this->fullRelated), $this->fullRelated);
}
}

View file

@ -13,7 +13,7 @@ class AbstractGroupedException extends AbstractNestedException
self::MODE_NEGATIVE => array(
self::NONE => 'None of there rules must pass for {{name}}',
self::SOME => 'These rules must not pass for {{name}}',
)
),
);
public function chooseTemplate()
@ -40,11 +40,11 @@ class AbstractGroupedException extends AbstractNestedException
if (!$isEmpty && $this->template != $parentTemplate) {
return $this->template;
} if ($isEmpty && 1 === count($this->related)) {
}
if ($isEmpty && 1 === count($this->related)) {
return current($this->related)->getTemplate();
} else {
return $parentTemplate;
}
}
}

View file

@ -52,7 +52,7 @@ class AbstractNestedException extends ValidationException
return $target;
}
public function getIterator($full=false, $mode=self::ITERATE_ALL)
public function getIterator($full = false, $mode = self::ITERATE_ALL)
{
$exceptionIterator = new ExceptionIterator($this, $full);
@ -74,7 +74,7 @@ class AbstractNestedException extends ValidationException
return implode(PHP_EOL, $message);
}
public function getRelated($full=false)
public function getRelated($full = false)
{
if (!$full && 1 === count($this->related)
&& current($this->related) instanceof AbstractNestedException) {
@ -104,4 +104,3 @@ class AbstractNestedException extends ValidationException
return $this;
}
}

View file

@ -11,7 +11,6 @@ class AllOfException extends AbstractGroupedException
self::MODE_NEGATIVE => array(
self::NONE => 'None of these rules must pass for {{name}}',
self::SOME => 'These rules must not pass for {{name}}',
)
),
);
}

View file

@ -6,12 +6,11 @@ class AlnumException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only letters (a-z) and digits (0-9)',
self::EXTRA => '{{name}} must contain only letters (a-z), digits (0-9) and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only letters (a-z), digits (0-9) and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain letters (a-z) or digits (0-9)',
self::EXTRA => '{{name}} must not contain letters (a-z), digits (0-9) or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain letters (a-z), digits (0-9) or "{{additionalChars}}"',
),
);
}

View file

@ -8,12 +8,12 @@ class AlphaException extends ValidationException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only letters (a-z)',
self::EXTRA => '{{name}} must contain only letters (a-z) and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only letters (a-z) and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain letters (a-z)',
self::EXTRA => '{{name}} must not contain letters (a-z) or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain letters (a-z) or "{{additionalChars}}"',
),
);
public function chooseTemplate()
@ -21,4 +21,3 @@ class AlphaException extends ValidationException
return $this->getParam('additionalChars') ? static::EXTRA : static::STANDARD;
}
}

View file

@ -9,7 +9,6 @@ class AlwaysInvalidException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} is always valid',
)
),
);
}

View file

@ -9,7 +9,6 @@ class AlwaysValidException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} is always invalid',
)
),
);
}

View file

@ -9,7 +9,6 @@ class ArrException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be an array',
)
),
);
}

View file

@ -11,7 +11,6 @@ class AtLeastException extends AbstractGroupedException
self::MODE_NEGATIVE => array(
self::NONE => 'At least {{howMany}} of the {{failed}} required rules must not pass for {{name}}',
self::SOME => 'At least {{howMany}} of the {{failed}} required rules must not pass for {{name}}, only {{passed}} passed.',
)
),
);
}

View file

@ -13,7 +13,7 @@ class AttributeException extends AbstractNestedException
self::MODE_NEGATIVE => array(
self::NOT_PRESENT => 'Attribute {{name}} must not be present',
self::INVALID => 'Attribute {{name}} must not validate',
)
),
);
public function chooseTemplate()
@ -21,4 +21,3 @@ class AttributeException extends AbstractNestedException
return $this->getParam('hasReference') ? static::INVALID : static::NOT_PRESENT;
}
}

View file

@ -3,6 +3,4 @@ namespace Respect\Validation\Exceptions;
class BaseException extends ValidationException
{
}

View file

@ -17,10 +17,10 @@ class BetweenException extends AbstractNestedException
self::BOTH => '{{name}} must not be between {{minValue}} and {{maxValue}}',
self::LOWER => '{{name}} must not be greater than {{minValue}}',
self::GREATER => '{{name}} must not be lower than {{maxValue}}',
)
),
);
public function configure($name, array $params=array())
public function configure($name, array $params = array())
{
$params['minValue'] = static::stringify($params['minValue']);
$params['maxValue'] = static::stringify($params['maxValue']);
@ -39,4 +39,3 @@ class BetweenException extends AbstractNestedException
}
}
}

View file

@ -9,7 +9,6 @@ class BoolException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a boolean',
)
),
);
}

View file

@ -4,4 +4,3 @@ namespace Respect\Validation\Exceptions;
class CallException extends AbstractGroupedException
{
}

View file

@ -9,7 +9,6 @@ class CallbackException extends AbstractNestedException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be valid',
)
),
);
}

View file

@ -5,11 +5,10 @@ class CharsetException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be in the {{charset}} charset'
self::STANDARD => '{{name}} must be in the {{charset}} charset',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be in the {{charset}} charset'
)
self::STANDARD => '{{name}} must not be in the {{charset}} charset',
),
);
}

View file

@ -9,7 +9,6 @@ class CnhException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid CNH number',
)
),
);
}

View file

@ -4,14 +4,12 @@ namespace Respect\Validation\Exceptions;
class CnpjException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be a valid CNPJ number',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid CNPJ number',
)
),
);
}
}

View file

@ -6,12 +6,11 @@ class CntrlException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only control characters',
self::EXTRA => '{{name}} must contain only control characters and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only control characters and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain control characters',
self::EXTRA => '{{name}} must not contain control characters or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain control characters or "{{additionalChars}}"',
),
);
}

View file

@ -6,4 +6,3 @@ use Exception;
class ComponentException extends Exception
{
}

View file

@ -6,12 +6,11 @@ class ConsonantException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only consonants',
self::EXTRA => '{{name}} must contain only consonants and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only consonants and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain consonants',
self::EXTRA => '{{name}} must not contain consonants or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain consonants or "{{additionalChars}}"',
),
);
}

View file

@ -9,7 +9,6 @@ class ContainsException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain the value "{{containsValue}}"',
)
),
);
}

View file

@ -9,7 +9,6 @@ class CountryCodeException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid country',
)
),
);
}

View file

@ -9,7 +9,6 @@ class CpfException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid CPF number',
)
),
);
}

View file

@ -9,7 +9,6 @@ class CreditCardException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid Credit Card number',
)
),
);
}

View file

@ -8,18 +8,19 @@ class DateException extends ValidationException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be a valid date',
self::FORMAT => '{{name}} must be a valid date. Sample format: {{format}}'
self::FORMAT => '{{name}} must be a valid date. Sample format: {{format}}',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid date',
self::FORMAT => '{{name}} must not be a valid date in the format {{format}}'
)
self::FORMAT => '{{name}} must not be a valid date in the format {{format}}',
),
);
public function configure($name, array $params=array())
public function configure($name, array $params = array())
{
$params['format'] = date(
$params['format'], strtotime('2005-12-30 01:02:03')
$params['format'],
strtotime('2005-12-30 01:02:03')
);
return parent::configure($name, $params);
@ -30,4 +31,3 @@ class DateException extends ValidationException
return $this->getParam('format') ? static::FORMAT : static::STANDARD;
}
}

View file

@ -6,12 +6,11 @@ class DigitException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only digits (0-9)',
self::EXTRA => '{{name}} must contain only digits (0-9) and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only digits (0-9) and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain digits (0-9)',
self::EXTRA => '{{name}} must not contain digits (0-9) or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain digits (0-9) or "{{additionalChars}}"',
),
);
}

View file

@ -9,7 +9,6 @@ class DirectoryException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a directory',
)
),
);
}

View file

@ -9,7 +9,6 @@ class DomainException extends AbstractNestedException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid domain',
)
),
);
}

View file

@ -9,7 +9,6 @@ class EachException extends AbstractNestedException
),
self::MODE_NEGATIVE => array(
self::STANDARD => 'Each item in {{name}} must not validate',
)
),
);
}

View file

@ -9,7 +9,6 @@ class EmailException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be an email',
)
),
);
}

View file

@ -9,7 +9,6 @@ class EndsWithException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not end with ({{endValue}})',
)
),
);
}

View file

@ -14,7 +14,7 @@ class EqualsException extends ValidationException
self::MODE_NEGATIVE => array(
self::EQUALS => '{{name}} must not be equals {{compareTo}}',
self::IDENTICAL => '{{name}} must not be identical as {{compareTo}}',
)
),
);
public function chooseTemplate()
@ -22,4 +22,3 @@ class EqualsException extends ValidationException
return $this->getParam('identical') ? static::IDENTICAL : static::EQUALS;
}
}

View file

@ -9,7 +9,6 @@ class EvenException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be an even number',
)
),
);
}

View file

@ -10,6 +10,6 @@ class ExecutableException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be an executable file',
)
),
);
}

View file

@ -4,14 +4,12 @@ namespace Respect\Validation\Exceptions;
class ExistsException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must exists',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not exists',
)
),
);
}

View file

@ -4,14 +4,12 @@ namespace Respect\Validation\Exceptions;
class FileException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be a file',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a file',
)
),
);
}

View file

@ -9,7 +9,6 @@ class FloatException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a float number',
)
),
);
}

View file

@ -6,12 +6,11 @@ class GraphException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only graphical characters',
self::EXTRA => '{{name}} must contain only graphical characters and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only graphical characters and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain graphical characters',
self::EXTRA => '{{name}} must not contain graphical characters or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain graphical characters or "{{additionalChars}}"',
),
);
}

View file

@ -9,7 +9,6 @@ class HexRgbColorException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a hex RGB color',
)
),
);
}

View file

@ -9,7 +9,6 @@ class HexaException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a hexadecimal number',
)
),
);
}

View file

@ -9,7 +9,6 @@ class InException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be in ({{haystack}})',
)
),
);
}

View file

@ -9,7 +9,6 @@ class InstanceException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be an instance of {{instanceName}}',
)
),
);
}

View file

@ -9,7 +9,6 @@ class IntException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be an integer number',
)
),
);
}

View file

@ -14,19 +14,19 @@ class IpException extends ValidationException
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be an IP address',
self::NETWORK_RANGE => '{{name}} must not be an IP address in the {{range}} range',
)
),
);
public function configure($name, array $params=array())
public function configure($name, array $params = array())
{
if ($params['networkRange']) {
$range = $params['networkRange'];
$message = $range['min'];
if (isset($range['max'])) {
$message .= '-' . $range['max'];
$message .= '-'.$range['max'];
} else {
$message .= '/' . long2ip($range['mask']);
$message .= '/'.long2ip($range['mask']);
}
$params['range'] = $message;
@ -44,4 +44,3 @@ class IpException extends ValidationException
}
}
}

View file

@ -9,7 +9,6 @@ class JsonException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid JSON string',
)
),
);
}

View file

@ -11,7 +11,6 @@ class KeyException extends AttributeException
self::MODE_NEGATIVE => array(
self::NOT_PRESENT => 'Key {{name}} must not be present',
self::INVALID => 'Key {{name}} must not be valid',
)
),
);
}

View file

@ -17,10 +17,10 @@ class LengthException extends ValidationException
self::BOTH => '{{name}} must not have a length between {{minValue}} and {{maxValue}}',
self::LOWER => '{{name}} must not have a length greater than {{minValue}}',
self::GREATER => '{{name}} must not have a length lower than {{maxValue}}',
)
),
);
public function configure($name, array $params=array())
public function configure($name, array $params = array())
{
$params['minValue'] = static::stringify($params['minValue']);
$params['maxValue'] = static::stringify($params['maxValue']);
@ -39,4 +39,3 @@ class LengthException extends ValidationException
}
}
}

View file

@ -9,7 +9,6 @@ class LowercaseException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be lowercase',
)
),
);
}

View file

@ -9,7 +9,6 @@ class MacAddressException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid mac address',
)
),
);
}

View file

@ -13,7 +13,7 @@ class MaxException extends ValidationException
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be lower than {{maxValue}}',
self::INCLUSIVE => '{{name}} must not be lower than or equals {{maxValue}}',
)
),
);
public function chooseTemplate()
@ -21,4 +21,3 @@ class MaxException extends ValidationException
return $this->getParam('inclusive') ? static::INCLUSIVE : static::STANDARD;
}
}

View file

@ -13,7 +13,7 @@ class MinException extends ValidationException
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be greater than {{minValue}}',
self::INCLUSIVE => '{{name}} must not be greater than or equals {{minValue}}',
)
),
);
public function chooseTemplate()
@ -21,4 +21,3 @@ class MinException extends ValidationException
return $this->getParam('inclusive') ? static::INCLUSIVE : static::STANDARD;
}
}

View file

@ -9,7 +9,6 @@ class MinimumAgeException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => 'The age must not be {{age}} years or more.',
)
),
);
}

View file

@ -4,4 +4,3 @@ namespace Respect\Validation\Exceptions;
class MostOfException extends AtLeastException
{
}

View file

@ -9,7 +9,6 @@ class MultipleException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be multiple of {{multipleOf}}',
)
),
);
}

View file

@ -9,7 +9,6 @@ class NegativeException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be negative',
)
),
);
}

View file

@ -9,7 +9,6 @@ class NfeAccessKeyException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid NFe access key',
)
),
);
}

View file

@ -9,7 +9,6 @@ class NoWhitespaceException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not not contain whitespace',
)
),
);
}

View file

@ -9,7 +9,6 @@ class NoneOfException extends AbstractNestedException
),
self::MODE_NEGATIVE => array(
self::STANDARD => 'All of these rules must pass for {{name}}',
)
),
);
}

View file

@ -13,7 +13,7 @@ class NotEmptyException extends ValidationException
self::MODE_NEGATIVE => array(
self::STANDARD => 'The value must be empty',
self::NAMED => '{{name}} must be empty',
)
),
);
public function chooseTemplate()
@ -21,4 +21,3 @@ class NotEmptyException extends ValidationException
return $this->getName() == "" ? static::STANDARD : static::NAMED;
}
}

View file

@ -4,4 +4,3 @@ namespace Respect\Validation\Exceptions;
class NotException extends AbstractGroupedException
{
}

View file

@ -9,7 +9,6 @@ class NullValueException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be null',
)
),
);
}

View file

@ -9,7 +9,6 @@ class NumericException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be numeric',
)
),
);
}

View file

@ -9,7 +9,6 @@ class ObjectException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be an object',
)
),
);
}

View file

@ -9,7 +9,6 @@ class OddException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be an odd number',
)
),
);
}

View file

@ -9,7 +9,6 @@ class OneOfException extends AbstractNestedException
),
self::MODE_NEGATIVE => array(
self::STANDARD => 'At least one of these rules must not pass for {{name}}',
)
),
);
}

View file

@ -9,7 +9,6 @@ class PerfectSquareException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid perfect square',
)
),
);
}

View file

@ -9,7 +9,6 @@ class PhoneException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid telephone number',
)
),
);
}

View file

@ -9,7 +9,6 @@ class PositiveException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be positive',
)
),
);
}

View file

@ -9,6 +9,6 @@ class PostalCodeException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid postal code',
)
),
);
}

View file

@ -9,7 +9,6 @@ class PrimeNumberException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid prime number',
)
),
);
}

View file

@ -6,12 +6,11 @@ class PrntException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only printable characters',
self::EXTRA => '{{name}} must contain only printable characters and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only printable characters and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain printable characters',
self::EXTRA => '{{name}} must not contain printable characters or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain printable characters or "{{additionalChars}}"',
),
);
}

View file

@ -6,12 +6,11 @@ class PunctException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only punctuation characters',
self::EXTRA => '{{name}} must contain only punctuation characters and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only punctuation characters and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain punctuation characters',
self::EXTRA => '{{name}} must not contain punctuation characters or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain punctuation characters or "{{additionalChars}}"',
),
);
}

View file

@ -4,14 +4,12 @@ namespace Respect\Validation\Exceptions;
class ReadableException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be readable',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be readable',
)
),
);
}

View file

@ -9,7 +9,6 @@ class RegexException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not validate against {{regex}}',
)
),
);
}

View file

@ -9,7 +9,6 @@ class RomanException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid roman number',
)
),
);
}

View file

@ -9,7 +9,6 @@ class SfException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}}',
)
),
);
}

View file

@ -9,7 +9,6 @@ class SlugException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid slug',
)
),
);
}

View file

@ -6,12 +6,11 @@ class SpaceException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only space characters',
self::EXTRA => '{{name}} must contain only space characters and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only space characters and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain space characters',
self::EXTRA => '{{name}} must not contain space characters or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain space characters or "{{additionalChars}}"',
),
);
}

View file

@ -9,7 +9,6 @@ class StartsWithException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not start with ({{startValue}})',
)
),
);
}

View file

@ -9,7 +9,6 @@ class StringException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be string',
)
),
);
}

View file

@ -4,14 +4,12 @@ namespace Respect\Validation\Exceptions;
class SymbolicLinkException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be a symbolic link',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a symbolic link',
)
),
);
}

View file

@ -4,12 +4,11 @@ namespace Respect\Validation\Exceptions;
class TldException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT =>array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be a valid top-level domain name',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a valid top-level domain name',
)
),
);
}

View file

@ -4,14 +4,12 @@ namespace Respect\Validation\Exceptions;
class UploadedException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be an uploaded file',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be an uploaded file',
)
),
);
}

View file

@ -9,7 +9,6 @@ class UppercaseException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be uppercase',
)
),
);
}

View file

@ -12,11 +12,11 @@ class ValidationException extends InvalidArgumentException
const STANDARD = 0;
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => 'Data validation failed for %s'
self::STANDARD => 'Data validation failed for %s',
),
self::MODE_NEGATIVE => array(
self::STANDARD => 'Data validation failed for %s'
)
self::STANDARD => 'Data validation failed for %s',
),
);
protected $id = 'validation';
protected $mode = self::MODE_DEFAULT;
@ -24,11 +24,11 @@ class ValidationException extends InvalidArgumentException
protected $template = '';
protected $params = array();
public static function format($template, array $vars=array())
public static function format($template, array $vars = array())
{
return preg_replace_callback(
'/{{(\w+)}}/',
function($match) use ($vars) {
function ($match) use ($vars) {
return isset($vars[$match[1]]) ? $vars[$match[1]] : $match[0];
},
$template
@ -55,7 +55,7 @@ class ValidationException extends InvalidArgumentException
} elseif ($value instanceof DateTime) {
return $value->format('Y-m-d H:i:s');
} else {
return "Object of class " . get_class($value);
return "Object of class ".get_class($value);
}
}
@ -179,10 +179,15 @@ class ValidationException extends InvalidArgumentException
protected function guessId()
{
if (!empty($this->id) && $this->id != 'validation')
if (!empty($this->id) && $this->id != 'validation') {
return $this->id;
return lcfirst(str_replace('Exception', '',
end((explode('\\', get_called_class())))));
}
$pieces = explode('\\', get_called_class());
$exceptionClassShortName = end($pieces);
$ruleClassShortName = str_replace('Exception', '', $exceptionClassShortName);
$ruleName = lcfirst($ruleClassShortName);
return $ruleName;
}
}

View file

@ -9,7 +9,6 @@ class VersionException extends ValidationException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be a version',
)
),
);
}

View file

@ -6,12 +6,11 @@ class VowelException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must contain only vowels',
self::EXTRA => '{{name}} must contain only vowels and "{{additionalChars}}"'
self::EXTRA => '{{name}} must contain only vowels and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain vowels',
self::EXTRA => '{{name}} must not contain vowels or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain vowels or "{{additionalChars}}"',
),
);
}

View file

@ -4,14 +4,12 @@ namespace Respect\Validation\Exceptions;
class WritableException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be writable',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be writable',
)
),
);
}

View file

@ -6,12 +6,11 @@ class XdigitException extends AlphaException
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} contain only hexadecimal digits',
self::EXTRA => '{{name}} contain only hexadecimal digits and "{{additionalChars}}"'
self::EXTRA => '{{name}} contain only hexadecimal digits and "{{additionalChars}}"',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not contain hexadecimal digits',
self::EXTRA => '{{name}} must not contain hexadecimal digits or "{{additionalChars}}"'
)
self::EXTRA => '{{name}} must not contain hexadecimal digits or "{{additionalChars}}"',
),
);
}

View file

@ -9,7 +9,6 @@ class ZendException extends AbstractNestedException
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}}',
)
),
);
}

View file

@ -1,143 +0,0 @@
<?php
/**
* Required for hhvm compatibility, can be ignored for Zend PHP.
* Code from PHP itself: https://raw.githubusercontent.com/php/php-src/master/ext/spl/internal/recursivetreeiterator.inc
*/
/**
* @file recursivetreeiterator.inc
* @ingroup SPL
* @brief class RecursiveTreeIterator
* @author Marcus Boerger, Johannes Schlueter
* @date 2005 - 2009
*
* SPL - Standard PHP Library
*/
/**
* @ingroup SPL
* @brief RecursiveIteratorIterator to generate ASCII graphic trees for the
* entries in a RecursiveIterator
* @author Marcus Boerger, Johannes Schlueter
* @version 1.1
* @since PHP 5.3
*/
class RecursiveTreeIterator extends RecursiveIteratorIterator
{
const BYPASS_CURRENT = 0x00000004;
const BYPASS_KEY = 0x00000008;
private $ritFlags;
/**
* @param it iterator to use as inner iterator
* @param ritFlags flags passed to RecursiveIteratoIterator (parent)
* @param citFlags flags passed to RecursiveCachingIterator (for hasNext)
* @param mode mode passed to RecursiveIteratoIterator (parent)
*/
public function __construct(
RecursiveIterator $it,
$ritFlags = self::BYPASS_KEY,
$citFlags = CachingIterator::CATCH_GET_CHILD,
$mode = self::SELF_FIRST
) {
parent::__construct(new RecursiveCachingIterator($it, $citFlags), $mode, $ritFlags);
$this->ritFlags = $ritFlags;
}
private $prefix = array(0 => '', 1 => '| ',2 => ' ', 3 => '|-', 4 => '\-', 5 => '');
/** Prefix used to start elements. */
const PREFIX_LEFT = 0;
/** Prefix used if $level < depth and hasNext($level) == true. */
const PREFIX_MID_HAS_NEXT = 1;
/** Prefix used if $level < depth and hasNext($level) == false. */
const PREFIX_MID_LAST = 2;
/** Prefix used if $level == depth and hasNext($level) == true. */
const PREFIX_END_HAS_NEXT = 3;
/** Prefix used if $level == depth and hasNext($level) == false. */
const PREFIX_END_LAST = 4;
/** Prefix used right in front of the current element. */
const PREFIX_RIGHT = 5;
/**
* Set prefix part as used in getPrefix() and stored in $prefix.
* @param $part any PREFIX_* const.
* @param $value new prefix string for specified part.
* @throws OutOfRangeException if 0 > $part or $part > 5.
*/
public function setPrefixPart($part, $value)
{
if (0 > $part || $part > 5) {
throw new OutOfRangeException();
}
$this->prefix[$part] = (string) $value;
}
/** @return string to place in front of current element
*/
public function getPrefix()
{
$tree = '';
for ($level = 0; $level < $this->getDepth(); $level++) {
$tree .= $this->getSubIterator($level)->hasNext() ? $this->prefix[1] : $this->prefix[2];
}
$tree .= $this->getSubIterator($level)->hasNext() ? $this->prefix[3] : $this->prefix[4];
return $this->prefix[0] . $tree . $this->prefix[5];
}
/**
* @return string presentation build for current element
*/
public function getEntry()
{
return @(string) parent::current();
}
/**
* @return string to place after the current element
*/
public function getPostfix()
{
return '';
}
/**
* @return the current element prefixed and postfixed
*/
public function current()
{
if ($this->ritFlags & self::BYPASS_CURRENT) {
return parent::current();
} else {
return $this->getPrefix() . $this->getEntry() . $this->getPostfix();
}
}
/**
* @return the current key prefixed and postfixed
*/
public function key()
{
if ($this->ritFlags & self::BYPASS_KEY) {
return parent::key();
} else {
return $this->getPrefix() . parent::key() . $this->getPostfix();
}
}
/**
* Aggregates the inner iterator
*/
public function __call($func, $params)
{
return call_user_func_array(array($this->getSubIterator(), $func), $params);
}
}

View file

@ -29,7 +29,7 @@ abstract class AbstractComposite extends AbstractRule
return parent::setName($name);
}
public function addRule($validator, $arguments=array())
public function addRule($validator, $arguments = array())
{
if (!$validator instanceof Validatable) {
$this->appendRule(Validator::buildRule($validator, $arguments));
@ -79,7 +79,7 @@ abstract class AbstractComposite extends AbstractRule
if (is_string($validator)) {
foreach ($this->rules as $rule) {
if (get_class($rule) == __NAMESPACE__ . '\\' . $validator) {
if (get_class($rule) == __NAMESPACE__.'\\'.$validator) {
return true;
}
}
@ -112,4 +112,3 @@ abstract class AbstractComposite extends AbstractRule
return $exceptions;
}
}

View file

@ -29,7 +29,7 @@ abstract class AbstractCountryInfo extends AbstractRule
'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj',
'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua',
'ug', 'uk', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu',
'wf', 'ws', 'ye', 'yt', 'za', 'zm', 'zw'
'wf', 'ws', 'ye', 'yt', 'za', 'zm', 'zw',
);
public function validate($input)
@ -37,4 +37,3 @@ abstract class AbstractCountryInfo extends AbstractRule
return in_array(strtolower($input), $this->tldList);
}
}

View file

@ -7,8 +7,10 @@ abstract class AbstractCtypeRule extends AbstractFilterRule
protected function filterWhiteSpaceOption($input)
{
if (!empty($this->additionalChars))
if (!empty($this->additionalChars)) {
$input = str_replace(str_split($this->additionalChars), '', $input);
}
return preg_replace('/\s/', '', $input);
}
@ -17,4 +19,3 @@ abstract class AbstractCtypeRule extends AbstractFilterRule
return $this->ctypeFunction($input);
}
}

View file

@ -9,10 +9,11 @@ abstract class AbstractFilterRule extends AbstractRule
abstract protected function validateClean($input);
public function __construct($additionalChars='')
public function __construct($additionalChars = '')
{
if (!is_string($additionalChars))
if (!is_string($additionalChars)) {
throw new ComponentException('Invalid list of additional characters to be loaded');
}
$this->additionalChars .= $additionalChars;
}
@ -24,12 +25,12 @@ abstract class AbstractFilterRule extends AbstractRule
public function validate($input)
{
if (!is_scalar($input))
if (!is_scalar($input)) {
return false;
}
$cleanInput = $this->filter((string) $input);
return $cleanInput === '' || $this->validateClean($cleanInput);
}
}

View file

@ -10,4 +10,3 @@ abstract class AbstractRegexRule extends AbstractFilterRule
return preg_match($this->getPregFormat(), $input);
}
}

View file

@ -14,8 +14,7 @@ abstract class AbstractRelated extends AbstractRule
abstract public function getReferenceValue($input);
public function __construct($reference, Validatable $validator=null,
$mandatory=true)
public function __construct($reference, Validatable $validator = null, $mandatory = true)
{
$this->setName($reference);
$this->reference = $reference;
@ -23,7 +22,8 @@ abstract class AbstractRelated extends AbstractRule
$this->mandatory = $mandatory;
}
private function decision($type, $hasReference, $input) {
private function decision($type, $hasReference, $input)
{
return (!$this->mandatory && !$hasReference)
|| (is_null($this->validator)
|| $this->validator->$type($this->getReferenceValue($input)));
@ -31,12 +31,14 @@ abstract class AbstractRelated extends AbstractRule
public function assert($input)
{
if ($input === '')
if ($input === '') {
return true;
}
$hasReference = $this->hasReference($input);
if ($this->mandatory && !$hasReference)
if ($this->mandatory && !$hasReference) {
throw $this->reportError($input, array('hasReference' => false));
}
try {
return $this->decision('assert', $hasReference, $input);
@ -49,21 +51,25 @@ abstract class AbstractRelated extends AbstractRule
public function check($input)
{
if ($input === '')
if ($input === '') {
return true;
}
$hasReference = $this->hasReference($input);
if ($this->mandatory && !$hasReference)
if ($this->mandatory && !$hasReference) {
throw $this->reportError($input, array('hasReference' => false));
}
return $this->decision('check', $hasReference, $input);
}
public function validate($input)
{
$hasReference = $this->hasReference($input);
if ($this->mandatory && !$hasReference)
if ($this->mandatory && !$hasReference) {
return false;
}
return $this->decision('validate', $hasReference, $input);
}
}

Some files were not shown because too many files have changed in this diff Show more