Skip to content

Commit

Permalink
Resolve PHP 8.4 deprecations (#929)
Browse files Browse the repository at this point in the history
  • Loading branch information
markwalet authored Dec 30, 2024
1 parent f00f6bf commit fcc0f5c
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 21 deletions.
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
2 changes: 1 addition & 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 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
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

0 comments on commit fcc0f5c

Please sign in to comment.