Skip to content

Commit

Permalink
Merge pull request #162 from knuckleswtf/php8
Browse files Browse the repository at this point in the history
PHP 8 compatibility
  • Loading branch information
shalvah authored Dec 16, 2020
2 parents 49b7fbf + 06bed64 commit 5b571f4
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 28 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ matrix:
- php: 7.4
- php: 7.4
env: SETUP=lowest
- php: 8.0

cache:
directories:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Generate API documentation for humans from your Laravel codebase. [Here's what t

[![Latest Stable Version](https://poser.pugx.org/knuckleswtf/scribe/v/stable)](https://packagist.org/packages/knuckleswtf/scribe) [![Total Downloads](https://poser.pugx.org/knuckleswtf/scribe/downloads)](https://packagist.org/packages/knuckleswtf/scribe) [![Build Status](https://travis-ci.com/knuckleswtf/scribe.svg?branch=master)](https://travis-ci.com/knuckleswtf/scribe)

> 👋 Scribe helps you generate docs automatically, but if you really want to make friendly, maintainable and testable API docs, there's some more things you need to know. So I made [a course](https://apidocsfordevs.com?utm_source=scribe-laravel&utm_medium=referral&utm_campaign=launch) for you.🤗
> 👋 Scribe helps you generate docs automatically, but if you really want to make friendly, maintainable and testable API docs, there's some more things you need to know. So I made [a course](https://apidocsfordevs.com?utm_source=scribe-laravel&utm_medium=referral&utm_campaign=none) for you.🤗
## Features
- Pretty HTML documentation page, with included code samples and friendly text
Expand Down
6 changes: 3 additions & 3 deletions composer.dingo.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
"symfony/yaml": "^4.0|^5.0"
},
"require-dev": {
"dms/phpunit-arraysubset-asserts": "^0.1.0",
"brianium/paratest": "^4.0",
"brianium/paratest": "^5.0|^6.0",
"dms/phpunit-arraysubset-asserts": "^0.2.0",
"league/fractal": "^0.19.0",
"laravel/legacy-factories": "^1.0.4",
"laravel/lumen-framework": "^6.0|^7.0|^8.0",
"orchestra/testbench": "^4.0|^5.0|^6.0",
"phpstan/phpstan": "^0.12.19",
"phpunit/phpunit": "^8.0|^9.0"
"phpunit/phpunit": "^9.0"
},
"suggest": {
"league/fractal": "Required for transformers support"
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
"symfony/yaml": "^4.0|^5.0"
},
"require-dev": {
"brianium/paratest": "^4.0",
"dms/phpunit-arraysubset-asserts": "^0.1.0",
"brianium/paratest": "^5.0|^6.0",
"dms/phpunit-arraysubset-asserts": "^0.2.0",
"laravel/legacy-factories": "^1.0.4",
"laravel/lumen-framework": "^6.0|^7.0|^8.0",
"league/fractal": "^0.19.0",
"nikic/fast-route": "^1.3",
"orchestra/testbench": "^4.0|^5.0",
"orchestra/testbench": "^4.0|^5.0|^6.0",
"phpstan/phpstan": "^0.12.19",
"phpunit/phpunit": "^8.0|^9.0"
"phpunit/phpunit": "^9.0"
},
"suggest": {
"league/fractal": "Required for transformers support"
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Generate API documentation for humans from your Laravel/Lumen/[Dingo](https://gi
```

```eval_rst
.. Tip:: Scribe helps you generate docs automatically, but if you really want to make friendly, maintainable and testable API docs, there's some more stuff you need to know. So I made `a course <https://apidocsfordevs.com?utm_source=scribe-laravel-docs&utm_medium=referral&utm_campaign=launch>`_ for you.🤗
.. Tip:: Scribe helps you generate docs automatically, but if you really want to make friendly, maintainable and testable API docs, there's some more stuff you need to know. So I made `a course <https://apidocsfordevs.com?utm_source=scribe-laravel-docs&utm_medium=referral&utm_campaign=none>`_ for you.🤗
```

## Features
Expand Down
24 changes: 13 additions & 11 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
cacheResult="true"
Expand All @@ -8,7 +9,17 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<file>src/ScribeServiceProvider.php</file>
<file>resources/views/pastel.blade.php</file>
</exclude>
</coverage>
<testsuites>
<testsuite name="Full Test">
<file>tests/GenerateDocumentationTest.php</file>
Expand All @@ -30,13 +41,4 @@
<file>tests/Unit/PostmanCollectionWriterTest.php</file>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
<exclude>
<file>src/ScribeServiceProvider.php</file>
<file>resources/views/pastel.blade.php</file>
</exclude>
</whitelist>
</filter>
</phpunit>
4 changes: 2 additions & 2 deletions src/Commands/GenerateDocumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
use Knuckles\Scribe\Extracting\Generator;
use Knuckles\Scribe\Matching\Match;
use Knuckles\Scribe\Matching\MatchedRoute;
use Knuckles\Scribe\Matching\RouteMatcherInterface;
use Knuckles\Scribe\Tools\ConsoleOutputUtils as c;
use Knuckles\Scribe\Tools\DocumentationConfig;
Expand Down Expand Up @@ -84,7 +84,7 @@ public function handle(RouteMatcherInterface $routeMatcher)
}

/**
* @param Match[] $matches
* @param MatchedRoute[] $matches
*
* @return array
* @throws \ReflectionException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use ReflectionClass;
use ReflectionException;
use ReflectionFunctionAbstract;
use ReflectionUnionType;

class GetFromBodyParamTag extends Strategy
{
Expand All @@ -33,6 +34,11 @@ public function getBodyParametersFromDocBlockInFormRequestOrMethod(Route $route,
continue;
}

if (class_exists(ReflectionUnionType::class)
&& $paramType instanceof ReflectionUnionType) {
continue;
}

$parameterClassName = $paramType->getName();

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use ReflectionException;
use ReflectionFunctionAbstract;
use Illuminate\Contracts\Validation\Factory as ValidationFactory;
use ReflectionUnionType;

class GetFromFormRequest extends Strategy
{
Expand All @@ -42,6 +43,11 @@ public function getBodyParametersFromFormRequest(ReflectionFunctionAbstract $met
continue;
}

if (class_exists(ReflectionUnionType::class)
&& $paramType instanceof ReflectionUnionType) {
continue;
}

$parameterClassName = $paramType->getName();

if (!class_exists($parameterClassName)) {
Expand Down
6 changes: 6 additions & 0 deletions src/Extracting/Strategies/Headers/GetFromHeaderTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Mpociot\Reflection\DocBlock\Tag;
use ReflectionClass;
use ReflectionFunctionAbstract;
use ReflectionUnionType;

class GetFromHeaderTag extends Strategy
{
Expand All @@ -27,6 +28,11 @@ public function __invoke(Route $route, ReflectionClass $controller, ReflectionFu
continue;
}

if (class_exists(ReflectionUnionType::class)
&& $paramType instanceof ReflectionUnionType) {
continue;
}

$parameterClassName = $paramType->getName();

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Mpociot\Reflection\DocBlock\Tag;
use ReflectionClass;
use ReflectionFunctionAbstract;
use ReflectionUnionType;

class GetFromQueryParamTag extends Strategy
{
Expand All @@ -33,6 +34,11 @@ public function getQueryParametersFromFormRequestOrMethod(Route $route, Reflecti
continue;
}

if (class_exists(ReflectionUnionType::class)
&& $paramType instanceof ReflectionUnionType) {
continue;
}

$parameterClassName = $paramType->getName();

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Mpociot\Reflection\DocBlock\Tag;
use ReflectionClass;
use ReflectionFunctionAbstract;
use ReflectionUnionType;

class GetFromUrlParamTag extends Strategy
{
Expand All @@ -28,6 +29,11 @@ public function __invoke(Route $route, ReflectionClass $controller, ReflectionFu
continue;
}

if (class_exists(ReflectionUnionType::class)
&& $paramType instanceof ReflectionUnionType) {
continue;
}

$parameterClassName = $paramType->getName();

try {
Expand Down
2 changes: 1 addition & 1 deletion src/Matching/Match.php → src/Matching/MatchedRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Routing\Route;

class Match implements \ArrayAccess
class MatchedRoute implements \ArrayAccess
{
/**
* @var Route
Expand Down
2 changes: 1 addition & 1 deletion src/Matching/RouteMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private function getRoutesToBeDocumented(array $routeRules, bool $usingDingoRout
}

if ($this->shouldIncludeRoute($route, $routeRule, $includes, $usingDingoRouter)) {
$matchedRoutes[] = new Match($route, $routeRule['apply'] ?? []);
$matchedRoutes[] = new MatchedRoute($route, $routeRule['apply'] ?? []);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Matching/RouteMatcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface RouteMatcherInterface
* @param array $routeRules Route rules defined under the "routes" section in config
* @param string $router
*
* @return Match[]
* @return MatchedRoute[]
*/
public function getRoutes(array $routeRules = [], string $router = 'laravel');
}
6 changes: 3 additions & 3 deletions tests/Unit/PostmanCollectionWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function testUrlParametersAreNotIncludedIfMissingFromPath()
}

/** @test */
public function query_parameters_are_disabled_with_no_value_when_notRequired()
public function query_parameters_are_disabled_with_no_value_when_not_required()
{
$fakeRoute = $this->createMockRouteData('fake/path');
$fakeRoute['queryParameters'] = [
Expand Down Expand Up @@ -198,13 +198,13 @@ public function query_parameters_are_disabled_with_no_value_when_notRequired()
$this->assertCount(2, $variableData);
$this->assertContains([
'key' => 'required',
'value' => null,
'value' => '',
'description' => 'A required param with a null value',
'disabled' => false,
], $variableData);
$this->assertContains([
'key' => 'not_required',
'value' => null,
'value' => '',
'description' => 'A not required param with a null value',
'disabled' => true,
], $variableData);
Expand Down

0 comments on commit 5b571f4

Please sign in to comment.