Skip to content

Commit

Permalink
fix(php): add list to PHP reserved keywords; prevent escaping PHP m…
Browse files Browse the repository at this point in the history
…ethod names. (#5233)

* Implement PHP SDK short-term solution.

* Update versions for both cli and php generator.

* feat(typescript): introduce API Promise so that we can return raw response headers (#5218)

* feat(typescript): RequestOptions takes in arbitrary headers (#5228)

* feat(go): Simplify generated code (#5213)

* feat(csharp): Make JsonSerializerOptions more configurable  (#5227)

Provide partial method ConfigureJsonSerializerOptions to let SDK maintainers customize JsonSerializerOptions

* chore: update changelog

* Define ENDPOINT_OVERRIDE_KEYWORDS in constants.ts

* Update naming.

---------

Co-authored-by: Deep Singhvi <[email protected]>
Co-authored-by: Alex McKinney <[email protected]>
Co-authored-by: Niels Swimberghe <[email protected]>
Co-authored-by: eyw520 <[email protected]>
  • Loading branch information
5 people authored Nov 20, 2024
1 parent c81bb89 commit 1eccbb0
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 60 deletions.
4 changes: 4 additions & 0 deletions fern/pages/changelogs/cli/2024-11-20.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 0.45.0-rc49
**`(fix):`** Add 'list' to reserved keywords for use in PHP generator.


3 changes: 3 additions & 0 deletions fern/pages/changelogs/php-sdk/2024-11-20.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.2.1
**`(fix):`** Override escaped method names in the generated client.

7 changes: 6 additions & 1 deletion generators/php/sdk/src/SdkGeneratorContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { camelCase, upperFirst } from "lodash-es";
import { RawClient } from "./core/RawClient";
import { GuzzleClient } from "./external/GuzzleClient";
import { ErrorId, ErrorDeclaration } from "@fern-fern/ir-sdk/api";
import { EXCEPTIONS_DIRECTORY, TYPES_DIRECTORY, REQUESTS_DIRECTORY } from "./constants";
import { EXCEPTIONS_DIRECTORY, TYPES_DIRECTORY, REQUESTS_DIRECTORY, RESERVED_METHOD_NAMES } from "./constants";
import { EndpointGenerator } from "./endpoint/EndpointGenerator";

export class SdkGeneratorContext extends AbstractPhpGeneratorContext<SdkCustomConfigSchema> {
Expand Down Expand Up @@ -74,6 +74,11 @@ export class SdkGeneratorContext extends AbstractPhpGeneratorContext<SdkCustomCo
}

public getEndpointMethodName(endpoint: HttpEndpoint): string {
// TODO: Propogate reserved keywords through IR via CasingsGenerator.
const unsafeName = endpoint.name.camelCase.unsafeName;
if (RESERVED_METHOD_NAMES.includes(unsafeName)) {
return unsafeName;
}
return endpoint.name.camelCase.safeName;
}

Expand Down
1 change: 1 addition & 0 deletions generators/php/sdk/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const RESERVED_METHOD_NAMES = ["use", "clone", "list"];
export const EXCEPTIONS_DIRECTORY = "Exceptions";
export const REQUESTS_DIRECTORY = "Requests";
export const TYPES_DIRECTORY = "Types";
6 changes: 6 additions & 0 deletions generators/php/sdk/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
- version: 0.2.1
changelogEntry:
- type: fix
summary: >-
Override escaped method names in the generated client.
irVersion: 53
- version: 0.2.0
changelogEntry:
- type: feat
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
- changelogEntry:
- summary: |
Add 'list' to reserved keywords for use in PHP generator.
type: fix
irVersion: 53
version: 0.45.0-rc49
- changelogEntry:
- summary: |
OAuth Client Credential Auth Scheme now supports the ability to optionally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const RESERVED_KEYWORDS: Record<generatorsYml.GenerationLanguage, Set<str
"function",
"global",
"goto",
"list",
"if",
"implements",
"include",
Expand Down
116 changes: 57 additions & 59 deletions seed/php-sdk/pagination/.mock/definition/users.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1eccbb0

Please sign in to comment.