Skip to content

Commit

Permalink
Merge branch 'master' into v3
Browse files Browse the repository at this point in the history
* master:
  Update URL Regex from Symfony project (Fixes #281) Includes unit tests.
  Backfill 2.9.7 changelog
  Fixed method doc generator for the 'NullOr' methods
  LazyAssertion magic calls return $this (#278)
  Update .travis.yml
  • Loading branch information
Richard Quadling authored and Richard Quadling committed May 28, 2019
2 parents b1b4850 + f6ca754 commit 25e18b5
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 200 deletions.
10 changes: 0 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,10 @@ matrix:
env:
- LINT=true COVERAGE=true
- php: 7.1
env:
- LINT=true
- php: 7.2
env:
- LINT=true
- php: 7.3.0
env:
- LINT=true
- php: 7.3.1
env:
- LINT=true
- php: 7.3.2
env:
- LINT=true
- php: nightly
- php: hhvm-3.9
sudo: required
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ All notable changes to this project will be documented in this file.
### Fixes
- An `AssertionFailedException` must be a `Throwable` (Thanks to [Marco Pivetta](https://github.com/beberlei/assert/pull/256))

## 2.9.7 - 2019-02-19

### Fixes
- Fixed broken regex for `Assert\Assertion::url()` (Thanks to [Menno Holtkamp](https://github.com/beberlei/assert/issues/275))

## 2.9.6 - 2018-04-16

### Fixes
Expand Down
11 changes: 8 additions & 3 deletions bin/MethodDocGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private function generateMethodDocs($methods, $format, $skipParameterTest, $pref

$parameters = [];

foreach ($method->getParameters() as $methodParameter) {
foreach ($method->getParameters() as $parameterIndex => $methodParameter) {
if (
(\is_bool($skipParameterTest) && $skipParameterTest) ||
(\is_callable($skipParameterTest) && $skipParameterTest($methodParameter))
Expand All @@ -77,6 +77,11 @@ private function generateMethodDocs($methods, $format, $skipParameterTest, $pref
: $matches['type'];
}
}

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

\Assert\Assertion::notEmpty($type, \sprintf('No type defined for %s in %s', $parameter, $methodName));
$parameter = \sprintf('%s %s', $type, $parameter);

Expand Down Expand Up @@ -189,8 +194,8 @@ public function generateLazyAssertionDocs()
};

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

$this->generateFile($phpFile, $docs, 'class');
Expand Down
Loading

0 comments on commit 25e18b5

Please sign in to comment.