Skip to content

Commit dd1df7a

Browse files
committed
modifying PHP templates and rules to meet PSR2 standards
some rules around whitespace have been disabled, since we don't have a great deal of control over whitespace that is emitted when template values are empty.
1 parent 37fc478 commit dd1df7a

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

modules/swagger-codegen/src/main/resources/php/.php_cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@ return PhpCsFixer\Config::create()
88
'phpdoc_order' => true,
99
'array_syntax' => [ 'syntax' => 'short' ],
1010
'strict_comparison' => true,
11-
'strict_param' => true
11+
'strict_param' => true,
12+
'no_trailing_whitespace' => false,
13+
'no_trailing_whitespace_in_comment' => false,
14+
'braces' => false,
15+
'single_blank_line_at_eof' => false,
16+
'blank_line_after_namespace' => false,
1217
])
1318
->setFinder(
1419
PhpCsFixer\Finder::create()
20+
->exclude('test')
21+
->exclude('tests')
1522
->in(__DIR__)
1623
);

modules/swagger-codegen/src/main/resources/php/HeaderSelector.mustache

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,3 @@ class HeaderSelector
9797
}
9898
}
9999
}
100-

modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ObjectSerializer
5858
if ($value !== null
5959
&& !in_array($swaggerType, [{{&primitives}}], true)
6060
&& method_exists($swaggerType, 'getAllowableEnumValues')
61-
&& !in_array($value, $swaggerType::getAllowableEnumValues())) {
61+
&& !in_array($value, $swaggerType::getAllowableEnumValues(), true)) {
6262
$imploded = implode("', '", $swaggerType::getAllowableEnumValues());
6363
throw new \InvalidArgumentException("Invalid value for enum '$swaggerType', must be one of: '$imploded'");
6464
}
@@ -274,7 +274,7 @@ class ObjectSerializer
274274

275275
return new \SplFileObject($filename, 'r');
276276
} elseif (method_exists($class, 'getAllowableEnumValues')) {
277-
if (!in_array($data, $class::getAllowableEnumValues())) {
277+
if (!in_array($data, $class::getAllowableEnumValues(), true)) {
278278
$imploded = implode("', '", $class::getAllowableEnumValues());
279279
throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'");
280280
}

modules/swagger-codegen/src/main/resources/php/model_generic.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa
166166
{{#discriminator}}
167167

168168
// Initialize discriminator property with the model name.
169-
$discriminator = array_search('{{discriminator}}', self::$attributeMap);
169+
$discriminator = array_search('{{discriminator}}', self::$attributeMap, true);
170170
$this->container[$discriminator] = static::$swaggerModelName;
171171
{{/discriminator}}
172172
}

0 commit comments

Comments
 (0)