Skip to content

Commit

Permalink
Merge pull request #221 from ember-nexus/github-issue/211
Browse files Browse the repository at this point in the history
Constants are changed to contain type declarations, closes #211.
  • Loading branch information
Syndesi authored Dec 18, 2023
2 parents 7208083 + 615be5d commit 4363614
Show file tree
Hide file tree
Showing 114 changed files with 412 additions and 398 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Changed
- Constants are changed to contain type declarations, closes #211.

## 0.1.0 - 2023-12-16
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

class Configuration implements ConfigurationInterface
{
public const HALF_AN_HOUR_IN_SECONDS = 1800;
public const THREE_HOURS_IN_SECONDS = 3600 * 3;
public const THIRTEEN_MONTHS_IN_SECONDS = 3600 * 24 * (365 + 31);
public const TWO_WEEKS_IN_SECONDS = 3600 * 24 * 14;
public const int HALF_AN_HOUR_IN_SECONDS = 1800;
public const int THREE_HOURS_IN_SECONDS = 3600 * 3;
public const int THIRTEEN_MONTHS_IN_SECONDS = 3600 * 24 * (365 + 31);
public const int TWO_WEEKS_IN_SECONDS = 3600 * 24 * 14;

public function getConfigTreeBuilder(): TreeBuilder
{
Expand Down
38 changes: 19 additions & 19 deletions lib/EmberNexusBundle/src/Service/EmberNexusConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@
*/
class EmberNexusConfiguration
{
public const PAGE_SIZE = 'pageSize';
public const PAGE_SIZE_MIN = 'min';
public const PAGE_SIZE_DEFAULT = 'default';
public const PAGE_SIZE_MAX = 'max';

public const REGISTER = 'register';
public const REGISTER_ENABLED = 'enabled';
public const REGISTER_UNIQUE_IDENTIFIER = 'uniqueIdentifier';
public const REGISTER_UNIQUE_IDENTIFIER_REGEX = 'uniqueIdentifierRegex';

public const INSTANCE_CONFIGURATION = 'instanceConfiguration';
public const INSTANCE_CONFIGURATION_ENABLED = 'enabled';
public const INSTANCE_CONFIGURATION_SHOW_VERSION = 'showVersion';

public const TOKEN = 'token';
public const TOKEN_MIN_LIFETIME_IN_SECONDS = 'minLifetimeInSeconds';
public const TOKEN_DEFAULT_LIFETIME_IN_SECONDS = 'defaultLifetimeInSeconds';
public const TOKEN_MAX_LIFETIME_IN_SECONDS = 'maxLifetimeInSeconds';
public const TOKEN_DELETE_EXPIRED_TOKENS_AUTOMATICALLY_IN_SECONDS = 'tokenDeleteExpiredTokensAutomaticallyInSeconds';
public const string PAGE_SIZE = 'pageSize';
public const string PAGE_SIZE_MIN = 'min';
public const string PAGE_SIZE_DEFAULT = 'default';
public const string PAGE_SIZE_MAX = 'max';

public const string REGISTER = 'register';
public const string REGISTER_ENABLED = 'enabled';
public const string REGISTER_UNIQUE_IDENTIFIER = 'uniqueIdentifier';
public const string REGISTER_UNIQUE_IDENTIFIER_REGEX = 'uniqueIdentifierRegex';

public const string INSTANCE_CONFIGURATION = 'instanceConfiguration';
public const string INSTANCE_CONFIGURATION_ENABLED = 'enabled';
public const string INSTANCE_CONFIGURATION_SHOW_VERSION = 'showVersion';

public const string TOKEN = 'token';
public const string TOKEN_MIN_LIFETIME_IN_SECONDS = 'minLifetimeInSeconds';
public const string TOKEN_DEFAULT_LIFETIME_IN_SECONDS = 'defaultLifetimeInSeconds';
public const string TOKEN_MAX_LIFETIME_IN_SECONDS = 'maxLifetimeInSeconds';
public const string TOKEN_DELETE_EXPIRED_TOKENS_AUTOMATICALLY_IN_SECONDS = 'tokenDeleteExpiredTokensAutomaticallyInSeconds';

private int $pageSizeMin;
private int $pageSizeDefault;
Expand Down
22 changes: 11 additions & 11 deletions src/Command/TokenRevokeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ class TokenRevokeCommand extends Command
{
private EmberNexusStyle $io;

public const OPTION_FORCE = 'force';
public const OPTION_DRY_RUN = 'dry-run';
public const OPTION_LIST_ALL_AFFECTED_TOKENS = 'list-all-affected-tokens';
public const OPTION_USER = 'user';
public const OPTION_GROUP = 'group';
public const OPTION_ISSUED_BEFORE = 'issued-before';
public const OPTION_ISSUED_AFTER = 'issued-after';
public const OPTION_ISSUED_WITHOUT_EXPIRATION_DATE = 'issued-without-expiration-date';
public const OPTION_ISSUED_WITH_EXPIRATION_DATE = 'issued-with-expiration-date';
public const NUMBER_OF_TOKENS_TO_DISPLAY = 10;
public const TOKEN_REVOKE_BATCH_SIZE = 10;
public const string OPTION_FORCE = 'force';
public const string OPTION_DRY_RUN = 'dry-run';
public const string OPTION_LIST_ALL_AFFECTED_TOKENS = 'list-all-affected-tokens';
public const string OPTION_USER = 'user';
public const string OPTION_GROUP = 'group';
public const string OPTION_ISSUED_BEFORE = 'issued-before';
public const string OPTION_ISSUED_AFTER = 'issued-after';
public const string OPTION_ISSUED_WITHOUT_EXPIRATION_DATE = 'issued-without-expiration-date';
public const string OPTION_ISSUED_WITH_EXPIRATION_DATE = 'issued-with-expiration-date';
public const int NUMBER_OF_TOKENS_TO_DISPLAY = 10;
public const int TOKEN_REVOKE_BATCH_SIZE = 10;

private bool $isForceActive = false;
private bool $isDryRunActive = false;
Expand Down
4 changes: 2 additions & 2 deletions src/Helper/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

class Regex
{
public const UUID_V4_CONTROLLER = '[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}';
public const UUID_V4 = '/^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$/';
public const string UUID_V4_CONTROLLER = '[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}';
public const string UUID_V4 = '/^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$/';
}
5 changes: 4 additions & 1 deletion src/Helper/ReservedPropertyNameHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

class ReservedPropertyNameHelper
{
public const RESERVED_PROPERTY_NAMES = [
/**
* @var string[] RESERVED_PROPERTY_NAMES
*/
public const array RESERVED_PROPERTY_NAMES = [
'id',
'_id',
'type',
Expand Down
2 changes: 1 addition & 1 deletion tests/ExampleGenerationCommand/Backup/BackupCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class BackupCreateTest extends BaseCommandTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testBackupCreateHelp(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ExampleGenerationCommand/Backup/BackupFetchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class BackupFetchTest extends BaseCommandTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testBackupFetchHelp(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ExampleGenerationCommand/Backup/BackupListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class BackupListTest extends BaseCommandTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testBackupListHelp(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ExampleGenerationCommand/Backup/BackupLoadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class BackupLoadTest extends BaseCommandTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testBackupListHelp(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class DatabaseDropTest extends BaseCommandTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testUserCreateHelp(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class SystemHealthcheckTest extends BaseCommandTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testSystemHealthcheckHelp(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ExampleGenerationCommand/Token/TokenCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class TokenCreateTest extends BaseCommandTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testTokenCreateHelp(): void
{
Expand Down
4 changes: 2 additions & 2 deletions tests/ExampleGenerationCommand/Token/TokenRevokeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class TokenRevokeTest extends BaseCommandTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testTokenRevokeHelp(): void
{
Expand All @@ -33,7 +33,7 @@ public function testTokenRevoke(): void
'Found user with identifier',
'Successfully revoked new token:',
'localhost.dev',
'User identifier'
'User identifier',
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ExampleGenerationCommand/User/UserCreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class UserCreateTest extends BaseCommandTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testUserCreateHelp(): void
{
Expand Down
12 changes: 9 additions & 3 deletions tests/ExampleGenerationController/BaseRequestTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@

abstract class BaseRequestTestCase extends \App\Tests\FeatureTests\BaseRequestTestCase
{
private const IGNORED_HEADERS = ['Date', 'Location'];

private const REMOVED_HEADERS = ['X-Debug-Token', 'X-Debug-Token-Link'];
/**
* @var string[] IGNORED_HEADERS
*/
private const array IGNORED_HEADERS = ['Date', 'Location'];

/**
* @var string[] REMOVED_HEADERS
*/
private const array REMOVED_HEADERS = ['X-Debug-Token', 'X-Debug-Token-Link'];

public function getHeadersFromRequest(ResponseInterface $response): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

class DeleteElementTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

private const TOKEN = 'secret-token:CevJS3ZkDtJcCdqEhFKqWF';
private const ELEMENT = '55cce573-1377-4781-be16-8b81587aca10';
private const NON_EXISTENT_ELEMENT = '00000000-0000-4000-8000-000000000000';
private const string TOKEN = 'secret-token:CevJS3ZkDtJcCdqEhFKqWF';
private const string ELEMENT = '55cce573-1377-4781-be16-8b81587aca10';
private const string NON_EXISTENT_ELEMENT = '00000000-0000-4000-8000-000000000000';

public function testDeleteElementSuccess(): void
{
Expand Down
8 changes: 4 additions & 4 deletions tests/ExampleGenerationController/Element/GetChildrenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

class GetChildrenTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const PARENT_UUID = '56fda20c-b238-4034-b555-1df47c47e17a';
private const ELEMENT_WHICH_DOES_NOT_EXIST = 'b4117ae0-1241-479f-b363-45f290ec7fc7';
private const string PATH_TO_ROOT = __DIR__.'/../../../';
private const string TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const string PARENT_UUID = '56fda20c-b238-4034-b555-1df47c47e17a';
private const string ELEMENT_WHICH_DOES_NOT_EXIST = 'b4117ae0-1241-479f-b363-45f290ec7fc7';

public function testGetChildrenSuccess(): void
{
Expand Down
10 changes: 5 additions & 5 deletions tests/ExampleGenerationController/Element/GetElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

class GetElementTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const NODE_UUID = '74a8fcd9-6cb0-4b0d-8d42-0b6c3c54d1ac';
private const RELATION_UUID = 'eb5d2879-c5e6-43a6-b8ce-2a1188ca7073';
private const ELEMENT_WHICH_DOES_NOT_EXIST = 'b4117ae0-1241-479f-b363-45f290ec7fc7';
private const string PATH_TO_ROOT = __DIR__.'/../../../';
private const string TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const string NODE_UUID = '74a8fcd9-6cb0-4b0d-8d42-0b6c3c54d1ac';
private const string RELATION_UUID = 'eb5d2879-c5e6-43a6-b8ce-2a1188ca7073';
private const string ELEMENT_WHICH_DOES_NOT_EXIST = 'b4117ae0-1241-479f-b363-45f290ec7fc7';

public function testGetNodeSuccess(): void
{
Expand Down
4 changes: 2 additions & 2 deletions tests/ExampleGenerationController/Element/GetIndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class GetIndexTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const string PATH_TO_ROOT = __DIR__.'/../../../';
private const string TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';

public function testGetIndexSuccess(): void
{
Expand Down
8 changes: 4 additions & 4 deletions tests/ExampleGenerationController/Element/GetParentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

class GetParentsTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const CHILD_UUID = '45482998-274a-43d0-a466-f31d0b24cc0a';
private const ELEMENT_WHICH_DOES_NOT_EXIST = 'b4117ae0-1241-479f-b363-45f290ec7fc7';
private const string PATH_TO_ROOT = __DIR__.'/../../../';
private const string TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const string CHILD_UUID = '45482998-274a-43d0-a466-f31d0b24cc0a';
private const string ELEMENT_WHICH_DOES_NOT_EXIST = 'b4117ae0-1241-479f-b363-45f290ec7fc7';

public function testGetParentsSuccess(): void
{
Expand Down
8 changes: 4 additions & 4 deletions tests/ExampleGenerationController/Element/GetRelatedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

class GetRelatedTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const ELEMENT_UUID = '45482998-274a-43d0-a466-f31d0b24cc0a';
private const ELEMENT_WHICH_DOES_NOT_EXIST = 'b4117ae0-1241-479f-b363-45f290ec7fc7';
private const string PATH_TO_ROOT = __DIR__.'/../../../';
private const string TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const string ELEMENT_UUID = '45482998-274a-43d0-a466-f31d0b24cc0a';
private const string ELEMENT_WHICH_DOES_NOT_EXIST = 'b4117ae0-1241-479f-b363-45f290ec7fc7';

public function testGetRelatedSuccess(): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/ExampleGenerationController/Element/PostElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

class PostElementTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const PARENT_ELEMENT = '7b80b203-2b82-40f5-accd-c7089fe6114e';
private const string PATH_TO_ROOT = __DIR__.'/../../../';
private const string TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const string PARENT_ELEMENT = '7b80b203-2b82-40f5-accd-c7089fe6114e';

public function testPostElementSuccess(): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/ExampleGenerationController/Element/PostIndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

class PostIndexTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const ELEMENT_WHICH_DOES_NOT_EXIST = 'b4117ae0-1241-479f-b363-45f290ec7fc7';
private const string PATH_TO_ROOT = __DIR__.'/../../../';
private const string TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const string ELEMENT_WHICH_DOES_NOT_EXIST = 'b4117ae0-1241-479f-b363-45f290ec7fc7';

public function testPostIndexSuccess(): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/ExampleGenerationController/Element/PutElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

class PutElementTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const PARENT_ELEMENT = '7b80b203-2b82-40f5-accd-c7089fe6114e';
private const string PATH_TO_ROOT = __DIR__.'/../../../';
private const string TOKEN = 'secret-token:PIPeJGUt7c00ENn8a5uDlc';
private const string PARENT_ELEMENT = '7b80b203-2b82-40f5-accd-c7089fe6114e';

public function testPostElementSuccess(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Get400BadContentTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testRegisterSuccess(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Get400ForbiddenPropertyTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testRegisterSuccess(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Get400IncompleteMutualDependencyTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testRegisterSuccess(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Get400MissingPropertyTest extends BaseRequestTestCase
{
private const PATH_TO_ROOT = __DIR__.'/../../../';
private const string PATH_TO_ROOT = __DIR__.'/../../../';

public function testRegisterSuccess(): void
{
Expand Down
Loading

0 comments on commit 4363614

Please sign in to comment.