The method generateSwaggerByType has a boolean flag argument $errorHandler, which is a certain sign of a Single Responsibility Principle violation. Open
public static function generateSwaggerByType(string $type, string $path = self::PATH, $errorHandler = true): string
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid using static access to class '\OpenApi\Generator' in method 'generateSwaggerByType'. Open
$openApi = \OpenApi\Generator::scan([ROOT_DIRECTORY . '/api/webservice/' . $type]);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\ErrorHandler' in method 'generateSwagger'. Open
$errorString = \App\ErrorHandler::error2string($errNo);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\ErrorHandler' in method 'generateSwaggerByType'. Open
$errorString = \App\ErrorHandler::error2string($errNo);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Call to method scan
from undeclared class \OpenApi\Generator
(Did you mean class \Generator) Open
$openApi = \OpenApi\Generator::scan([ROOT_DIRECTORY . '/api/webservice/' . $type]);
- Exclude checks
Expected @param annotation for path
to be before the @param annotation for errorHandler
Open
* @param bool $errorHandler
- Exclude checks
Argument 1 (error_handler)
is Closure(mixed,mixed,mixed,mixed):void
but \set_error_handler()
takes callable(int,string):bool|callable(int,string,string):bool|callable(int,string,string,int):bool|callable(int,string,string,int,array):bool|null
Open
set_error_handler(function ($errNo, $errStr, $errFile, $errLine) {
- Exclude checks
Argument 1 (error_handler)
is Closure(mixed,mixed,mixed,mixed):void
but \set_error_handler()
takes callable(int,string):bool|callable(int,string,string):bool|callable(int,string,string,int):bool|callable(int,string,string,int,array):bool|null
Open
set_error_handler(function ($errNo, $errStr, $errFile, $errLine) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Generate interactive OpenAPI documentation for your RESTful API using doctrine annotations.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($errorHandler) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
set_error_handler(function ($errNo, $errStr, $errFile, $errLine) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$msg = reset($errorString) . ": {$errStr}\nFile: {$errFile}\nLine: $errLine" . PHP_EOL;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $errorHandler
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$errorString = \App\ErrorHandler::error2string($errNo);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (\Api\Core\Containers::$list as $type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$openApi->saveAs(ROOT_DIRECTORY . "{$path}/{$type}.json");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $openApi->toJson();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $path
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public const PATH = '/api/doc';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$msg = reset($errorString) . ": {$errStr}\nFile: {$errFile}\nLine: $errLine" . PHP_EOL;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Default path */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$openApi->saveAs(ROOT_DIRECTORY . "{$path}/{$type}.yaml");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $path
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
set_error_handler(function ($errNo, $errStr, $errFile, $errLine) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$openApi = \OpenApi\Generator::scan([ROOT_DIRECTORY . '/api/webservice/' . $type]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Generate interactive OpenAPI documentation for your RESTful API using doctrine annotations by type.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$json = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
echo "<pre>$msg</pre><hr>";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
echo "<pre>$msg</pre><hr>";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$errorString = \App\ErrorHandler::error2string($errNo);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function generateSwaggerByType(string $type, string $path = self::PATH, $errorHandler = true): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function generateSwagger(string $path = self::PATH): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}, E_ALL);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$json .= self::generateSwaggerByType($type, $path, false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $json;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}, E_ALL);
- Exclude checks