Summary
The PHP SDK generator's README "Environments" section emits a code sample that does not compile. Two values are hardcoded in the template while the prose and the environment list around them are correctly derived from the IR, so the section is internally inconsistent.
Affects any PHP SDK with single-base-URL environments. It is visible in this repo's own seed fixtures — Environments::Staging appears in 24 files under seed/php-sdk/.
Where
generators/php/sdk/src/readme/ReadmeSnippetBuilder.ts, buildSingleUrlEnvironmentsSnippet():
${this.context.getClientVariableName()} = new ${this.context.getRootClientClassName()}(
token: '${this.escapePhpSingleQuote(this.getAuthTokenPlaceholder())}',
options: [
'baseUrl' => ${this.context.getEnvironmentsClassReference().name}::Staging->value
Two defects
1. token: is hardcoded regardless of the auth scheme. The root client names that constructor parameter from the auth scheme — RootClientGenerator.getParameterForAuthScheme uses this.context.getParameterName(...) — so for header auth it is not token. The generated constructor and the README disagree.
2. ::Staging is a literal. The environment list immediately above it is generated from this.context.ir.environments, so the section lists the real environments and then demonstrates one that does not exist in the generated enum.
Reproduction
A spec with header auth and two single-base-URL environments named UnitedStates and Canada produces:
// generated src/AwardspringClient.php
public function __construct(
string $apiKey,
?array $options = null,
)
// generated src/Environments.php
enum Environments: string
{
case UnitedStates = "https://api.awardspring.com";
case Canada = "https://api.awardspring.ca";
}
and this README section:
$client = new AwardspringClient(
token: '<YOUR_TOKEN>',
options: [
'baseUrl' => Environments::Staging->value
]
);
token: is not a parameter and Environments::Staging does not exist, so a reader copying the sample gets two errors. Live example: https://github.com/AwardSpring/awardspring-php#environments
Suggested fix
Both correct values are already in scope:
- Use the auth parameter name the root client generator derives, rather than the literal
token.
- Pick a real environment for the sample —
environments[1] ?? environments[0] — instead of Staging. firstEnvName is already computed on line 412 and used in the prose above.
Happy to open a PR, but the change moves 24 seed fixtures and I could not run pnpm seed locally, so regenerating the goldens is better done by someone with the toolchain.
Also, minor
The same section's markdown is malformed: a ```php fence opens around the prose line ("The SDK defaults to ...") before the actual code fence, and a stray closing fence follows the environment list. Rendered output puts explanatory prose inside a PHP code block.
Summary
The PHP SDK generator's README "Environments" section emits a code sample that does not compile. Two values are hardcoded in the template while the prose and the environment list around them are correctly derived from the IR, so the section is internally inconsistent.
Affects any PHP SDK with single-base-URL environments. It is visible in this repo's own seed fixtures —
Environments::Stagingappears in 24 files underseed/php-sdk/.Where
generators/php/sdk/src/readme/ReadmeSnippetBuilder.ts,buildSingleUrlEnvironmentsSnippet():Two defects
1.
token:is hardcoded regardless of the auth scheme. The root client names that constructor parameter from the auth scheme —RootClientGenerator.getParameterForAuthSchemeusesthis.context.getParameterName(...)— so for header auth it is nottoken. The generated constructor and the README disagree.2.
::Stagingis a literal. The environment list immediately above it is generated fromthis.context.ir.environments, so the section lists the real environments and then demonstrates one that does not exist in the generated enum.Reproduction
A spec with header auth and two single-base-URL environments named
UnitedStatesandCanadaproduces:and this README section:
token:is not a parameter andEnvironments::Stagingdoes not exist, so a reader copying the sample gets two errors. Live example: https://github.com/AwardSpring/awardspring-php#environmentsSuggested fix
Both correct values are already in scope:
token.environments[1] ?? environments[0]— instead ofStaging.firstEnvNameis already computed on line 412 and used in the prose above.Happy to open a PR, but the change moves 24 seed fixtures and I could not run
pnpm seedlocally, so regenerating the goldens is better done by someone with the toolchain.Also, minor
The same section's markdown is malformed: a ```php fence opens around the prose line ("The SDK defaults to ...") before the actual code fence, and a stray closing fence follows the environment list. Rendered output puts explanatory prose inside a PHP code block.