Skip to content

Commit f832cb9

Browse files
authored
ENV vars and secrets have scalar values, and a string name (#4224)
1 parent 6a96feb commit f832cb9

4 files changed

Lines changed: 19 additions & 8 deletions

File tree

docs/api.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ run('echo \{{not_replaced}}'); // outputs: {{not_replaced}}
382382
| `$cwd` | `string` or `null` | Working directory for this run. Defaults to `{{working_path}}` (set by `cd()`). |
383383
| `$timeout` | `int` or `null` | Max runtime in seconds (default: `{{default_timeout}}`, 300; `null` disables). |
384384
| `$idleTimeout` | `int` or `null` | Max seconds without output before aborting. |
385-
| `$secrets` | `array` or `null` | Map of `%name%` placeholders to redacted values. |
386-
| `$env` | `array` or `null` | Environment variables: `run('echo $KEY', env: ['KEY' => 'value']);` |
385+
| `$secrets` | `array<string, scalar>` or `null` | Map of `%name%` placeholders to redacted values. |
386+
| `$env` | `array<string, scalar>` or `null` | Environment variables: `run('echo $KEY', env: ['KEY' => 'value']);` |
387387
| `$forceOutput` | `bool` or `null` | Print command output in real time. |
388388
| `$nothrow` | `bool` or `null` | Return output instead of throwing on non-zero exit. |
389389

@@ -420,8 +420,8 @@ runLocally('npm run build', timeout: 600);
420420
| `$cwd` | `string` or `null` | Working directory for this run. Defaults to `{{working_path}}`. |
421421
| `$timeout` | `int` or `null` | Max runtime in seconds (default 300, `null` disables). |
422422
| `$idleTimeout` | `int` or `null` | Max seconds without output before aborting. |
423-
| `$secrets` | `array` or `null` | Map of `%name%` placeholders to redacted values. |
424-
| `$env` | `array` or `null` | Environment variables: `runLocally('echo $KEY', env: ['KEY' => 'value']);` |
423+
| `$secrets` | `array<string, scalar>` or `null` | Map of `%name%` placeholders to redacted values. |
424+
| `$env` | `array<string, scalar>` or `null` | Environment variables: `runLocally('echo $KEY', env: ['KEY' => 'value']);` |
425425
| `$forceOutput` | `bool` or `null` | Print command output in real time. |
426426
| `$nothrow` | `bool` or `null` | Return output instead of throwing on non-zero exit. |
427427
| `$shell` | `string` or `null` | Shell to run in. Default `bash -s`. |

src/Ssh/RunParams.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
class RunParams
66
{
7+
/**
8+
* @param array<string, scalar>|null $env
9+
* @param array<string, scalar>|null $secrets
10+
*/
711
public function __construct(
812
public ?string $shell = null,
913
public ?string $cwd = null,
@@ -18,6 +22,9 @@ public function __construct(
1822
public ?array $secrets = null,
1923
) {}
2024

25+
/**
26+
* @param array<string, scalar>|null $secrets
27+
*/
2128
public function with(
2229
#[\SensitiveParameter]
2330
?array $secrets = null,

src/Support/helpers.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ function ($key, $value) {
6767
));
6868
}
6969

70+
/**
71+
* @param array<string, scalar>|null $secrets
72+
* @return string
73+
*/
7074
function replace_secrets(string $command, ?array $secrets): string
7175
{
7276
if (!empty($secrets)) {

src/functions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,8 @@ function within(string $path, callable $callback): mixed
495495
* @param string|null $cwd Working directory for this run. Defaults to `{{working_path}}` (set by `cd()`).
496496
* @param int|null $timeout Max runtime in seconds (default: `{{default_timeout}}`, 300; `null` disables).
497497
* @param int|null $idleTimeout Max seconds without output before aborting.
498-
* @param array|null $secrets Map of `%name%` placeholders to redacted values.
499-
* @param array|null $env Environment variables: `run('echo $KEY', env: ['KEY' => 'value']);`
498+
* @param array<string, scalar>|null $secrets Map of `%name%` placeholders to redacted values.
499+
* @param array<string, scalar>|null $env Environment variables: `run('echo $KEY', env: ['KEY' => 'value']);`
500500
* @param bool|null $forceOutput Print command output in real time.
501501
* @param bool|null $nothrow Return output instead of throwing on non-zero exit.
502502
* @throws RunException
@@ -581,8 +581,8 @@ function run(
581581
* @param string|null $cwd Working directory for this run. Defaults to `{{working_path}}`.
582582
* @param int|null $timeout Max runtime in seconds (default 300, `null` disables).
583583
* @param int|null $idleTimeout Max seconds without output before aborting.
584-
* @param array|null $secrets Map of `%name%` placeholders to redacted values.
585-
* @param array|null $env Environment variables: `runLocally('echo $KEY', env: ['KEY' => 'value']);`
584+
* @param array<string, scalar>|null $secrets Map of `%name%` placeholders to redacted values.
585+
* @param array<string, scalar>|null $env Environment variables: `runLocally('echo $KEY', env: ['KEY' => 'value']);`
586586
* @param bool|null $forceOutput Print command output in real time.
587587
* @param bool|null $nothrow Return output instead of throwing on non-zero exit.
588588
* @param string|null $shell Shell to run in. Default `bash -s`.

0 commit comments

Comments
 (0)