Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ parameters:
- recipe
- contrib

bootstrapFiles:
- tests/constants.php

dynamicConstantNames:
DEPLOYER_VERSION: string
DEPLOYER_BIN: string
MASTER_ENDPOINT: string
MASTER_TOKEN: string
Comment on lines +15 to +19
Copy link
Copy Markdown
Contributor Author

@staabm staabm May 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make PHPStan aware which types we expect the constants to have. those will be validated against when code uses define() or const.

see


ignoreErrors:
- "#^Constant DEPLOYER_VERSION not found\\.$#"
- "#^Constant DEPLOYER_BIN not found\\.$#"
- "#^Constant MASTER_ENDPOINT not found\\.$#"
- "#^Constant MASTER_TOKEN not found\\.$#"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEPLOYER_VERSION, DEPLOYER_BIN will be detected by phpstan bootstrap.

MASTER_ENDPOINT, MASTER_TOKEN are only conditionally defined, therefore still needs the ignore

- "#CpanelPhp#"
Expand Down
3 changes: 3 additions & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use function Deployer\Support\is_closure;
use function Deployer\Support\normalize_line_endings;

/**
* @implements \ArrayAccess<string, mixed>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reflects the signature of
function set(string $name, mixed $value)

*/
class Configuration implements \ArrayAccess
{
private ?Configuration $parent;
Expand Down
5 changes: 1 addition & 4 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
set_include_path(__DIR__ . '/..' . PATH_SEPARATOR . get_include_path());

putenv('DEPLOYER_LOCAL_WORKER=true');
define('DEPLOYER_BIN', __DIR__ . '/../bin/dep');
define('__FIXTURES__', __DIR__ . '/fixtures');
define('__REPOSITORY__', __DIR__ . '/fixtures/repository');
define('__TEMP_DIR__', sys_get_temp_dir() . '/deployer');
require_once __DIR__ . '/constants.php';

require_once __DIR__ . '/spec/SpecTest.php';

Expand Down
7 changes: 7 additions & 0 deletions tests/constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

define('DEPLOYER_BIN', __DIR__ . '/../bin/dep');
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracting constant definitions in a separate file, so PHPStan can discover them

define('DEPLOYER_VERSION', 'dev-master');
define('__FIXTURES__', __DIR__ . '/fixtures');
define('__REPOSITORY__', __DIR__ . '/fixtures/repository');
define('__TEMP_DIR__', sys_get_temp_dir() . '/deployer');