Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,51 @@
# Change Log
All notable changes to this project will be documented in this file.

## 3.3 - 2020-11-20

### Added assertions
- `Assert\Assertion::ulid()`

## 3.2.7 - 2019-12-19

### Fixes
- Reinstated the `@method` return type for `Assert\LazyAssertion` methods to show that the return type is `LazyAssertion`.

## 3.2.6 - 2019-10-10

### Fixes
- Make `Assert\Assertion::stringify()` UTF-8 safe (Thanks to [Pedram Azimaei](https://github.com/beberlei/assert/pull/290))

## 3.2.5 - 2019-10-10 - Fix the broken things release.

### Notice
- Sigh!
- Richard Quadling

### Fixes
- REALLY Removed dependency of the intl extension.
- Updated the Docblocks for `Assert\Assertion::all()` helper to show that the value is expected to be an array.

## 3.2.4 - 2019-10-10 - Fix the broken things release.

### Notice
- It seems I've been slightly lax in verifying the signature changes and expected extensions.
Hopefully, both of these have been fixed in this version.
Truly sorry for breaking the internet!
- Richard Quadling

### Fixes
- Restored `\Assert\Assertion::createException()` signature to 3.2.2.
- Removed dependency of the intl extension. If the extension is available, then `Assert\Assertion::count()`,
`Assert\Assertion::isCountable()`, `Assert\Assertion::minCount()`, and `Assert\Assertion::maxCount()` will operate on
`ResourceBundles`.
- Fixed the `@method` return type for `Assert\LazyAssertion` methods to show that the return type is `static` for
extensions of `Assert\LazyAssertion`.
*NOTE :* Docblock does not have the ability to differentiate between a non static `@method` whose returns type is of
the subclass and a `@method` that is called statically ([PSR-5#899](https://github.com/php-fig/fig-standards/pull/899)).
So the use of `static static` is a fudge that sort of works for IDEs that need to know about the method that MAY be
overridden in a subclass.

## 3.2.3 - 2019-08-23

### Other changes
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ Assertion::startsWith(mixed $string, string $needle);
Assertion::string(mixed $value);
Assertion::subclassOf(mixed $value, string $className);
Assertion::true(mixed $value);
Assertion::ulid(string $value);
Assertion::url(mixed $value);
Assertion::uuid(string $value);
Assertion::version(string $version1, string $operator, string $version2);
Expand Down
8 changes: 6 additions & 2 deletions bin/MethodDocGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ private function generateMethodDocs($methods, $format, $skipParameterTest, $pref
}
}

if ($prefix === 'all' && strpos($type, 'null') === false && $parameterIndex === 0) {
$type = str_replace('|', '[]|', $type).'[]';
}

if ($prefix === 'nullOr' && strpos($type, 'null') === false && $parameterIndex === 0) {
$type .= '|null';
}
Expand Down Expand Up @@ -197,8 +201,8 @@ public function generateLazyAssertionDocs()
};

$docs = array_merge(
$this->generateMethodDocs($this->gatherAssertions(), ' * @method $this %s(%s) %s.', $skipParameterTest),
$this->generateMethodDocs($this->gatherAssertionChainSwitches(), ' * @method $this %s(%s) %s.', false)
$this->generateMethodDocs($this->gatherAssertions(), ' * @method LazyAssertion %s(%s) %s.', $skipParameterTest),
$this->generateMethodDocs($this->gatherAssertionChainSwitches(), ' * @method LazyAssertion %s(%s) %s.', false)
);

$this->generateFile($phpFile, $docs, 'class');
Expand Down
34 changes: 18 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,6 @@
"assertion",
"validation"
],
"config": {
"sort-packages": true
},
"require": {
"php": "^7",
"ext-intl": "*",
"ext-simplexml": "*",
"ext-mbstring": "*",
"ext-ctype": "*",
"ext-json": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "*",
"phpstan/phpstan-shim": "*",
"phpunit/phpunit": ">=6.0.0 <8"
},
"autoload": {
"psr-4": {
"Assert\\": "lib/Assert"
Expand All @@ -51,11 +35,29 @@
"tests/Assert/Tests/Fixtures/functions.php"
]
},
"config": {
"sort-packages": true
},
"require": {
"php": "^7",
"ext-simplexml": "*",
"ext-mbstring": "*",
"ext-ctype": "*",
"ext-json": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "*",
"phpstan/phpstan-shim": "*",
"phpunit/phpunit": ">=6.0.0 <8"
},
"scripts": {
"assert:generate-docs": "php bin/generate_method_docs.php",
"assert:cs-lint": "php-cs-fixer fix --diff -vvv --dry-run",
"assert:cs-fix": "php-cs-fixer fix . -vvv || true",
"assert:sa-code": "vendor/bin/phpstan analyse --configuration=phpstan-code.neon --no-progress --ansi -l 7 bin lib",
"assert:sa-tests": "vendor/bin/phpstan analyse --configuration=phpstan-tests.neon --no-progress --ansi -l 7 tests"
},
"suggest": {
"ext-intl": "Needed to allow Assertion::count(), Assertion::isCountable(), Assertion::minCount(), and Assertion::maxCount() to operate on ResourceBundles"
}
}
11 changes: 0 additions & 11 deletions lib/Assert/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ abstract class Assert
*
* @param mixed $value
* @param string|callable|null $defaultMessage
* @param string|null $defaultPropertyPath
*
* @return AssertionChain
*
* @example
*
Expand All @@ -57,9 +54,6 @@ public static function that($value, $defaultMessage = null, string $defaultPrope
*
* @param mixed $values
* @param string|callable|null $defaultMessage
* @param string|null $defaultPropertyPath
*
* @return AssertionChain
*/
public static function thatAll($values, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
{
Expand All @@ -71,9 +65,6 @@ public static function thatAll($values, $defaultMessage = null, string $defaultP
*
* @param mixed $value
* @param string|callable|null $defaultMessage
* @param string|null $defaultPropertyPath
*
* @return AssertionChain
*/
public static function thatNullOr($value, $defaultMessage = null, string $defaultPropertyPath = null): AssertionChain
{
Expand All @@ -82,8 +73,6 @@ public static function thatNullOr($value, $defaultMessage = null, string $defaul

/**
* Create a lazy assertion object.
*
* @return LazyAssertion
*/
public static function lazy(): LazyAssertion
{
Expand Down
Loading