Merge cc38d3bfc8c006ac5d68c046cd769ee483b3383f into d6c46342693205f0dae441b45742d9c85d41cf33

This commit is contained in:
Sumit Chauhan 2025-05-09 11:28:15 +02:00 committed by GitHub
commit f22d0e9466
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 22 additions and 0 deletions

View File

@ -69,6 +69,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
protected String interfaceNamePrefix = "", interfaceNameSuffix = "Interface"; protected String interfaceNamePrefix = "", interfaceNameSuffix = "Interface";
protected String abstractNamePrefix = "Abstract", abstractNameSuffix = ""; protected String abstractNamePrefix = "Abstract", abstractNameSuffix = "";
protected String traitNamePrefix = "", traitNameSuffix = "Trait"; protected String traitNamePrefix = "", traitNameSuffix = "Trait";
protected boolean declareStrictTypes = false;
private Map<String, String> schemaKeyToModelNameCache = new HashMap<>(); private Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
@ -285,6 +286,11 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
// all PHP codegens requires Composer, it means that we need to exclude from SVN at least vendor folder // all PHP codegens requires Composer, it means that we need to exclude from SVN at least vendor folder
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore")); supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
// Add declareStrictTypes property to the additionalProperties
if (additionalProperties.containsKey("declareStrictTypes")) {
this.declareStrictTypes = Boolean.parseBoolean(additionalProperties.get("declareStrictTypes").toString());
}
additionalProperties.put("declareStrictTypes", declareStrictTypes);
} }
public String toSrcPath(final String packageName, final String basePath) { public String toSrcPath(final String packageName, final String basePath) {
@ -567,6 +573,14 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
public String toAbstractName(final String name) { public String toAbstractName(final String name) {
return camelize(abstractNamePrefix + name + abstractNameSuffix); return camelize(abstractNamePrefix + name + abstractNameSuffix);
} }
@Override
public String getHelp() {
return "Generates a PHP client library." + "\n" +
"Options:\n" +
" - declareStrictTypes: boolean, set to true to add declare(strict_types=1); in generated PHP files.";
}
/** /**
* Output the proper trait name (capitalized). * Output the proper trait name (capitalized).

View File

@ -1,4 +1,6 @@
<?php <?php
{{#declareStrictTypes}}declare(strict_types=1);{{/declareStrictTypes}}
/** /**
* ApiException * ApiException
* PHP version 8.1 * PHP version 8.1

View File

@ -1,4 +1,5 @@
<?php <?php
{{#declareStrictTypes}}declare(strict_types=1);{{/declareStrictTypes}}
/** /**
* Configuration * Configuration
* PHP version 8.1 * PHP version 8.1

View File

@ -1,4 +1,6 @@
<?php <?php
{{#declareStrictTypes}}declare(strict_types=1);{{/declareStrictTypes}}
/** /**
* FormDataProcessor * FormDataProcessor
* PHP version 7.4 * PHP version 7.4

View File

@ -1,4 +1,5 @@
<?php <?php
{{#declareStrictTypes}}declare(strict_types=1);{{/declareStrictTypes}}
/** /**
* HeaderSelector * HeaderSelector
* PHP version 8.1 * PHP version 8.1

View File

@ -1,4 +1,5 @@
<?php <?php
{{#declareStrictTypes}}declare(strict_types=1);{{/declareStrictTypes}}
/** /**
* ModelInterface * ModelInterface
* *

View File

@ -1,4 +1,5 @@
<?php <?php
{{#declareStrictTypes}}declare(strict_types=1);{{/declareStrictTypes}}
/** /**
* ObjectSerializer * ObjectSerializer
* *