OpenAPITools/openapi-generator

[REQ][php] declareStrictTypes option for all PHP generators

Open

#12,771 创建于 2022年7月5日

在 GitHub 查看
 (2 评论) (4 反应) (0 负责人)Java (7,516 fork)batch import
Client: PHPEnhancement: FeatureGood First IssueServer: PHP

仓库指标

Star
 (26,243 star)
PR 合并指标
 (平均合并 9天 1小时) (30 天内合并 123 个 PR)

描述

Is your feature request related to a problem? Please describe.

Usually I totally against codegen options which modifies one line of code, but this one looks really handy.

Describe the solution you'd like

Add declareStrictTypes switch option to AbstractPhpCodegen class, then:

openapi-generator-cli generate -g php --additional-properties=declareStrictTypes=true \
    -o out -i petstore.yaml

then in all mustache files:

<?php 

{{#declareStrictTypes}}declare(strict_types=1);{{/declareStrictTypes}}

We also need to decide whether this switch option should be on or off by default. I think it should be on, but it can cause breaking changes.

Describe alternatives you've considered

Close this issue as not necessary feature 😆

Additional context

cc @jebentier @dkarlovi @mandrean @jfastnacht @renepardon

贡献者指南