Skip to content

Commit

Permalink
Fix PHPStan v0.12, run CS fixer (#295)
Browse files Browse the repository at this point in the history
* Fix PHPStan v0.12

* Code style autofixes

* PHPStan fixes in MethodDocGenerator

Co-authored-by: Krzysztof Śmiałek <krzysztof.smialek@amsterdamstandard.com>
  • Loading branch information
gronostajo and Krzysztof Śmiałek authored May 22, 2020
1 parent ed28db1 commit 10eef03
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 317 deletions.
21 changes: 19 additions & 2 deletions bin/MethodDocGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*/
class MethodDocGenerator
{
/**
* @return void
*/
public function generateChainDocs()
{
$phpFile = __DIR__.'/../lib/Assert/AssertionChain.php';
Expand All @@ -34,10 +37,10 @@ public function generateChainDocs()
/**
* @param ReflectionMethod[] $methods
* @param string $format
* @param callable|false $skipParameterTest
* @param callable|bool $skipParameterTest
* @param string $prefix
*
* @return array
* @return string[]
*
* @throws AssertionFailedException
*/
Expand All @@ -47,6 +50,7 @@ private function generateMethodDocs($methods, $format, $skipParameterTest, $pref
asort($methods);
foreach ($methods as $method) {
$doc = $method->getDocComment();
assert($doc !== false);
list(, $descriptionLine) = explode("\n", $doc);
$shortDescription = trim(substr($descriptionLine, 7), '.');
$methodName = $prefix.($prefix ? ucfirst($method->getName()) : $method->getName());
Expand Down Expand Up @@ -132,11 +136,15 @@ function (ReflectionMethod $reflMethod) {
* @param string $phpFile
* @param string[] $lines
* @param string $fileType
*
* @return void
*/
private function generateFile($phpFile, $lines, $fileType)
{
$phpFile = realpath($phpFile);
assert($phpFile !== false);
$fileContent = file_get_contents($phpFile);
assert($fileContent !== false);

switch ($fileType) {
case 'class':
Expand All @@ -162,6 +170,9 @@ private function generateFile($phpFile, $lines, $fileType)
}
}

/**
* @return void
*/
public function generateAssertionDocs()
{
$phpFile = __DIR__.'/../lib/Assert/Assertion.php';
Expand All @@ -177,6 +188,9 @@ public function generateAssertionDocs()
$this->generateFile($phpFile, $docs, 'class');
}

/**
* @return void
*/
public function generateReadMe()
{
$mdFile = __DIR__.'/../README.md';
Expand All @@ -189,6 +203,9 @@ public function generateReadMe()
$this->generateFile($mdFile, $docs, 'readme');
}

/**
* @return void
*/
public function generateLazyAssertionDocs()
{
$phpFile = __DIR__.'/../lib/Assert/LazyAssertion.php';
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "*",
"phpstan/phpstan-shim": "*",
"phpstan/phpstan": "*",
"phpunit/phpunit": ">=6.0.0 <8"
},
"autoload": {
Expand Down
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

0 comments on commit 10eef03

Please sign in to comment.