Skip to content

Commit

Permalink
fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
d8vjork committed Sep 7, 2023
1 parent 41ff48f commit cf4182b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Commands/DtoMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function buildClass($name)
* Replace the namespace for the given stub.
*
* @param string $stub
* @param string $name
* @param string $requestClass
* @return $this
*/
protected function replaceProperties(&$stub, $requestClass)
Expand All @@ -104,6 +104,12 @@ protected function replaceProperties(&$stub, $requestClass)
return $this;
}

/**
* Get the request properties for the given class.
*
* @param string $requestClass
* @return $this
*/
protected function getProperties(string $requestClass)
{
$requestInstance = app($requestClass);
Expand All @@ -115,7 +121,7 @@ protected function getProperties(string $requestClass)
// TODO: Sort nulls here to be prepended (need to create array first)
foreach ($requestRules as $property => $rules) {
if (str_ends_with('_id', $property)) {
$property = str_replace_last('/_id$/gu', '', $property);
$property = str_replace('/_id$/gu', '', $property);
}

$property = Str::camel($property);
Expand Down Expand Up @@ -150,6 +156,13 @@ protected function getProperties(string $requestClass)
return $properties;

Check failure on line 156 in src/Commands/DtoMakeCommand.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method OpenSoutheners\LaravelDto\Commands\DtoMakeCommand::getProperties() should return $this(OpenSoutheners\LaravelDto\Commands\DtoMakeCommand) but returns string.
}

/**
* Replace the request class for the given stub.
*
* @param string $stub
* @param string $requestClass
* @return string
*/
public function replaceRequestClass(&$stub, $requestClass)
{
$requestClass ??= '// ';

Check failure on line 168 in src/Commands/DtoMakeCommand.php

View workflow job for this annotation

GitHub Actions / PHPStan

Variable $requestClass on left side of ??= always exists and is not nullable.
Expand Down

0 comments on commit cf4182b

Please sign in to comment.