Switch `concat_space` to default (no space)

This commit is contained in:
DerManoMann 2020-07-30 13:18:45 +12:00
parent 3f1cee99ba
commit b8fc26f3c6
32 changed files with 110 additions and 110 deletions

View File

@ -14,7 +14,7 @@ return PhpCsFixer\Config::create()
'no_unused_imports' => true,
'blank_line_before_statement' => ['statements' => ['return']],
'cast_spaces' => ['space' => 'single'],
'concat_space' => ['spacing' => 'one'],
'concat_space' => true,
'declare_strict_types' => true,
'function_typehint_space' => true,
'lowercase_cast' => true,

View File

@ -23,7 +23,7 @@ if (class_exists('Doctrine\Common\Annotations\AnnotationRegistry', true)) {
$loaded = class_exists($class);
if (!$loaded && $namespace === 'OpenApi\Annotations\\') {
if (in_array(strtolower(substr($class, 20)), ['definition', 'path'])) { // Detected an 2.x annotation?
throw new Exception('The annotation @SWG\\' . substr($class, 20) . '() is deprecated. Found in ' . Analyser::$context . "\nFor more information read the migration guide: https://github.com/zircote/swagger-php/blob/master/docs/Migrating-to-v3.md");
throw new Exception('The annotation @SWG\\'.substr($class, 20).'() is deprecated. Found in '.Analyser::$context."\nFor more information read the migration guide: https://github.com/zircote/swagger-php/blob/master/docs/Migrating-to-v3.md");
}
}
@ -116,14 +116,14 @@ class Analyser
return $annotations;
} catch (Exception $e) {
self::$context = null;
if (preg_match('/^(.+) at position ([0-9]+) in ' . preg_quote((string) $context, '/') . '\.$/', $e->getMessage(), $matches)) {
if (preg_match('/^(.+) at position ([0-9]+) in '.preg_quote((string) $context, '/').'\.$/', $e->getMessage(), $matches)) {
$errorMessage = $matches[1];
$errorPos = (int) $matches[2];
$atPos = strpos($comment, '@');
$context->line += substr_count($comment, "\n", 0, $atPos + $errorPos);
$lines = explode("\n", substr($comment, $atPos, $errorPos));
$context->character = strlen(array_pop($lines)) + 1; // position starts at 0 character starts at 1
Logger::warning(new Exception($errorMessage . ' in ' . $context, $e->getCode(), $e));
Logger::warning(new Exception($errorMessage.' in '.$context, $e->getCode(), $e));
} else {
Logger::warning($e);
}

View File

@ -121,14 +121,14 @@ abstract class AbstractAnnotation implements JsonSerializable
if (is_object($annotation) && $annotation instanceof AbstractAnnotation) {
$annotations[] = $annotation;
} else {
Logger::notice('Unexpected field in ' . $this->identity() . ' in ' . $this->_context);
Logger::notice('Unexpected field in '.$this->identity().' in '.$this->_context);
}
}
$this->merge($annotations);
} elseif (is_object($value)) {
$this->merge([$value]);
} else {
Logger::notice('Unexpected parameter in ' . $this->identity());
Logger::notice('Unexpected parameter in '.$this->identity());
}
}
}
@ -136,7 +136,7 @@ abstract class AbstractAnnotation implements JsonSerializable
public function __get($property)
{
$properties = get_object_vars($this);
Logger::notice('Property "' . $property . '" doesn\'t exist in a ' . $this->identity() . ', existing properties: "' . implode('", "', array_keys($properties)) . '" in ' . $this->_context);
Logger::notice('Property "'.$property.'" doesn\'t exist in a '.$this->identity().', existing properties: "'.implode('", "', array_keys($properties)).'" in '.$this->_context);
}
public function __set($property, $value)
@ -145,7 +145,7 @@ abstract class AbstractAnnotation implements JsonSerializable
foreach (static::$_blacklist as $_property) {
unset($fields[$_property]);
}
Logger::notice('Unexpected field "' . $property . '" for ' . $this->identity() . ', expecting "' . implode('", "', array_keys($fields)) . '" in ' . $this->_context);
Logger::notice('Unexpected field "'.$property.'" for '.$this->identity().', expecting "'.implode('", "', array_keys($fields)).'" in '.$this->_context);
$this->$property = $value;
}
@ -225,7 +225,7 @@ abstract class AbstractAnnotation implements JsonSerializable
if (is_object($this->$property) && $this->$property instanceof AbstractAnnotation) {
$context1 = $this->$property->_context;
}
Logger::warning('Multiple definitions for ' . $identity . '->' . $property . "\n Using: " . $context1 . "\n Skipping: " . $context2);
Logger::warning('Multiple definitions for '.$identity.'->'.$property."\n Using: ".$context1."\n Skipping: ".$context2);
}
}
}
@ -296,7 +296,7 @@ abstract class AbstractAnnotation implements JsonSerializable
unset($data->x);
if (is_array($this->x)) {
foreach ($this->x as $property => $value) {
$prefixed = 'x-' . $property;
$prefixed = 'x-'.$property;
$data->$prefixed = $value;
}
}
@ -357,27 +357,27 @@ abstract class AbstractAnnotation implements JsonSerializable
// Report orphaned annotations
foreach ($this->_unmerged as $annotation) {
if (!is_object($annotation)) {
Logger::notice('Unexpected type: "' . gettype($annotation) . '" in ' . $this->identity() . '->_unmerged, expecting a Annotation object');
Logger::notice('Unexpected type: "'.gettype($annotation).'" in '.$this->identity().'->_unmerged, expecting a Annotation object');
break;
}
$class = get_class($annotation);
if (isset(static::$_nested[$class])) {
$property = static::$_nested[$class];
if (is_array($property)) {
Logger::notice('Only one @' . str_replace('OpenApi\Annotations\\', 'OA\\', get_class($annotation)) . '() allowed for ' . $this->identity() . ' multiple found, skipped: ' . $annotation->_context);
Logger::notice('Only one @'.str_replace('OpenApi\Annotations\\', 'OA\\', get_class($annotation)).'() allowed for '.$this->identity().' multiple found, skipped: '.$annotation->_context);
} else {
Logger::notice('Only one @' . str_replace('OpenApi\Annotations\\', 'OA\\', get_class($annotation)) . '() allowed for ' . $this->identity() . " multiple found in:\n Using: " . $this->$property->_context . "\n Skipped: " . $annotation->_context);
Logger::notice('Only one @'.str_replace('OpenApi\Annotations\\', 'OA\\', get_class($annotation)).'() allowed for '.$this->identity()." multiple found in:\n Using: ".$this->$property->_context."\n Skipped: ".$annotation->_context);
}
} elseif ($annotation instanceof AbstractAnnotation) {
$message = 'Unexpected ' . $annotation->identity();
$message = 'Unexpected '.$annotation->identity();
if (count($class::$_parents)) {
$shortNotations = [];
foreach ($class::$_parents as $_class) {
$shortNotations[] = '@' . str_replace('OpenApi\Annotations\\', 'OA\\', $_class);
$shortNotations[] = '@'.str_replace('OpenApi\Annotations\\', 'OA\\', $_class);
}
$message .= ', expected to be inside ' . implode(', ', $shortNotations);
$message .= ', expected to be inside '.implode(', ', $shortNotations);
}
Logger::notice($message . ' in ' . $annotation->_context);
Logger::notice($message.' in '.$annotation->_context);
}
$valid = false;
}
@ -395,12 +395,12 @@ abstract class AbstractAnnotation implements JsonSerializable
$keyField = $nested[1];
foreach ($this->$property as $key => $item) {
if (is_array($item) && is_numeric($key) === false) {
Logger::notice($this->identity() . '->' . $property . ' is an object literal, use nested @' . str_replace('OpenApi\\Annotations\\', 'OA\\', $annotationClass) . '() annotation(s) in ' . $this->_context);
Logger::notice($this->identity().'->'.$property.' is an object literal, use nested @'.str_replace('OpenApi\\Annotations\\', 'OA\\', $annotationClass).'() annotation(s) in '.$this->_context);
$keys[$key] = $item;
} elseif ($item->$keyField === UNDEFINED) {
Logger::warning($item->identity() . ' is missing key-field: "' . $keyField . '" in ' . $item->_context);
Logger::warning($item->identity().' is missing key-field: "'.$keyField.'" in '.$item->_context);
} elseif (isset($keys[$item->$keyField])) {
Logger::warning('Multiple ' . $item->_identity([]) . ' with the same ' . $keyField . '="' . $item->$keyField . "\":\n " . $item->_context . "\n " . $keys[$item->$keyField]->_context);
Logger::warning('Multiple '.$item->_identity([]).' with the same '.$keyField.'="'.$item->$keyField."\":\n ".$item->_context."\n ".$keys[$item->$keyField]->_context);
} else {
$keys[$item->$keyField] = $item;
}
@ -411,23 +411,23 @@ abstract class AbstractAnnotation implements JsonSerializable
try {
$parents[0]->ref($this->ref);
} catch (Exception $exception) {
Logger::notice($exception->getMessage() . ' for ' . $this->identity() . ' in ' . $this->_context);
Logger::notice($exception->getMessage().' for '.$this->identity().' in '.$this->_context);
}
}
} else {
// Report missing required fields (when not a $ref)
foreach (static::$_required as $property) {
if ($this->$property === UNDEFINED) {
$message = 'Missing required field "' . $property . '" for ' . $this->identity() . ' in ' . $this->_context;
$message = 'Missing required field "'.$property.'" for '.$this->identity().' in '.$this->_context;
foreach (static::$_nested as $class => $nested) {
$nestedProperty = is_array($nested) ? $nested[0] : $nested;
if ($property === $nestedProperty) {
if ($this instanceof OpenApi) {
$message = 'Required @' . str_replace('OpenApi\\Annotations\\', 'OA\\', $class) . '() not found';
$message = 'Required @'.str_replace('OpenApi\\Annotations\\', 'OA\\', $class).'() not found';
} elseif (is_array($nested)) {
$message = $this->identity() . ' requires at least one @' . str_replace('OpenApi\\Annotations\\', 'OA\\', $class) . '() in ' . $this->_context;
$message = $this->identity().' requires at least one @'.str_replace('OpenApi\\Annotations\\', 'OA\\', $class).'() in '.$this->_context;
} else {
$message = $this->identity() . ' requires a @' . str_replace('OpenApi\\Annotations\\', 'OA\\', $class) . '() in ' . $this->_context;
$message = $this->identity().' requires a @'.str_replace('OpenApi\\Annotations\\', 'OA\\', $class).'() in '.$this->_context;
}
break;
}
@ -445,14 +445,14 @@ abstract class AbstractAnnotation implements JsonSerializable
if (is_string($type)) {
if ($this->validateType($type, $value) === false) {
$valid = false;
Logger::notice($this->identity() . '->' . $property . ' is a "' . gettype($value) . '", expecting a "' . $type . '" in ' . $this->_context);
Logger::notice($this->identity().'->'.$property.' is a "'.gettype($value).'", expecting a "'.$type.'" in '.$this->_context);
}
} elseif (is_array($type)) { // enum?
if (in_array($value, $type) === false) {
Logger::notice($this->identity() . '->' . $property . ' "' . $value . '" is invalid, expecting "' . implode('", "', $type) . '" in ' . $this->_context);
Logger::notice($this->identity().'->'.$property.' "'.$value.'" is invalid, expecting "'.implode('", "', $type).'" in '.$this->_context);
}
} else {
throw new Exception('Invalid ' . get_class($this) . '::$_types[' . $property . ']');
throw new Exception('Invalid '.get_class($this).'::$_types['.$property.']');
}
}
$parents[] = $this;
@ -485,7 +485,7 @@ abstract class AbstractAnnotation implements JsonSerializable
if ($value === null || is_scalar($value) || in_array($field, $blacklist)) {
continue;
}
$ref = $baseRef !== '' ? $baseRef . '/' . urlencode((string) $field) : urlencode((string) $field);
$ref = $baseRef !== '' ? $baseRef.'/'.urlencode((string) $field) : urlencode((string) $field);
if (is_object($value)) {
if (method_exists($value, 'validate')) {
if (!$value->validate($parents, $skip, $ref)) {
@ -526,11 +526,11 @@ abstract class AbstractAnnotation implements JsonSerializable
foreach ($properties as $property) {
$value = $this->$property;
if ($value !== null && $value !== UNDEFINED) {
$fields[] = $property . '=' . (is_string($value) ? '"' . $value . '"' : $value);
$fields[] = $property.'='.(is_string($value) ? '"'.$value.'"' : $value);
}
}
return '@' . str_replace('OpenApi\\Annotations\\', 'OA\\', get_class($this)) . '(' . implode(',', $fields) . ')';
return '@'.str_replace('OpenApi\\Annotations\\', 'OA\\', get_class($this)).'('.implode(',', $fields).')';
}
/**
@ -590,7 +590,7 @@ abstract class AbstractAnnotation implements JsonSerializable
case 'scheme':
return in_array($value, ['http', 'https', 'ws', 'wss'], true);
default:
throw new Exception('Invalid type "' . $type . '"');
throw new Exception('Invalid type "'.$type.'"');
}
}

View File

@ -54,7 +54,7 @@ class Items extends Schema
// A limited subset of JSON-Schema's items object.
$allowedTypes = ['string', 'number', 'integer', 'boolean', 'array'];
if (in_array($this->type, $allowedTypes) === false) {
Logger::notice('@OA\Items()->type="' . $this->type . '" not allowed inside a ' . $parent->_identity([]) . ' must be "' . implode('", "', $allowedTypes) . '" in ' . $this->_context);
Logger::notice('@OA\Items()->type="'.$this->type.'" not allowed inside a '.$parent->_identity([]).' must be "'.implode('", "', $allowedTypes).'" in '.$this->_context);
$valid = false;
}
}

View File

@ -128,7 +128,7 @@ class OpenApi extends AbstractAnnotation
public function validate($parents = null, $skip = null, $ref = null)
{
if ($parents !== null || $skip !== null || $ref !== null) {
Logger::notice('Nested validation for ' . $this->identity() . ' not allowed');
Logger::notice('Nested validation for '.$this->identity().' not allowed');
return false;
}
@ -154,7 +154,7 @@ class OpenApi extends AbstractAnnotation
$content = $this->toYaml();
}
if (file_put_contents($filename, $content) === false) {
throw new Exception('Failed to saveAs("' . $filename . '", "' . $format . '")');
throw new Exception('Failed to saveAs("'.$filename.'", "'.$format.'")');
}
}
@ -169,7 +169,7 @@ class OpenApi extends AbstractAnnotation
{
if (substr($ref, 0, 2) !== '#/') {
// @todo Add support for external (http) refs?
throw new Exception('Unsupported $ref "' . $ref . '", it should start with "#/"');
throw new Exception('Unsupported $ref "'.$ref.'", it should start with "#/"');
}
return $this->resolveRef($ref, '#/', $this, []);
@ -191,11 +191,11 @@ class OpenApi extends AbstractAnnotation
$subpath = $slash === false ? $path : substr($path, 0, $slash);
$property = self::unescapeRef($subpath);
$unresolved = $slash === false ? $resolved . $subpath : $resolved . $subpath . '/';
$unresolved = $slash === false ? $resolved.$subpath : $resolved.$subpath.'/';
if (is_object($container)) {
if (property_exists($container, $property) === false) {
throw new Exception('$ref "' . $ref . '" not found');
throw new Exception('$ref "'.$ref.'" not found');
}
if ($slash === false) {
return $container->$property;
@ -222,7 +222,7 @@ class OpenApi extends AbstractAnnotation
}
}
}
throw new Exception('$ref "' . $unresolved . '" not found');
throw new Exception('$ref "'.$unresolved.'" not found');
}
/**

View File

@ -185,7 +185,7 @@ abstract class Operation extends AbstractAnnotation
if ($this->responses !== UNDEFINED) {
foreach ($this->responses as $response) {
if ($response->response !== UNDEFINED && $response->response !== 'default' && preg_match('/^([12345]{1}[0-9]{2})|([12345]{1}XX)$/', (string) $response->response) === 0) {
Logger::notice('Invalid value "' . $response->response . '" for ' . $response->_identity([]) . '->response, expecting "default", a HTTP Status Code or HTTP Status Code range definition in ' . $response->_context);
Logger::notice('Invalid value "'.$response->response.'" for '.$response->_identity([]).'->response, expecting "default", a HTTP Status Code or HTTP Status Code range definition in '.$response->_context);
}
}
}

View File

@ -243,7 +243,7 @@ class Parameter extends AbstractAnnotation
if ($this->ref === UNDEFINED) {
if ($this->in === 'body') {
if ($this->schema === UNDEFINED) {
Logger::notice('Field "schema" is required when ' . $this->identity() . ' is in "' . $this->in . '" in ' . $this->_context);
Logger::notice('Field "schema" is required when '.$this->identity().' is in "'.$this->in.'" in '.$this->_context);
$valid = false;
}
} else {

View File

@ -342,9 +342,9 @@ class Schema extends AbstractAnnotation
'minItems' => 'integer',
'uniqueItems' => 'boolean',
'multipleOf' => 'integer',
'allOf' => '[' . Schema::class . ']',
'oneOf' => '[' . Schema::class . ']',
'anyOf' => '[' . Schema::class . ']',
'allOf' => '['.Schema::class.']',
'oneOf' => '['.Schema::class.']',
'anyOf' => '['.Schema::class.']',
];
/**
@ -372,7 +372,7 @@ class Schema extends AbstractAnnotation
public function validate($parents = [], $skip = [], $ref = '')
{
if ($this->type === 'array' && $this->items === UNDEFINED) {
Logger::notice('@OA\Items() is required when ' . $this->identity() . ' has type "array" in ' . $this->_context);
Logger::notice('@OA\Items() is required when '.$this->identity().' has type "array" in '.$this->_context);
return false;
}

View File

@ -123,9 +123,9 @@ class Context
if ($this->class && ($this->method || $this->property)) {
$location .= $this->fullyQualifiedName($this->class);
if ($this->method) {
$location .= ($this->static ? '::' : '->') . $this->method . '()';
$location .= ($this->static ? '::' : '->').$this->method.'()';
} elseif ($this->property) {
$location .= ($this->static ? '::$' : '->') . $this->property;
$location .= ($this->static ? '::$' : '->').$this->property;
}
}
if ($this->filename) {
@ -138,9 +138,9 @@ class Context
if ($location !== '') {
$location .= ' on';
}
$location .= ' line ' . $this->line;
$location .= ' line '.$this->line;
if ($this->character) {
$location .= ':' . $this->character;
$location .= ':'.$this->character;
}
}
@ -185,7 +185,7 @@ class Context
$lines = preg_split('/(\n|\r\n)/', $content);
$summary = '';
foreach ($lines as $line) {
$summary .= $line . "\n";
$summary .= $line."\n";
if ($line === '' || substr($line, -1) === '.') {
return trim($summary);
}
@ -237,7 +237,7 @@ class Context
}
if ($append) {
$i = count($lines) - 1;
$lines[$i] = substr($lines[$i], 0, -1) . $line;
$lines[$i] = substr($lines[$i], 0, -1).$line;
} else {
$lines[] = $line;
}
@ -302,7 +302,7 @@ class Context
}
if ($this->namespace) {
$namespace = str_replace('\\\\', '\\', '\\' . $this->namespace . '\\');
$namespace = str_replace('\\\\', '\\', '\\'.$this->namespace.'\\');
} else {
// global namespace
$namespace = '\\';
@ -310,7 +310,7 @@ class Context
$thisSource = $this->class ?? $this->interface ?? $this->trait;
if ($thisSource && strcasecmp($source, $thisSource) === 0) {
return $namespace . $thisSource;
return $namespace.$thisSource;
}
$pos = strpos($source, '\\');
if ($pos !== false) {
@ -324,7 +324,7 @@ class Context
$alias .= '\\';
if (strcasecmp(substr($source, 0, strlen($alias)), $alias) === 0) {
// Aliased namespace (use \Long\Namespace as Foo)
return '\\' . $aliasedNamespace . substr($source, strlen($alias) - 1);
return '\\'.$aliasedNamespace.substr($source, strlen($alias) - 1);
}
}
}
@ -332,11 +332,11 @@ class Context
// Unqualified name (Foo)
foreach ($this->uses as $alias => $aliasedNamespace) {
if (strcasecmp($alias, $source) === 0) {
return '\\' . $aliasedNamespace;
return '\\'.$aliasedNamespace;
}
}
}
return $namespace . $source;
return $namespace.$source;
}
}

View File

@ -47,7 +47,7 @@ class AugmentProperties
foreach ($analysis->openapi->components->schemas as $schema) {
if ($schema->schema !== UNDEFINED) {
$refs[strtolower($schema->_context->fullyQualifiedName($schema->_context->class))]
= Components::SCHEMA_REF . $schema->schema;
= Components::SCHEMA_REF.$schema->schema;
}
}
}

View File

@ -24,7 +24,7 @@ class BuildPaths
if ($analysis->openapi->paths !== UNDEFINED) {
foreach ($analysis->openapi->paths as $annotation) {
if (empty($annotation->path)) {
Logger::notice($annotation->identity() . ' is missing required property "path" in ' . $annotation->_context);
Logger::notice($annotation->identity().' is missing required property "path" in '.$annotation->_context);
} elseif (isset($paths[$annotation->path])) {
$paths[$annotation->path]->mergeProperties($annotation);
$analysis->annotations->detach($annotation);
@ -48,7 +48,7 @@ class BuildPaths
$analysis->annotations->attach($paths[$operation->path]);
}
if ($paths[$operation->path]->merge([$operation])) {
Logger::notice('Unable to merge ' . $operation->identity() . ' in ' . $operation->_context);
Logger::notice('Unable to merge '.$operation->identity().' in '.$operation->_context);
}
}
}

View File

@ -25,7 +25,7 @@ class InheritInterfaces
}
$schema->allOf[] = new Schema([
'_context' => $interface['context']->_context,
'ref' => Components::SCHEMA_REF . $interface['interface'],
'ref' => Components::SCHEMA_REF.$interface['interface'],
]);
}
}

View File

@ -96,7 +96,7 @@ class InheritProperties
if ($schema->schema === UNDEFINED && $schema->properties !== UNDEFINED) {
// move properties from allOf back up into schema
$currentSchema->properties = $schema->properties;
} elseif ($schema->ref !== UNDEFINED && $schema->ref != Components::SCHEMA_REF . $parentSchema->schema) {
} elseif ($schema->ref !== UNDEFINED && $schema->ref != Components::SCHEMA_REF.$parentSchema->schema) {
// keep other schemas
$childSchema->allOf[] = $schema;
}
@ -106,7 +106,7 @@ class InheritProperties
$childSchema->allOf[] = new Schema([
'_context' => $parentSchema->_context,
'ref' => Components::SCHEMA_REF . $parentSchema->schema,
'ref' => Components::SCHEMA_REF.$parentSchema->schema,
]);
if ($currentSchema->properties !== UNDEFINED) {
$childSchema->allOf[] = $currentSchema;

View File

@ -26,7 +26,7 @@ class InheritTraits
}
$schema->allOf[] = new Schema([
'_context' => $trait['context']->_context,
'ref' => Components::SCHEMA_REF . $trait['trait'],
'ref' => Components::SCHEMA_REF.$trait['trait'],
]);
}
}

View File

@ -27,9 +27,9 @@ class MergeJsonContent
$parent = $jsonContent->_context->nested;
if (!($parent instanceof Response) && !($parent instanceof RequestBody) && !($parent instanceof Parameter)) {
if ($parent) {
Logger::notice('Unexpected ' . $jsonContent->identity() . ' in ' . $parent->identity() . ' in ' . $parent->_context);
Logger::notice('Unexpected '.$jsonContent->identity().' in '.$parent->identity().' in '.$parent->_context);
} else {
Logger::notice('Unexpected ' . $jsonContent->identity() . ' must be nested');
Logger::notice('Unexpected '.$jsonContent->identity().' must be nested');
}
continue;
}

View File

@ -27,9 +27,9 @@ class MergeXmlContent
$parent = $xmlContent->_context->nested;
if (!($parent instanceof Response) && !($parent instanceof RequestBody) && !($parent instanceof Parameter)) {
if ($parent) {
Logger::notice('Unexpected ' . $xmlContent->identity() . ' in ' . $parent->identity() . ' in ' . $parent->_context);
Logger::notice('Unexpected '.$xmlContent->identity().' in '.$parent->identity().' in '.$parent->_context);
} else {
Logger::notice('Unexpected ' . $xmlContent->identity() . ' must be nested');
Logger::notice('Unexpected '.$xmlContent->identity().' must be nested');
}
continue;
}

View File

@ -27,9 +27,9 @@ class OperationId
$source = $context->class ?? $context->interface ?? $context->trait;
if ($source) {
if ($context->namespace) {
$operation->operationId = $context->namespace . '\\' . $source . '::' . $context->method;
$operation->operationId = $context->namespace.'\\'.$source.'::'.$context->method;
} else {
$operation->operationId = $source . '::' . $context->method;
$operation->operationId = $source.'::'.$context->method;
}
} else {
$operation->operationId = $context->method;

View File

@ -83,7 +83,7 @@ class Serializer
public function deserialize($jsonString, $className)
{
if (!$this->isValidAnnotationClass($className)) {
throw new \Exception($className . ' is not defined in OpenApi PHP Annotations');
throw new \Exception($className.' is not defined in OpenApi PHP Annotations');
}
return $this->doDeserialize(json_decode($jsonString), $className);
@ -102,7 +102,7 @@ class Serializer
public function deserializeFile($filename, $className = 'OpenApi\Annotations\OpenApi')
{
if (!$this->isValidAnnotationClass($className)) {
throw new \Exception($className . ' is not defined in OpenApi PHP Annotations');
throw new \Exception($className.' is not defined in OpenApi PHP Annotations');
}
return $this->doDeserialize(json_decode(file_get_contents($filename)), $className);

View File

@ -432,7 +432,7 @@ class StaticAnalyser
if ($pos) {
$line = $context->line ? $context->line + $token[2] : $token[2];
$commentContext = new Context(['line' => $line], $context);
Logger::notice('Annotations are only parsed inside `/**` DocBlocks, skipping ' . $commentContext);
Logger::notice('Annotations are only parsed inside `/**` DocBlocks, skipping '.$commentContext);
}
continue;
}

View File

@ -101,7 +101,7 @@ class Util
}
}
} else {
throw new InvalidArgumentException('Unexpected $directory value:' . gettype($directory));
throw new InvalidArgumentException('Unexpected $directory value:'.gettype($directory));
}
if ($exclude !== null) {
if (is_string($exclude)) {
@ -111,7 +111,7 @@ class Util
$finder->notPath(Util::getRelativePath($path, $directory));
}
} else {
throw new InvalidArgumentException('Unexpected $exclude value:' . gettype($exclude));
throw new InvalidArgumentException('Unexpected $exclude value:'.gettype($exclude));
}
}

View File

@ -24,7 +24,7 @@ class AnnotationPropertiesDefinedTest extends OpenApiTestCase
continue;
}
if ($value === null) {
$this->fail('Property ' . basename($annotation) . '->' . $property . ' should be DEFINED');
$this->fail('Property '.basename($annotation).'->'.$property.' should be DEFINED');
}
}
}

View File

@ -28,14 +28,14 @@ class ResponseTest extends OpenApiTestCase
protected function validateMisspelledAnnotation(string $response = '')
{
$annotations = $this->parseComment(
'@OA\Get(@OA\Response(response="' . $response . '", description="description"))'
'@OA\Get(@OA\Response(response="'.$response.'", description="description"))'
);
/*
* @see Annotations/Operation.php:187
*/
$this->assertOpenApiLogEntryContains(
'Invalid value "' . $response . '" for @OA\Response()->response, expecting "default"'
. ', a HTTP Status Code or HTTP '
'Invalid value "'.$response.'" for @OA\Response()->response, expecting "default"'
.', a HTTP Status Code or HTTP '
);
$annotations[0]->validate();
}

View File

@ -29,7 +29,7 @@ class ValidateRelationsTest extends OpenApiTestCase
}
}
if ($found === false) {
$this->fail($class . ' not found in ' . $parent . "::\$_nested. Found:\n " . implode("\n ", array_keys($parent::$_nested)));
$this->fail($class.' not found in '.$parent."::\$_nested. Found:\n ".implode("\n ", array_keys($parent::$_nested)));
}
}
}
@ -50,7 +50,7 @@ class ValidateRelationsTest extends OpenApiTestCase
}
}
if ($found === false) {
$this->fail($class . ' not found in ' . $nested . "::\$parent. Found:\n " . implode("\n ", $nested::$_parents));
$this->fail($class.' not found in '.$nested."::\$parent. Found:\n ".implode("\n ", $nested::$_parents));
}
}
}

View File

@ -15,22 +15,22 @@ class CommandlineInterfaceTest extends OpenApiTestCase
public function testStdout()
{
$path = __DIR__ . '/../Examples/swagger-spec/petstore-simple';
exec(__DIR__ . '/../bin/openapi --format yaml ' . escapeshellarg($path) . ' 2> /dev/null', $output, $retval);
$path = __DIR__.'/../Examples/swagger-spec/petstore-simple';
exec(__DIR__.'/../bin/openapi --format yaml '.escapeshellarg($path).' 2> /dev/null', $output, $retval);
$this->assertSame(0, $retval);
$yaml = implode("\n", $output);
$this->assertSpecEquals(file_get_contents($path . '/petstore-simple.yaml'), $yaml);
$this->assertSpecEquals(file_get_contents($path.'/petstore-simple.yaml'), $yaml);
}
public function testOutputTofile()
{
$path = __DIR__ . '/../Examples/swagger-spec/petstore-simple';
$filename = sys_get_temp_dir() . '/swagger-php-clitest.yaml';
exec(__DIR__ . '/../bin/openapi --format yaml -o ' . escapeshellarg($filename) . ' ' . escapeshellarg($path) . ' 2> /dev/null', $output, $retval);
$path = __DIR__.'/../Examples/swagger-spec/petstore-simple';
$filename = sys_get_temp_dir().'/swagger-php-clitest.yaml';
exec(__DIR__.'/../bin/openapi --format yaml -o '.escapeshellarg($filename).' '.escapeshellarg($path).' 2> /dev/null', $output, $retval);
$this->assertSame(0, $retval);
$this->assertCount(0, $output, 'No output to stdout');
$yaml = file_get_contents($filename);
unlink($filename);
$this->assertSpecEquals(file_get_contents($path . '/petstore-simple.yaml'), $yaml);
$this->assertSpecEquals(file_get_contents($path.'/petstore-simple.yaml'), $yaml);
}
}

View File

@ -18,13 +18,13 @@ class ConstantsTest extends OpenApiTestCase
public function testConstant()
{
self::$counter++;
$const = 'OPENAPI_TEST_' . self::$counter;
$const = 'OPENAPI_TEST_'.self::$counter;
$this->assertFalse(defined($const));
$this->assertOpenApiLogEntryContains("[Semantical Error] Couldn't find constant " . $const);
$this->parseComment('@OA\Contact(email=' . $const . ')');
$this->assertOpenApiLogEntryContains("[Semantical Error] Couldn't find constant ".$const);
$this->parseComment('@OA\Contact(email='.$const.')');
define($const, 'me@domain.org');
$annotations = $this->parseComment('@OA\Contact(email=' . $const . ')');
$annotations = $this->parseComment('@OA\Contact(email='.$const.')');
$this->assertSame('me@domain.org', $annotations[0]->email);
}
@ -57,7 +57,7 @@ class ConstantsTest extends OpenApiTestCase
$backup = Analyser::$whitelist;
Analyser::$whitelist = false;
$analyser = new StaticAnalyser();
$analysis = $analyser->fromFile(__DIR__ . '/Fixtures/Customer.php');
$analysis = $analyser->fromFile(__DIR__.'/Fixtures/Customer.php');
// @todo Only tests that $whitelist=false doesn't trigger errors,
// No constants are used, because by default only class constants in the whitelisted namespace are allowed and no class in OpenApi\Annotation namespace has a constant.

View File

@ -26,7 +26,7 @@ class ContextTest extends OpenApiTestCase
public function testFullyQualifiedName()
{
$this->assertOpenApiLogEntryContains('Required @OA\PathItem() not found');
$openapi = \OpenApi\scan(__DIR__ . '/Fixtures/Customer.php');
$openapi = \OpenApi\scan(__DIR__.'/Fixtures/Customer.php');
$context = $openapi->components->schemas[0]->_context;
// resolve with namespace
$this->assertSame('\FullyQualified', $context->fullyQualifiedName('\FullyQualified'));

View File

@ -66,8 +66,8 @@ class ExamplesTest extends OpenApiTestCase
$options['processors'] = $processors;
}
$path = __DIR__ . '/../Examples/' . $example;
$path = __DIR__.'/../Examples/'.$example;
$openapi = \OpenApi\scan($path, $options);
$this->assertSpecEquals(file_get_contents($path . '/' . $spec), $openapi);
$this->assertSpecEquals(file_get_contents($path.'/'.$spec), $openapi);
}
}

View File

@ -50,9 +50,9 @@ class OpenApiTestCase extends TestCase
E_USER_WARNING => 'warning',
];
if (isset($map[$type])) {
$this->fail('Unexpected \OpenApi\Logger::' . $map[$type] . '("' . $entry . '")');
$this->fail('Unexpected \OpenApi\Logger::'.$map[$type].'("'.$entry.'")');
} else {
$this->fail('Unexpected \OpenApi\Logger->getInstance()->log("' . $entry . '",' . $type . ')');
$this->fail('Unexpected \OpenApi\Logger->getInstance()->log("'.$entry.'",'.$type.')');
}
}
};
@ -61,7 +61,7 @@ class OpenApiTestCase extends TestCase
protected function tearDown(): void
{
$this->assertCount($this->countExceptions, $this->expectedLogMessages, count($this->expectedLogMessages) . ' OpenApi\Logger messages were not triggered');
$this->assertCount($this->countExceptions, $this->expectedLogMessages, count($this->expectedLogMessages).' OpenApi\Logger messages were not triggered');
Logger::getInstance()->log = $this->originalLogger;
parent::tearDown();
}
@ -95,7 +95,7 @@ class OpenApiTestCase extends TestCase
try {
$in = Yaml::parse($in);
} catch (ParseException $e) {
$this->fail('Invalid YAML: ' . $e->getMessage() . PHP_EOL . $in);
$this->fail('Invalid YAML: '.$e->getMessage().PHP_EOL.$in);
}
}
@ -131,7 +131,7 @@ class OpenApiTestCase extends TestCase
$analyser = new Analyser();
$context = Context::detect(1);
return $analyser->fromComment("<?php\n/**\n * " . implode("\n * ", explode("\n", $comment)) . "\n*/", $context);
return $analyser->fromComment("<?php\n/**\n * ".implode("\n * ", explode("\n", $comment))."\n*/", $context);
}
/**
@ -162,7 +162,7 @@ class OpenApiTestCase extends TestCase
public function fixtures($files): array
{
return array_map(function ($file) {
return __DIR__ . '/Fixtures/' . $file;
return __DIR__.'/Fixtures/'.$file;
}, (array) $files);
}
@ -180,7 +180,7 @@ class OpenApiTestCase extends TestCase
public function analysisFromCode(string $code, ?Context $context = null)
{
return (new StaticAnalyser())->fromCode("<?php\n" . $code, $context ?: new Context());
return (new StaticAnalyser())->fromCode("<?php\n".$code, $context ?: new Context());
}
/**
@ -191,7 +191,7 @@ class OpenApiTestCase extends TestCase
public function allAnnotationClasses()
{
$classes = [];
$dir = new DirectoryIterator(__DIR__ . '/../src/Annotations');
$dir = new DirectoryIterator(__DIR__.'/../src/Annotations');
foreach ($dir as $entry) {
if (!$entry->isFile() || $entry->getExtension() != 'php') {
continue;
@ -200,7 +200,7 @@ class OpenApiTestCase extends TestCase
if (in_array($class, ['AbstractAnnotation','Operation'])) {
continue;
}
$classes[] = ['OpenApi\\Annotations\\' . $class];
$classes[] = ['OpenApi\\Annotations\\'.$class];
}
return $classes;

View File

@ -173,7 +173,7 @@ class InheritPropertiesTest extends OpenApiTestCase
$this->assertCount(2, $extendedSchema->allOf);
$this->assertEquals($extendedSchema->allOf[0]->ref, Components::SCHEMA_REF . 'Base');
$this->assertEquals($extendedSchema->allOf[0]->ref, Components::SCHEMA_REF.'Base');
$this->assertEquals($extendedSchema->allOf[1]->properties[0]->property, 'extendedProperty');
}
@ -209,7 +209,7 @@ class InheritPropertiesTest extends OpenApiTestCase
$this->assertSame(UNDEFINED, $extendedSchema->properties);
$this->assertCount(2, $extendedSchema->allOf);
$this->assertEquals($extendedSchema->allOf[0]->ref, Components::SCHEMA_REF . 'Base');
$this->assertEquals($extendedSchema->allOf[0]->ref, Components::SCHEMA_REF.'Base');
$this->assertEquals($extendedSchema->allOf[1]->properties[0]->property, 'nested');
$this->assertEquals($extendedSchema->allOf[1]->properties[1]->property, 'extendedProperty');

View File

@ -149,7 +149,7 @@ JSON;
public function testPetstoreExample()
{
$serializer = new Serializer();
$spec = __DIR__ . '/../Examples/petstore.swagger.io/petstore.swagger.io.json';
$spec = __DIR__.'/../Examples/petstore.swagger.io/petstore.swagger.io.json';
$openapi = $serializer->deserializeFile($spec);
$this->assertInstanceOf(OpenApi::class, $openapi);
$this->assertJsonStringEqualsJsonString(file_get_contents($spec), $openapi->toJson());

View File

@ -124,13 +124,13 @@ class StaticAnalyserTest extends OpenApiTestCase
$backup = Analyser::$whitelist;
Analyser::$whitelist = ['OpenApi\Annotations\\'];
$analyser = new StaticAnalyser();
$defaultAnalysis = $analyser->fromFile(__DIR__ . '/Fixtures/ThirdPartyAnnotations.php');
$defaultAnalysis = $analyser->fromFile(__DIR__.'/Fixtures/ThirdPartyAnnotations.php');
$this->assertCount(3, $defaultAnalysis->annotations, 'Only read the @OA annotations, skip the others.');
// Allow the analyser to parse 3rd party annotations, which might
// contain useful info that could be extracted with a custom processor
Analyser::$whitelist[] = 'AnotherNamespace\Annotations';
$openapi = \OpenApi\scan(__DIR__ . '/Fixtures/ThirdPartyAnnotations.php');
$openapi = \OpenApi\scan(__DIR__.'/Fixtures/ThirdPartyAnnotations.php');
$this->assertSame('api/3rd-party', $openapi->paths[0]->path);
$this->assertCount(4, $openapi->_unmerged);
Analyser::$whitelist = $backup;

View File

@ -10,7 +10,7 @@ class UtilTest extends OpenApiTestCase
{
public function testExclude()
{
$openapi = \OpenApi\scan(__DIR__ . '/Fixtures', [
$openapi = \OpenApi\scan(__DIR__.'/Fixtures', [
'exclude' => [
'Customer.php',
'CustomerInterface.php',