Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Php 84 upgrade #922

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
2 changes: 0 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ jobs:
php:
- '8.2'
- '8.1'
- '8.0'
deps:
- highest
include:
- {php: '8.0', deps: lowest}
- {php: '8.1', deps: dingo}

name: Tests (PHP ${{ matrix.php }} - ${{ matrix.deps }})
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ docs/make.bat
tests/public/docs/
tests/resources/**
.phpunit.result.cache
.phpunit.cache/
25 changes: 12 additions & 13 deletions composer.dingo.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,36 @@
}
],
"require": {
"php": ">=8.0",
"php": ">=8.1",
"ext-fileinfo": "*",
"ext-json": "*",
"ext-pdo": "*",
"dingo/api": "^2.3|^3.0",
"erusev/parsedown": "1.7.4",
"fakerphp/faker": "^1.9.1",
"illuminate/console": "^8.0|^9.0",
"illuminate/routing": "^8.0|^9.0",
"illuminate/support": "^8.0|^9.0",
"fakerphp/faker": "^1.24.1",
"illuminate/console": "^8.0|^9.0|^10.0|^11.0",
"illuminate/routing": "^8.0|^9.0|^10.0|^11.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0",
"league/flysystem": "^1.1.4|^2.1.1|^3.0",
"mpociot/reflection-docblock": "^1.0.1",
"nikic/php-parser": "^5.0",
"nunomaduro/collision": "^5.10|^6.0|^7.0|^8.0",
"ramsey/uuid": "^4.2.2",
"shalvah/clara": "^3.1.0",
"shalvah/upgrader": ">=0.6.0",
"spatie/data-transfer-object": "^2.6|^3.0",
"spatie/data-transfer-object": "^3.1",
"symfony/var-exporter": "^5.4|^6.0|^7.0",
"symfony/yaml": "^5.4|^6.0|^7.0"
},
"require-dev": {
"brianium/paratest": "^6.0",
"dms/phpunit-arraysubset-asserts": "^0.2.0",
"brianium/paratest": "^6.0|^7.0",
"dms/phpunit-arraysubset-asserts": "^0.5",
"laravel/legacy-factories": "^1.3.0",
"laravel/lumen-framework": "^8.0|^9.0",
"league/fractal": "^0.19.0",
"league/fractal": "^0.20.1",
"nikic/fast-route": "^1.3",
"orchestra/testbench": "^6.0|^7.0",
"pestphp/pest": "^1.21",
"phpstan/phpstan": "^1.0",
"orchestra/testbench": "^6.0|^7.0|^8.0",
"pestphp/pest": "^2.20",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^9.0|^10.0",
"symfony/css-selector": "^5.4|^6.0",
"symfony/dom-crawler": "^5.4|^6.0"
Expand Down
19 changes: 9 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
}
],
"require": {
"php": ">=8.0",
"php": ">=8.1",
"ext-fileinfo": "*",
"ext-json": "*",
"ext-pdo": "*",
"erusev/parsedown": "1.7.4",
"fakerphp/faker": "^1.9.1",
"fakerphp/faker": "^1.23.1",
"illuminate/console": "^8.0|^9.0|^10.0|^11.0",
"illuminate/routing": "^8.0|^9.0|^10.0|^11.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0",
Expand All @@ -31,20 +31,19 @@
"ramsey/uuid": "^4.2.2",
"shalvah/clara": "^3.1.0",
"shalvah/upgrader": ">=0.6.0",
"spatie/data-transfer-object": "^2.6|^3.0",
"spatie/data-transfer-object": "^3.1",
"symfony/var-exporter": "^5.4|^6.0|^7.0",
"symfony/yaml": "^5.4|^6.0|^7.0"
},
"require-dev": {
"brianium/paratest": "^6.0",
"dms/phpunit-arraysubset-asserts": "^0.4",
"brianium/paratest": "^6.0|^7.0",
"dms/phpunit-arraysubset-asserts": "^0.4|^0.5",
"laravel/legacy-factories": "^1.3.0",
"laravel/lumen-framework": "^8.0|^9.0|^10.0",
"league/fractal": "^0.20",
"league/fractal": "^0.20.1",
"nikic/fast-route": "^1.3",
"orchestra/testbench": "^6.0|^7.0|^8.0",
"pestphp/pest": "^1.21",
"phpstan/phpstan": "^1.0",
"pestphp/pest": "^2.20",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^9.0|^10.0",
"symfony/css-selector": "^5.4|^6.0",
"symfony/dom-crawler": "^5.4|^6.0"
Expand All @@ -62,7 +61,7 @@
},
"scripts": {
"lint": "phpstan analyse -c ./phpstan.neon src camel --memory-limit 1G",
"test": "pest --stop-on-failure --exclude-group dingo --colors",
"test": "pest --exclude-group dingo --colors",
"test-ci": "pest --exclude-group dingo --coverage --min=80",
"test-parallel": "paratest -p16 --stop-on-failure --exclude-group dingo",
"test-parallel-ci": "paratest -p16 --exclude-group dingo"
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ parameters:
- '#Call to an undefined method Illuminate\\Routing\\Route::versions\(\).#'
- '#Call to an undefined method ReflectionType::getName\(\).#'
- '#.+Dingo.+#'
- '#.+Laravel\\Lumen\\Application.+#'
- '#Call to an undefined method Illuminate\\Contracts\\Filesystem\\Filesystem::path\(\)#'
- '#Call to an undefined method Illuminate\\Contracts\\Foundation\\Application::forgetInstance\(\)#'
- '#Access to an undefined property Illuminate\\Support\\HigherOrderCollectionProxy#'
Expand Down
59 changes: 24 additions & 35 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
cacheResult="true"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
<directory suffix=".php">camel/</directory>
</include>
<exclude>
<file>src/ScribeServiceProvider.php</file>
<file>src/Tools/ConfigDiffer.php</file>
<file>src/Commands/DiffConfig.php</file>
</exclude>
</coverage>
<php>
<server name="SCRIBE_TESTS" value="1" />
</php>
<testsuites>
<testsuite name="Non-Unit Tests">
<directory>tests/GenerateDocumentation/OutputTest.php</directory>
<directory>tests/Strategies</directory>
</testsuite>
<testsuite name="Unit Tests">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" cacheResult="true" colors="false" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<php>
<server name="SCRIBE_TESTS" value="1"/>
</php>
<testsuites>
<testsuite name="Non-Unit Tests">
<file>tests/GenerateDocumentation/OutputTest.php</file>
<directory>tests/Strategies</directory>
</testsuite>
<testsuite name="Unit Tests">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src/</directory>
<directory suffix=".php">camel/</directory>
</include>
<exclude>
<file>src/ScribeServiceProvider.php</file>
<file>src/Tools/ConfigDiffer.php</file>
<file>src/Commands/DiffConfig.php</file>
</exclude>
</source>
</phpunit>
8 changes: 4 additions & 4 deletions src/Config/Extracting.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function auth(
bool $default = false,
string $in = 'bearer',
string $name = 'key',
string $useValue = null,
?string $useValue = null,
string $placeholder = '{YOUR_AUTH_KEY}',
string $extraInfo = ''
): array
Expand All @@ -48,10 +48,10 @@ public static function with(
Routes $routes,
string $defaultGroup = 'Endpoints',
array $databaseConnectionsToTransact = [],
int $fakerSeedForExamples = null,
?int $fakerSeedForExamples = null,
array $dataSourcesForExampleModels = ['factoryCreate', 'factoryMake', 'databaseFirst'],
string $routeMatcher = null,
string $fractalSerializer = null,
?string $routeMatcher = null,
?string $fractalSerializer = null,
array $auth = [],
array $strategies = [],
): Extracting
Expand Down
6 changes: 3 additions & 3 deletions src/Config/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Output
{
public static function with(
string $theme = 'default',
string $title = null,
?string $title = null,
string $description = '',
array $baseUrls = [],
array $exampleLanguages = ['bash', 'javascript'],
Expand Down Expand Up @@ -45,7 +45,7 @@ public function __construct(
public static function laravelType(
bool $addRoutes = true,
string $docsUrl = '/docs',
string $assetsDirectory = null,
?string $assetsDirectory = null,
array $middleware = [],
): array
{
Expand Down Expand Up @@ -93,7 +93,7 @@ public static function openApi(

public static function tryItOut(
bool $enabled = true,
string $baseUrl = null,
?string $baseUrl = null,
bool $useCsrf = false,
string $csrfUrl = '/sanctum/csrf-cookie',
): array
Expand Down
2 changes: 1 addition & 1 deletion src/Extracting/ApiDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ApiDetails

public function __construct(
PathConfig $paths,
DocumentationConfig $config = null,
?DocumentationConfig $config = null,
bool $preserveUserChanges = true
) {
$this->markdownOutputPath = $paths->intermediateOutputPath(); //.scribe by default
Expand Down
2 changes: 1 addition & 1 deletion src/Extracting/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Extractor

private static ?Route $routeBeingProcessed = null;

public function __construct(DocumentationConfig $config = null)
public function __construct(?DocumentationConfig $config = null)
{
// If no config is injected, pull from global
$this->config = $config ?: new DocumentationConfig(config('scribe'));
Expand Down
2 changes: 1 addition & 1 deletion src/Extracting/ParamHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function getDummyValueGenerator(string $type, array $hints = []): \Clo
return $fakeFactoriesByType[$baseType] ?? $fakeFactoriesByType['string'];
}

private function getDummyDataGeneratorBetween(string $type, $min, $max = 90, string $fieldName = null): \Closure
private function getDummyDataGeneratorBetween(string $type, $min, $max = 90, ?string $fieldName = null): \Closure
{
$hints = [
'name' => $fieldName,
Expand Down
4 changes: 1 addition & 3 deletions src/Extracting/Shared/ResponseFileTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ public static function getResponseContents($filePath, array|string|null $merge):
return json_encode(array_merge(json_decode($content, true), json_decode($json, true)));
}

if (is_array($merge)) {
return json_encode(array_merge(json_decode($content, true), $merge));
}
return json_encode(array_merge(json_decode($content, true), $merge));
}

protected static function getFileContents($filePath): string
Expand Down
3 changes: 2 additions & 1 deletion src/Extracting/Shared/UrlParamsNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public static function getTypeHintedEnums(ReflectionFunctionAbstract $method): a
* @return string|null
*/
protected static function getRouteKeyForUrlParam(
Route $route, string $paramName, array $typeHintedEloquentModels = [], string $default = null
Route $route, string $paramName, array $typeHintedEloquentModels = [], ?string $default = null
): ?string
{
if ($binding = self::getInlineRouteKey($route, $paramName)) {
Expand All @@ -166,6 +166,7 @@ protected static function getRouteKeyForUrlParam(
protected static function getInlineRouteKey(Route $route, string $paramName): ?string
{
// Was added in Laravel 7.x
// @phpstan-ignore-next-line
if (method_exists($route, 'bindingFieldFor')) {
return $route->bindingFieldFor($paramName);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Extracting/Strategies/Metadata/GetFromDocBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getMetadataFromDocBlock(DocBlock $methodDocBlock, DocBlock $clas
return $metadata;
}

protected function getAuthStatusFromDocBlock(DocBlock $methodDocBlock, DocBlock $classDocBlock = null): ?bool
protected function getAuthStatusFromDocBlock(DocBlock $methodDocBlock, ?DocBlock $classDocBlock = null): ?bool
{
foreach ($methodDocBlock->getTags() as $tag) {
if (strtolower($tag->getName()) === 'authenticated') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected function setTypesAndExamplesForOthers(array $parameters, ExtractedEndp
*
* @return string|null
*/
protected function getNameOfUrlThing(string $url, string $paramName, string $alternateParamName = null): ?string
protected function getNameOfUrlThing(string $url, string $paramName, ?string $alternateParamName = null): ?string
{
$parts = explode("/", $url);
if (count($parts) === 1) return null; // URL was "/{thing}"
Expand Down
1 change: 0 additions & 1 deletion src/GroupedEndpoints/GroupedEndpointsFromApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ private function mergeAnyEndpointDataUpdates(ExtractedEndpointData $endpointData
protected function writeEndpointsToDisk(array $grouped): void
{
Utils::deleteFilesMatching(static::$camelDir, function ($file) {
/** @var $file array|\League\Flysystem\StorageAttributes */
return !Str::startsWith(basename($file['path']), 'custom.');
});
Utils::deleteDirectoryAndContents(static::$cacheDir);
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/BladeMarkdownEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BladeMarkdownEngine extends CompilerEngine
{
private Parsedown $markdown;

public function __construct(CompilerInterface $compiler, Filesystem $files = null)
public function __construct(CompilerInterface $compiler, ?Filesystem $files = null)
{
parent::__construct($compiler, $files ?: new Filesystem);
$this->markdown = Parsedown::instance();
Expand Down
4 changes: 2 additions & 2 deletions src/Tools/PathConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
}
}

public function outputPath(string $resolvePath = null, string $separator = '/'): string
public function outputPath(?string $resolvePath = null, string $separator = '/'): string
{
if (is_null($resolvePath)) {
return $this->configName;
Expand All @@ -36,7 +36,7 @@ public function configFileName(): string
/**
* The directory where Scribe writes its intermediate output (default is .<config> ie .scribe)
*/
public function intermediateOutputPath(string $resolvePath = null, string $separator = '/'): string
public function intermediateOutputPath(?string $resolvePath = null, string $separator = '/'): string
{
if (is_null($resolvePath)) {
return $this->scribeDir;
Expand Down
2 changes: 1 addition & 1 deletion src/Writing/HtmlWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HtmlWriter
protected string $assetPathPrefix;
protected MarkdownParser $markdownParser;

public function __construct(DocumentationConfig $config = null)
public function __construct(?DocumentationConfig $config = null)
{
$this->config = $config ?: new DocumentationConfig(config('scribe', []));
$this->markdownParser = new MarkdownParser();
Expand Down
6 changes: 3 additions & 3 deletions src/Writing/OpenAPISpecWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class OpenAPISpecWriter

private DocumentationConfig $config;

public function __construct(DocumentationConfig $config = null)
public function __construct(?DocumentationConfig $config = null)
{
$this->config = $config ?: new DocumentationConfig(config('scribe', []));
}
Expand Down Expand Up @@ -400,7 +400,7 @@ protected function generateResponseContentSpec(?string $responseContent, OutputE
],
'example' => $decoded,
],
],
],
];

case 'object':
Expand Down Expand Up @@ -661,7 +661,7 @@ public function filterRequiredFields(OutputEndpointData $endpoint, array $proper

return $required;
}

/*
* Set the description for the schema. If the field has a description, it is set in the schema.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Writing/PostmanCollectionWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PostmanCollectionWriter

protected string $baseUrl;

public function __construct(DocumentationConfig $config = null)
public function __construct(?DocumentationConfig $config = null)
{
$this->config = $config ?: new DocumentationConfig(config('scribe', []));
$this->baseUrl = $this->config->get('base_url') ?: config('app.url');
Expand Down
Loading
Loading