update 1.0.8.0

Commits for version update
This commit is contained in:
Manish Verma
2016-10-17 12:02:27 +05:30
parent dec927987b
commit 76e85db070
9674 changed files with 495757 additions and 58922 deletions

View File

@@ -0,0 +1,7 @@
{
"github-oauth": {
"github.com": "PLEASE DO NOT USE THIS TOKEN IN YOUR OWN PROJECTS/FORKS",
"github.com": "This token is reserved for testing the webmozart/* repositories",
"github.com": "a9debbffdd953ee9b3b82dbc3b807cde2086bb86"
}
}

View File

@@ -5,7 +5,3 @@ enabled:
disabled:
- empty_return
# Unusable at the moment
# https://github.com/StyleCI/StyleCI/issues/471
- psr0

View File

@@ -4,7 +4,7 @@ sudo: false
cache:
directories:
- $HOME/.composer/cache
- $HOME/.composer/cache/files
matrix:
include:
@@ -12,18 +12,24 @@ matrix:
- php: 5.4
- php: 5.5
- php: 5.6
- php: 5.6
env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'
- php: hhvm
- php: nightly
- php: 7.0
env: COVERAGE=yes
- php: 7.0
env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'
allow_failures:
- php: hhvm
- php: nightly
fast_finish: true
install: composer update $COMPOSER_FLAGS -n
before_install:
- if [[ $TRAVIS_PHP_VERSION != hhvm && $COVERAGE != yes ]]; then phpenv config-rm xdebug.ini; fi;
- if [[ $TRAVIS_REPO_SLUG = webmozart/assert ]]; then cp .composer-auth.json ~/.composer/auth.json; fi;
- composer self-update
script: vendor/bin/phpunit -v --coverage-clover=coverage.clover
install: composer update $COMPOSER_FLAGS --prefer-dist --no-interaction
after_script:
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi;'
script: if [[ $COVERAGE = yes ]]; then vendor/bin/phpunit --verbose --coverage-clover=coverage.clover; else vendor/bin/phpunit --verbose; fi
after_script: if [[ $COVERAGE = yes ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi

View File

@@ -1,6 +1,15 @@
Changelog
=========
* 1.1.0 (2016-08-09)
* added `Assert::object()`
* added `Assert::propertyExists()`
* added `Assert::propertyNotExists()`
* added `Assert::methodExists()`
* added `Assert::methodNotExists()`
* added `Assert::uuid()`
* 1.0.2 (2015-08-24)
* integrated Style CI

View File

@@ -1,13 +1,13 @@
Webmozart Assert
================
[![Build Status](https://travis-ci.org/webmozart/assert.svg?branch=1.0.2)](https://travis-ci.org/webmozart/assert)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/689b709c-117b-4076-82e5-000862e8a211/mini.png)](https://insight.sensiolabs.com/projects/689b709c-117b-4076-82e5-000862e8a211)
[![Build Status](https://travis-ci.org/webmozart/assert.svg?branch=1.1.0)](https://travis-ci.org/webmozart/assert)
[![Build status](https://ci.appveyor.com/api/projects/status/lyg83bcsisrr94se/branch/master?svg=true)](https://ci.appveyor.com/project/webmozart/assert/branch/master)
[![Latest Stable Version](https://poser.pugx.org/webmozart/assert/v/stable.svg)](https://packagist.org/packages/webmozart/assert)
[![Total Downloads](https://poser.pugx.org/webmozart/assert/downloads.svg)](https://packagist.org/packages/webmozart/assert)
[![Dependency Status](https://www.versioneye.com/php/webmozart:assert/1.0.2/badge.svg)](https://www.versioneye.com/php/webmozart:assert/1.0.2)
[![Dependency Status](https://www.versioneye.com/php/webmozart:assert/1.1.0/badge.svg)](https://www.versioneye.com/php/webmozart:assert/1.1.0)
Latest release: [1.0.2](https://packagist.org/packages/webmozart/assert#1.0.2)
Latest release: [1.1.0](https://packagist.org/packages/webmozart/assert#1.1.0)
PHP >= 5.3.9
@@ -51,7 +51,7 @@ Installation
Use [Composer] to install the package:
```
$ composer require webmozart/assert:~1.0
$ composer require webmozart/assert
```
Example
@@ -99,6 +99,7 @@ Method | Description
`numeric($value, $message = '')` | Check that a value is numeric
`boolean($value, $message = '')` | Check that a value is a boolean
`scalar($value, $message = '')` | Check that a value is a scalar
`object($value, $message = '')` | Check that a value is an object
`resource($value, $type = null, $message = '')` | Check that a value is a resource
`isCallable($value, $message = '')` | Check that a value is a callable
`isArray($value, $message = '')` | Check that a value is an array
@@ -148,6 +149,7 @@ Method | Description
`minLength($value, $min, $message = '')` | Check that a string has at least a certain number of characters
`maxLength($value, $max, $message = '')` | Check that a string has at most a certain number of characters
`lengthBetween($value, $min, $max, $message = '')` | Check that a string has a length in the given range
`uuid($value, $message = '')` | Check that a string is a valid UUID
### File Assertions
@@ -159,13 +161,17 @@ Method | Description
`readable($value, $message = '')` | Check that a value is a readable path
`writable($value, $message = '')` | Check that a value is a writable path
### Class Assertions
### Object Assertions
Method | Description
---------------------------------------------------- | --------------------------------------------------
`classExists($value, $message = '')` | Check that a value is an existing class name
`subclassOf($value, $class, $message = '')` | Check that a class is a subclass of another
`implementsInterface($value, $class, $message = '')` | Check that a class implements an interface
Method | Description
----------------------------------------------------- | --------------------------------------------------
`classExists($value, $message = '')` | Check that a value is an existing class name
`subclassOf($value, $class, $message = '')` | Check that a class is a subclass of another
`implementsInterface($value, $class, $message = '')` | Check that a class implements an interface
`propertyExists($value, $property, $message = '')` | Check that a property exists in a class/object
`propertyNotExists($value, $property, $message = '')` | Check that a property does not exist in a class/object
`methodExists($value, $method, $message = '')` | Check that a method exists in a class/object
`methodNotExists($value, $method, $message = '')` | Check that a method does not exist in a class/object
### Array Assertions

36
vendor/webmozart/assert/appveyor.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
build: false
platform: x86
clone_folder: c:\projects\webmozart\assert
cache:
- c:\php -> appveyor.yml
init:
- SET PATH=c:\php;%PATH%
- SET COMPOSER_NO_INTERACTION=1
- SET PHP=1
install:
- IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php)
- cd c:\php
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-7.0.0-nts-Win32-VC14-x86.zip
- IF %PHP%==1 7z x php-7.0.0-nts-Win32-VC14-x86.zip -y >nul
- IF %PHP%==1 del /Q *.zip
- IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat
- IF %PHP%==1 copy /Y php.ini-development php.ini
- IF %PHP%==1 echo max_execution_time=1200 >> php.ini
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini
- IF %PHP%==1 echo extension_dir=ext >> php.ini
- IF %PHP%==1 echo extension=php_curl.dll >> php.ini
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini
- IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini
- IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini
- appveyor DownloadFile https://getcomposer.org/composer.phar
- cd c:\projects\webmozart\assert
- mkdir %APPDATA%\Composer
- IF %APPVEYOR_REPO_NAME%==webmozart/assert copy /Y .composer-auth.json %APPDATA%\Composer\auth.json
- composer update --prefer-dist --no-progress --ansi
test_script:
- cd c:\projects\webmozart\assert
- vendor\bin\phpunit.bat --verbose

View File

@@ -10,7 +10,11 @@
}
],
"require": {
"php": ">=5.3.3"
"php": "^5.3.3|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.6",
"sebastian/version": "^1.0.1"
},
"autoload": {
"psr-4": {
@@ -24,10 +28,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "1.2-dev"
}
},
"require-dev": {
"phpunit/phpunit": "^4.6"
}
}

View File

@@ -26,6 +26,7 @@ use Traversable;
* @method static void nullOrNumeric($value, $message = '')
* @method static void nullOrBoolean($value, $message = '')
* @method static void nullOrScalar($value, $message = '')
* @method static void nullOrObject($value, $message = '')
* @method static void nullOrResource($value, $type = null, $message = '')
* @method static void nullOrIsCallable($value, $message = '')
* @method static void nullOrIsArray($value, $message = '')
@@ -68,6 +69,13 @@ use Traversable;
* @method static void nullOrClassExists($value, $message = '')
* @method static void nullOrSubclassOf($value, $class, $message = '')
* @method static void nullOrImplementsInterface($value, $interface, $message = '')
* @method static void nullOrPropertyExists($value, $property, $message = '')
* @method static void nullOrPropertyNotExists($value, $property, $message = '')
* @method static void nullOrMethodExists($value, $method, $message = '')
* @method static void nullOrMethodNotExists($value, $method, $message = '')
* @method static void nullOrKeyExists($value, $key, $message = '')
* @method static void nullOrKeyNotExists($value, $key, $message = '')
* @method static void nullOrUuid($values, $message = '')
* @method static void allString($values, $message = '')
* @method static void allStringNotEmpty($values, $message = '')
* @method static void allInteger($values, $message = '')
@@ -76,6 +84,7 @@ use Traversable;
* @method static void allNumeric($values, $message = '')
* @method static void allBoolean($values, $message = '')
* @method static void allScalar($values, $message = '')
* @method static void allObject($values, $message = '')
* @method static void allResource($values, $type = null, $message = '')
* @method static void allIsCallable($values, $message = '')
* @method static void allIsArray($values, $message = '')
@@ -120,6 +129,13 @@ use Traversable;
* @method static void allClassExists($values, $message = '')
* @method static void allSubclassOf($values, $class, $message = '')
* @method static void allImplementsInterface($values, $interface, $message = '')
* @method static void allPropertyExists($values, $property, $message = '')
* @method static void allPropertyNotExists($values, $property, $message = '')
* @method static void allMethodExists($values, $method, $message = '')
* @method static void allMethodNotExists($values, $method, $message = '')
* @method static void allKeyExists($values, $key, $message = '')
* @method static void allKeyNotExists($values, $key, $message = '')
* @method static void allUuid($values, $message = '')
*
* @since 1.0
*
@@ -203,6 +219,16 @@ class Assert
}
}
public static function object($value, $message = '')
{
if (!is_object($value)) {
throw new InvalidArgumentException(sprintf(
$message ?: 'Expected an object. Got: %s',
self::typeToString($value)
));
}
}
public static function resource($value, $type = null, $message = '')
{
if (!is_resource($value)) {
@@ -713,6 +739,46 @@ class Assert
}
}
public static function propertyExists($classOrObject, $property, $message = '')
{
if (!property_exists($classOrObject, $property)) {
throw new InvalidArgumentException(sprintf(
$message ?: 'Expected the property %s to exist.',
self::valueToString($property)
));
}
}
public static function propertyNotExists($classOrObject, $property, $message = '')
{
if (property_exists($classOrObject, $property)) {
throw new InvalidArgumentException(sprintf(
$message ?: 'Expected the property %s to not exist.',
self::valueToString($property)
));
}
}
public static function methodExists($classOrObject, $method, $message = '')
{
if (!method_exists($classOrObject, $method)) {
throw new InvalidArgumentException(sprintf(
$message ?: 'Expected the method %s to exist.',
self::valueToString($method)
));
}
}
public static function methodNotExists($classOrObject, $method, $message = '')
{
if (method_exists($classOrObject, $method)) {
throw new InvalidArgumentException(sprintf(
$message ?: 'Expected the method %s to not exist.',
self::valueToString($method)
));
}
}
public static function keyExists($array, $key, $message = '')
{
if (!array_key_exists($key, $array)) {
@@ -733,6 +799,24 @@ class Assert
}
}
public static function uuid($value, $message = '')
{
$value = str_replace(array('urn:', 'uuid:', '{', '}'), '', $value);
// The nil UUID is special form of UUID that is specified to have all
// 128 bits set to zero.
if ('00000000-0000-0000-0000-000000000000' === $value) {
return;
}
if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) {
throw new InvalidArgumentException(sprintf(
$message ?: 'Value "%s" is not a valid UUID.',
self::valueToString($value)
));
}
}
public static function __callStatic($name, $arguments)
{
if ('nullOr' === substr($name, 0, 6)) {

View File

@@ -14,6 +14,7 @@ namespace Webmozart\Assert\Tests;
use ArrayIterator;
use Exception;
use PHPUnit_Framework_TestCase;
use RuntimeException;
use stdClass;
use Webmozart\Assert\Assert;
@@ -78,6 +79,12 @@ class AssertTest extends PHPUnit_Framework_TestCase
array('scalar', array(null), false),
array('scalar', array(array()), false),
array('scalar', array(new stdClass()), false),
array('object', array(new stdClass()), true),
array('object', array(new RuntimeException()), true),
array('object', array(null), false),
array('object', array(true), false),
array('object', array(1), false),
array('object', array(array()), false),
array('resource', array($resource), true),
array('resource', array($resource, 'stream'), true),
array('resource', array($resource, 'other'), false),
@@ -242,12 +249,45 @@ class AssertTest extends PHPUnit_Framework_TestCase
array('subclassOf', array(__CLASS__, 'stdClass'), false),
array('implementsInterface', array('ArrayIterator', 'Traversable'), true),
array('implementsInterface', array(__CLASS__, 'Traversable'), false),
array('propertyExists', array((object) array('property' => 0), 'property'), true),
array('propertyExists', array((object) array('property' => null), 'property'), true),
array('propertyExists', array((object) array('property' => null), 'foo'), false),
array('propertyNotExists', array((object) array('property' => 0), 'property'), false),
array('propertyNotExists', array((object) array('property' => null), 'property'), false),
array('propertyNotExists', array((object) array('property' => null), 'foo'), true),
array('methodExists', array('RuntimeException', 'getMessage'), true),
array('methodExists', array(new RuntimeException(), 'getMessage'), true),
array('methodExists', array('stdClass', 'getMessage'), false),
array('methodExists', array(new stdClass(), 'getMessage'), false),
array('methodExists', array(null, 'getMessage'), false),
array('methodExists', array(true, 'getMessage'), false),
array('methodExists', array(1, 'getMessage'), false),
array('methodNotExists', array('RuntimeException', 'getMessage'), false),
array('methodNotExists', array(new RuntimeException(), 'getMessage'), false),
array('methodNotExists', array('stdClass', 'getMessage'), true),
array('methodNotExists', array(new stdClass(), 'getMessage'), true),
array('methodNotExists', array(null, 'getMessage'), true),
array('methodNotExists', array(true, 'getMessage'), true),
array('methodNotExists', array(1, 'getMessage'), true),
array('keyExists', array(array('key' => 0), 'key'), true),
array('keyExists', array(array('key' => null), 'key'), true),
array('keyExists', array(array('key' => null), 'foo'), false),
array('keyNotExists', array(array('key' => 0), 'key'), false),
array('keyNotExists', array(array('key' => null), 'key'), false),
array('keyNotExists', array(array('key' => null), 'foo'), true),
array('uuid', array('00000000-0000-0000-0000-000000000000'), true),
array('uuid', array('ff6f8cb0-c57d-21e1-9b21-0800200c9a66'), true),
array('uuid', array('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'), true),
array('uuid', array('ff6f8cb0-c57d-31e1-9b21-0800200c9a66'), true),
array('uuid', array('ff6f8cb0-c57d-41e1-9b21-0800200c9a66'), true),
array('uuid', array('ff6f8cb0-c57d-51e1-9b21-0800200c9a66'), true),
array('uuid', array('FF6F8CB0-C57D-11E1-9B21-0800200C9A66'), true),
array('uuid', array('zf6f8cb0-c57d-11e1-9b21-0800200c9a66'), false),
array('uuid', array('af6f8cb0c57d11e19b210800200c9a66'), false),
array('uuid', array('ff6f8cb0-c57da-51e1-9b21-0800200c9a66'), false),
array('uuid', array('af6f8cb-c57d-11e1-9b21-0800200c9a66'), false),
array('uuid', array('3f6f8cb0-c57d-11e1-9b21-0800200c9a6'), false),
);
}