[Slim] Add PHP CodeSniffer config template (#1764)

* [Slim] Add PHP_CodeSniffer config template

* [Slim] Update doc

* [Slim] Add local configs to gitignore

PHPUnit and PHP_CodeSniffer provides the same developing pattern when
user overrides global config with local one. In local config he can
set environment variables. Official doc recommends to not commit local
config files.

* [Slim] Remove phpcsStandard CLI option

Now user have full freedom to override config file. This option is not
used and not necessary anymore.

* [Slim] Refresh samples
This commit is contained in:
Yuriy Belenko
2018-12-29 11:58:15 +05:00
committed by Akihito Nakano
parent 1db105b6f9
commit 5400a7e445
16 changed files with 250 additions and 67 deletions

View File

@@ -35,12 +35,10 @@ import java.util.Map;
public class PhpSlimServerCodegen extends AbstractPhpCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(PhpSlimServerCodegen.class);
public static final String PHPCS_STANDARD = "phpcsStandard";
public static final String USER_CLASSNAME_KEY = "userClassname";
protected String groupId = "org.openapitools";
protected String artifactId = "openapi-server";
protected String phpcsStandard = "PSR12";
public PhpSlimServerCodegen() {
super();
@@ -74,9 +72,6 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
break;
}
}
cliOptions.add(new CliOption(PHPCS_STANDARD, "PHP CodeSniffer <standard> option. Accepts name or path of the coding standard to use.")
.defaultValue("PSR12"));
}
@Override
@@ -116,18 +111,13 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey(PHPCS_STANDARD)) {
this.setPhpcsStandard((String) additionalProperties.get(PHPCS_STANDARD));
} else {
additionalProperties.put(PHPCS_STANDARD, phpcsStandard);
}
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json"));
supportingFiles.add(new SupportingFile("index.mustache", "", "index.php"));
supportingFiles.add(new SupportingFile(".htaccess", "", ".htaccess"));
supportingFiles.add(new SupportingFile("SlimRouter.mustache", toSrcPath(invokerPackage, srcBasePath), "SlimRouter.php"));
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist"));
supportingFiles.add(new SupportingFile("phpcs.xml.mustache", "", "phpcs.xml.dist"));
}
@Override
@@ -161,15 +151,6 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
return objs;
}
/**
* Sets PHP CodeSniffer &lt;standard&gt; option. Accepts name or path of the coding standard to use.
*
* @param phpcsStandard standard option value
*/
public void setPhpcsStandard(String phpcsStandard) {
this.phpcsStandard = phpcsStandard;
}
@Override
public String toApiName(String name) {
if (name.length() == 0) {