From b20b5b6d27315e2913ba2eb90e75b251fbe94ccd Mon Sep 17 00:00:00 2001 From: Marco Spengler Date: Wed, 22 Dec 2021 10:17:39 +0100 Subject: [PATCH] #98 Raise PHP version (#99) * #98 Raise php version * #98 Add native types * #98 Drop redundand type information from doc blocks * #98 Drop PHP 7.1, 7.2, 7.3 from travis configuration * #98 Add `ReturnTypeWillChange` attribute Add `ReturnTypeWillChange` attribute for methods with mixed return type to support PHP 8.1 type inheritance check. --- .travis.yml | 3 - composer.json | 2 +- src/Client.php | 120 ++++--------- src/Collections/CertificateCollection.php | 7 +- src/Collections/ConfigMapCollection.php | 7 +- src/Collections/CronJobCollection.php | 7 +- src/Collections/DaemonSetCollection.php | 7 +- src/Collections/DeploymentCollection.php | 7 +- src/Collections/EndpointCollection.php | 7 +- src/Collections/EventCollection.php | 7 +- .../HorizontalPodAutoscalerCollection.php | 7 +- src/Collections/IngressCollection.php | 7 +- src/Collections/IssuerCollection.php | 7 +- src/Collections/JobCollection.php | 7 +- src/Collections/NamespaceCollection.php | 7 +- src/Collections/NetworkPolicyCollection.php | 7 +- src/Collections/NodeCollection.php | 7 +- .../PersistentVolumeClaimCollection.php | 7 +- .../PersistentVolumeCollection.php | 7 +- src/Collections/PodCollection.php | 7 +- src/Collections/QuotaCollection.php | 7 +- src/Collections/ReplicaSetCollection.php | 7 +- .../ReplicationControllerCollection.php | 7 +- src/Collections/SecretCollection.php | 7 +- src/Collections/ServiceCollection.php | 7 +- src/Models/Certificate.php | 2 +- src/Models/CronJob.php | 4 +- src/Models/DaemonSet.php | 4 +- src/Models/Deployment.php | 4 +- src/Models/Endpoint.php | 4 +- src/Models/HorizontalPodAutoscaler.php | 4 +- src/Models/Ingress.php | 4 +- src/Models/Issuer.php | 2 +- src/Models/Job.php | 4 +- src/Models/Model.php | 47 ++--- src/Models/NamespaceModel.php | 4 +- src/Models/NetworkPolicy.php | 4 +- src/Models/ReplicaSet.php | 4 +- src/Repositories/CertificateRepository.php | 4 +- src/Repositories/ConfigMapRepository.php | 4 +- src/Repositories/CronJobRepository.php | 4 +- src/Repositories/DaemonSetRepository.php | 4 +- src/Repositories/DeploymentRepository.php | 4 +- src/Repositories/EndpointRepository.php | 4 +- src/Repositories/EventRepository.php | 4 +- .../HorizontalPodAutoscalerRepository.php | 4 +- src/Repositories/IngressRepository.php | 4 +- src/Repositories/IssuerRepository.php | 4 +- src/Repositories/JobRepository.php | 4 +- src/Repositories/NamespaceRepository.php | 6 +- src/Repositories/NetworkPolicyRepository.php | 4 +- src/Repositories/NodeRepository.php | 9 +- .../PersistentVolumeClaimRepository.php | 4 +- .../PersistentVolumeRepository.php | 14 +- src/Repositories/PodRepository.php | 13 +- src/Repositories/QuotaRepository.php | 6 +- src/Repositories/ReplicaSetRepository.php | 4 +- .../ReplicationControllerRepository.php | 4 +- src/Repositories/Repository.php | 161 +++++------------- src/Repositories/SecretRepository.php | 4 +- src/Repositories/ServiceRepository.php | 4 +- src/Repositories/Strategy/PatchMergeTrait.php | 2 +- .../Utils/JSONStreamingListener.php | 61 +------ .../Utils/JSONStreamingParser.php | 122 +++++-------- src/RepositoryRegistry.php | 23 +-- tests/ClientTest.php | 10 +- tests/RepositoryRegistryTest.php | 4 +- tests/TestCase.php | 15 +- .../collections/CertificateCollectionTest.php | 6 +- tests/collections/ConfigMapCollectionTest.php | 6 +- .../collections/DeploymentCollectionTest.php | 6 +- tests/collections/EndpointCollectionTest.php | 6 +- tests/collections/EventCollectionTest.php | 6 +- tests/collections/IngressCollectionTest.php | 6 +- tests/collections/IssuerCollectionTest.php | 6 +- tests/collections/JobCollectionTest.php | 6 +- tests/collections/NamespaceCollectionTest.php | 6 +- .../NetworkPolicyCollectionTest.php | 6 +- tests/collections/NodeCollectionTest.php | 6 +- tests/collections/PodCollectionTest.php | 6 +- .../collections/ReplicaSetCollectionTest.php | 6 +- .../ReplicationControllerCollectionTest.php | 6 +- tests/collections/SecretCollectionTest.php | 6 +- tests/collections/ServiceCollectionTest.php | 6 +- tests/models/CertificateTest.php | 4 +- tests/models/ConfigMapTest.php | 4 +- tests/models/CronJobTest.php | 6 +- tests/models/DeploymentTest.php | 4 +- tests/models/EndpointTest.php | 4 +- tests/models/EventTest.php | 4 +- tests/models/IngressTest.php | 4 +- tests/models/IssuerTest.php | 4 +- tests/models/JobTest.php | 4 +- tests/models/ModelTest.php | 14 +- tests/models/NamespaceTest.php | 4 +- tests/models/NetworkPolicyTest.php | 4 +- tests/models/NodeTest.php | 4 +- tests/models/PodTest.php | 6 +- tests/models/ReplicaSetTest.php | 4 +- tests/models/ReplicationControllerTest.php | 6 +- tests/models/SecretTest.php | 4 +- tests/models/ServiceTest.php | 6 +- 102 files changed, 343 insertions(+), 727 deletions(-) diff --git a/.travis.yml b/.travis.yml index ed1ead3..4bbccbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,6 @@ language: php dist: bionic php: - - 7.1 - - 7.2 - - 7.3 - 7.4 # - 8.0 # PHP 8.0 requires PHPUnit to be upgraded, which then would break earlier versions diff --git a/composer.json b/composer.json index a1f2b44..7cfa277 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ ], "license" : "MIT", "require": { - "php" : "^7.1|^8.0", + "php" : "^7.4|^8.0", "php-http/client-common": "^2.0", "php-http/socket-client": "^2.0", "php-http/discovery" : "^1.0", diff --git a/src/Client.php b/src/Client.php index 13b140d..158d8a3 100644 --- a/src/Client.php +++ b/src/Client.php @@ -10,6 +10,7 @@ use Http\Client\HttpClient; use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; use Http\Client\Exception\TransferException as HttpTransferException; use Http\Message\RequestFactory as HttpRequestFactory; use Http\Discovery\HttpClientDiscovery; @@ -68,59 +69,43 @@ class Client { /** * The api version. - * - * @var string */ - protected $apiVersion = 'v1'; + protected string $apiVersion = 'v1'; /** * The address of the master server. - * - * @var string|null */ - protected $master; + protected ?string $master = null; /** * The servide account token. - * - * @var string */ - protected $token; + protected ?string $token = null; /** * The username for basic auth. - * - * @var string */ - protected $username; + protected ?string $username = null; /** * The password for basic auth. - * - * @var string */ - protected $password; + protected ?string $password = null; /** * The namespace. - * - * @var string */ - protected $namespace = 'default'; + protected string $namespace = 'default'; /** * The http client. - * - * @var \Http\Client\Common\HttpMethodsClientInterface */ - protected $httpClient; + protected HttpMethodsClientInterface $httpClient; /** * The exec channels for result messages. - * - * @var array */ - protected $execChannels = [ + protected array $execChannels = [ 'stdin', 'stdout', 'stderr', @@ -130,32 +115,29 @@ class Client /** * The repository class registry. - * - * @var RepositoryRegistry */ - protected $classRegistry; + protected RepositoryRegistry $classRegistry; /** * The class instances. - * - * @var array */ - protected $classInstances = []; + protected array $classInstances = []; /** * header for patch. - * - * @var array */ - protected $patchHeaders = ['Content-Type' => 'application/strategic-merge-patch+json']; + protected array $patchHeaders = ['Content-Type' => 'application/strategic-merge-patch+json']; + + protected ?bool $verify = null; + + protected ?string $caCert = null; + + protected ?string $clientCert = null; + + protected ?string $clientKey = null; /** * The constructor. - * - * @param array $options - * @param \Maclof\Kubernetes\RepositoryRegistry|null $repositoryRegistry - * @param ClientInterface|null $httpClient Some client implementing PSR HTTP ClientInterface - * @param \Http\Message\RequestFactory $httpRequestFactory */ public function __construct(array $options = [], RepositoryRegistry $repositoryRegistry = null, ClientInterface $httpClient = null, HttpRequestFactory $httpRequestFactory = null) { @@ -169,11 +151,8 @@ public function __construct(array $options = [], RepositoryRegistry $repositoryR /** * Set the options. - * - * @param array $options - * @param bool $reset */ - public function setOptions(array $options, $reset = false) + public function setOptions(array $options, bool $reset = false): void { if ($reset) { $this->master = null; @@ -205,11 +184,9 @@ public function setOptions(array $options, $reset = false) * Parse a kubeconfig. * * @param string|array $content Mixed type, based on the second input argument - * @param string $contentType - * @return array * @throws \InvalidArgumentException */ - public static function parseKubeconfig($content, $contentType = 'yaml') + public static function parseKubeconfig($content, string $contentType = 'yaml'): array { if ($contentType === 'array') { if (!is_array($content)) { @@ -328,11 +305,9 @@ public static function parseKubeconfig($content, $contentType = 'yaml') /** * Parse a kubeconfig file. * - * @param string $filePath - * @return array * @throws \InvalidArgumentException */ - public static function parseKubeconfigFile($filePath) + public static function parseKubeconfigFile(string $filePath): array { if (!file_exists($filePath)) { throw new InvalidArgumentException('Kubeconfig file does not exist at path: ' . $filePath); @@ -343,12 +318,8 @@ public static function parseKubeconfigFile($filePath) /** * Get a temp file path for some content. - * - * @param string $fileName - * @param string $fileContent - * @return string */ - protected static function getTempFilePath($fileName, $fileContent) + protected static function getTempFilePath(string $fileName, string $fileContent): string { $fileName = 'kubernetes-client-' . $fileName; @@ -363,20 +334,16 @@ protected static function getTempFilePath($fileName, $fileContent) /** * Set namespace. - * - * @param string $namespace */ - public function setNamespace($namespace) + public function setNamespace(string $namespace): void { $this->namespace = $namespace; } /** * Set patch header - * - * @param string patch type */ - public function setPatchType($patchType = "strategic") + public function setPatchType(string $patchType = "strategic"): void { if ($patchType === "merge") { $this->patchHeaders = ['Content-Type' => 'application/merge-patch+json']; @@ -390,17 +357,12 @@ public function setPatchType($patchType = "strategic") /** * Send a request. * - * @param string $method - * @param string $uri - * @param array $query - * @param mixed $body - * @param boolean $namespace - * @param string $apiVersion - * @param array $requestOptions + * @param mixed $body * @return mixed * @throws \Maclof\Kubernetes\Exceptions\BadRequestException */ - public function sendRequest($method, $uri, $query = [], $body = null, $namespace = true, $apiVersion = null, array $requestOptions = []) + #[\ReturnTypeWillChange] + public function sendRequest(string $method, string $uri, array $query = [], $body = null, bool $namespace = true, string $apiVersion = null, array $requestOptions = []) { $baseUri = $apiVersion ? ('apis/' . $apiVersion) : ('api/' . $this->apiVersion); if ($namespace) { @@ -472,23 +434,16 @@ public function sendRequest($method, $uri, $query = [], $body = null, $namespace /** * Check if an upgrade request is required. - * - * @param array $response - * @return boolean */ - protected function isUpgradeRequestRequired(array $response) + protected function isUpgradeRequestRequired(array $response): bool { return $response['code'] == 400 && $response['status'] === 'Failure' && $response['message'] === 'Upgrade request required'; } /** * Send an upgrade request and return any response messages. - * - * @param string $requestUri - * @param array $query - * @return array */ - protected function sendUpgradeRequest($requestUri, array $query) + protected function sendUpgradeRequest(string $requestUri, array $query): array { $fullUrl = $this->master .'/' . $requestUri . '?' . implode('&', $this->parseQueryParams($query)); if (parse_url($fullUrl, PHP_URL_SCHEME) === 'https') { @@ -568,11 +523,8 @@ protected function sendUpgradeRequest($requestUri, array $query) /** * Parse an array of query params. - * - * @param array $query - * @return array */ - protected function parseQueryParams(array $query) + protected function parseQueryParams(array $query): array { $parts = []; @@ -603,10 +555,8 @@ public function health() /** * Check the version. - * - * @return array */ - public function version() + public function version(): array { return $this->sendRequest('GET', '/version'); } @@ -614,12 +564,10 @@ public function version() /** * Magic call method to grab a class instance. * - * @param string $name - * @param array $args * @return \stdClass * @throws \BadMethodCallException */ - public function __call($name, array $args) + public function __call(string $name, array $args) { if (isset($this->classRegistry[$name])) { $class = $this->classRegistry[$name]; diff --git a/src/Collections/CertificateCollection.php b/src/Collections/CertificateCollection.php index 214db94..b11fbce 100644 --- a/src/Collections/CertificateCollection.php +++ b/src/Collections/CertificateCollection.php @@ -6,8 +6,6 @@ class CertificateCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of certificates. - * - * @param array $items - * @return array */ - protected function getCertificates(array $items) + protected function getCertificates(array $items): array { foreach ($items as &$item) { if ($item instanceof Certificate) { diff --git a/src/Collections/ConfigMapCollection.php b/src/Collections/ConfigMapCollection.php index c43098a..716af0c 100644 --- a/src/Collections/ConfigMapCollection.php +++ b/src/Collections/ConfigMapCollection.php @@ -6,8 +6,6 @@ class ConfigMapCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of config maps. - * - * @param array $items - * @return array */ - protected function getConfigMaps(array $items) + protected function getConfigMaps(array $items): array { foreach ($items as &$item) { if ($item instanceof ConfigMap) { diff --git a/src/Collections/CronJobCollection.php b/src/Collections/CronJobCollection.php index 1768463..5942207 100644 --- a/src/Collections/CronJobCollection.php +++ b/src/Collections/CronJobCollection.php @@ -6,8 +6,6 @@ class CronJobCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of cron jobs. - * - * @param array $items - * @return array */ - protected function getCronJobs(array $items) + protected function getCronJobs(array $items): array { foreach ($items as &$item) { if ($item instanceof CronJob) { diff --git a/src/Collections/DaemonSetCollection.php b/src/Collections/DaemonSetCollection.php index c9d9c1f..a96d27f 100644 --- a/src/Collections/DaemonSetCollection.php +++ b/src/Collections/DaemonSetCollection.php @@ -6,8 +6,6 @@ class DaemonSetCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of daemon sets. - * - * @param array $items - * @return array */ - protected function getDaemonSets(array $items) + protected function getDaemonSets(array $items): array { foreach ($items as &$item) { if ($item instanceof DaemonSet) { diff --git a/src/Collections/DeploymentCollection.php b/src/Collections/DeploymentCollection.php index 6ac7aa2..07bbdcb 100644 --- a/src/Collections/DeploymentCollection.php +++ b/src/Collections/DeploymentCollection.php @@ -6,8 +6,6 @@ class DeploymentCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of deployments. - * - * @param array $items - * @return array */ - protected function getDeployments(array $items) + protected function getDeployments(array $items): array { foreach ($items as &$item) { if ($item instanceof Deployment) { diff --git a/src/Collections/EndpointCollection.php b/src/Collections/EndpointCollection.php index 8fbc4ad..c514acd 100644 --- a/src/Collections/EndpointCollection.php +++ b/src/Collections/EndpointCollection.php @@ -6,8 +6,6 @@ class EndpointCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of nodes. - * - * @param array $items - * @return array */ - protected function getEndpoints(array $items) + protected function getEndpoints(array $items): array { foreach ($items as &$item) { if ($item instanceof Endpoint) { diff --git a/src/Collections/EventCollection.php b/src/Collections/EventCollection.php index e960717..af7bc78 100644 --- a/src/Collections/EventCollection.php +++ b/src/Collections/EventCollection.php @@ -6,8 +6,6 @@ class EventCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of nodes. - * - * @param array $items - * @return array */ - protected function getEvents(array $items) + protected function getEvents(array $items): array { foreach ($items as &$item) { if ($item instanceof Event) { diff --git a/src/Collections/HorizontalPodAutoscalerCollection.php b/src/Collections/HorizontalPodAutoscalerCollection.php index 80e12b3..2f06099 100644 --- a/src/Collections/HorizontalPodAutoscalerCollection.php +++ b/src/Collections/HorizontalPodAutoscalerCollection.php @@ -6,8 +6,6 @@ class HorizontalPodAutoscalerCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of autoscalers. - * - * @param array $items - * @return array */ - protected function getHorizontalPodAutoscalers(array $items) + protected function getHorizontalPodAutoscalers(array $items): array { foreach ($items as &$item) { if ($item instanceof HorizontalPodAutoscaler) { diff --git a/src/Collections/IngressCollection.php b/src/Collections/IngressCollection.php index 3014dfa..818b6d9 100644 --- a/src/Collections/IngressCollection.php +++ b/src/Collections/IngressCollection.php @@ -6,8 +6,6 @@ class IngressCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of Ingresses. - * - * @param array $items - * @return array */ - protected function getIngresses(array $items) + protected function getIngresses(array $items): array { foreach ($items as &$item) { if ($item instanceof Ingress) { diff --git a/src/Collections/IssuerCollection.php b/src/Collections/IssuerCollection.php index c507c2d..79fd0f1 100644 --- a/src/Collections/IssuerCollection.php +++ b/src/Collections/IssuerCollection.php @@ -6,8 +6,6 @@ class IssuerCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of certificate issuers. - * - * @param array $items - * @return array */ - protected function getIssuers(array $items) + protected function getIssuers(array $items): array { foreach ($items as &$item) { if ($item instanceof Issuer) { diff --git a/src/Collections/JobCollection.php b/src/Collections/JobCollection.php index f81dc20..dec7f46 100644 --- a/src/Collections/JobCollection.php +++ b/src/Collections/JobCollection.php @@ -6,8 +6,6 @@ class JobCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of jobs. - * - * @param array $items - * @return array */ - protected function getJobs(array $items) + protected function getJobs(array $items): array { foreach ($items as &$item) { if ($item instanceof Job) { diff --git a/src/Collections/NamespaceCollection.php b/src/Collections/NamespaceCollection.php index d735ecc..e40638f 100644 --- a/src/Collections/NamespaceCollection.php +++ b/src/Collections/NamespaceCollection.php @@ -6,8 +6,6 @@ class NamespaceCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of Namespaces. - * - * @param array $items - * @return array */ - protected function getNamespaces(array $items) + protected function getNamespaces(array $items): array { foreach ($items as &$item) { if ($item instanceof NamespaceModel) { diff --git a/src/Collections/NetworkPolicyCollection.php b/src/Collections/NetworkPolicyCollection.php index 1452f5b..9338765 100644 --- a/src/Collections/NetworkPolicyCollection.php +++ b/src/Collections/NetworkPolicyCollection.php @@ -6,8 +6,6 @@ class NetworkPolicyCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of network policies. - * - * @param array $items - * @return array */ - protected function getPolicies(array $items) + protected function getPolicies(array $items): array { foreach ($items as &$item) { if ($item instanceof NetworkPolicy) { diff --git a/src/Collections/NodeCollection.php b/src/Collections/NodeCollection.php index f322e47..3c12545 100644 --- a/src/Collections/NodeCollection.php +++ b/src/Collections/NodeCollection.php @@ -6,8 +6,6 @@ class NodeCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of nodes. - * - * @param array $items - * @return array */ - protected function getNodes(array $items) + protected function getNodes(array $items): array { foreach ($items as &$item) { if ($item instanceof Node) { diff --git a/src/Collections/PersistentVolumeClaimCollection.php b/src/Collections/PersistentVolumeClaimCollection.php index 5bcf381..9daafb7 100644 --- a/src/Collections/PersistentVolumeClaimCollection.php +++ b/src/Collections/PersistentVolumeClaimCollection.php @@ -6,8 +6,6 @@ class PersistentVolumeClaimCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of persistent volume claims. - * - * @param array $items - * @return array */ - protected function getPersistentVolumeClaims(array $items) + protected function getPersistentVolumeClaims(array $items): array { foreach ($items as &$item) { if ($item instanceof PersistentVolumeClaim) { diff --git a/src/Collections/PersistentVolumeCollection.php b/src/Collections/PersistentVolumeCollection.php index 64ff889..9bb47c5 100644 --- a/src/Collections/PersistentVolumeCollection.php +++ b/src/Collections/PersistentVolumeCollection.php @@ -7,8 +7,6 @@ class PersistentVolumeCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -17,11 +15,8 @@ public function __construct(array $items) /** * Get an array of persistent volumes. - * - * @param array $items - * @return array */ - protected function getPersistentVolumes(array $items) + protected function getPersistentVolumes(array $items): array { foreach ($items as &$item) { if ($item instanceof PersistentVolume) { diff --git a/src/Collections/PodCollection.php b/src/Collections/PodCollection.php index c44e374..ad99c27 100644 --- a/src/Collections/PodCollection.php +++ b/src/Collections/PodCollection.php @@ -6,8 +6,6 @@ class PodCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of pods. - * - * @param array $items - * @return array */ - protected function getPods(array $items) + protected function getPods(array $items): array { foreach ($items as &$item) { if ($item instanceof Pod) { diff --git a/src/Collections/QuotaCollection.php b/src/Collections/QuotaCollection.php index 4b50aff..9cb51bb 100644 --- a/src/Collections/QuotaCollection.php +++ b/src/Collections/QuotaCollection.php @@ -6,8 +6,6 @@ class QuotaCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of Namespaces. - * - * @param array $items - * @return array */ - protected function getQuotas(array $items) + protected function getQuotas(array $items): array { foreach ($items as &$item) { if ($item instanceof QuotaModel) { diff --git a/src/Collections/ReplicaSetCollection.php b/src/Collections/ReplicaSetCollection.php index 7eea1fc..750b64d 100644 --- a/src/Collections/ReplicaSetCollection.php +++ b/src/Collections/ReplicaSetCollection.php @@ -6,8 +6,6 @@ class ReplicaSetCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of replication sets. - * - * @param array $items - * @return array */ - protected function getReplicaSets(array $items) + protected function getReplicaSets(array $items): array { foreach ($items as &$item) { if ($item instanceof ReplicaSet) { diff --git a/src/Collections/ReplicationControllerCollection.php b/src/Collections/ReplicationControllerCollection.php index dcde3fb..4e34c04 100644 --- a/src/Collections/ReplicationControllerCollection.php +++ b/src/Collections/ReplicationControllerCollection.php @@ -6,8 +6,6 @@ class ReplicationControllerCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of replication controllers. - * - * @param array $items - * @return array */ - protected function getReplicationControllers(array $items) + protected function getReplicationControllers(array $items): array { foreach ($items as &$item) { if ($item instanceof ReplicationController) { diff --git a/src/Collections/SecretCollection.php b/src/Collections/SecretCollection.php index 80fd249..cda1758 100644 --- a/src/Collections/SecretCollection.php +++ b/src/Collections/SecretCollection.php @@ -6,8 +6,6 @@ class SecretCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of secrets. - * - * @param array $items - * @return array */ - protected function getSecrets(array $items) + protected function getSecrets(array $items): array { foreach ($items as &$item) { if ($item instanceof Secret) { diff --git a/src/Collections/ServiceCollection.php b/src/Collections/ServiceCollection.php index ead0bfc..90e1dc7 100644 --- a/src/Collections/ServiceCollection.php +++ b/src/Collections/ServiceCollection.php @@ -6,8 +6,6 @@ class ServiceCollection extends Collection { /** * The constructor. - * - * @param array $items */ public function __construct(array $items) { @@ -16,11 +14,8 @@ public function __construct(array $items) /** * Get an array of services. - * - * @param array $items - * @return array */ - protected function getServices(array $items) + protected function getServices(array $items): array { foreach ($items as &$item) { if ($item instanceof Service) { diff --git a/src/Models/Certificate.php b/src/Models/Certificate.php index 48f248d..bc265c6 100644 --- a/src/Models/Certificate.php +++ b/src/Models/Certificate.php @@ -3,6 +3,6 @@ class Certificate extends Model { - protected $apiVersion = 'certmanager.k8s.io/v1alpha1'; + protected string $apiVersion = 'certmanager.k8s.io/v1alpha1'; } diff --git a/src/Models/CronJob.php b/src/Models/CronJob.php index 90f42bb..b64d61f 100644 --- a/src/Models/CronJob.php +++ b/src/Models/CronJob.php @@ -4,8 +4,6 @@ class CronJob extends Model { /** * The api version. - * - * @var string */ - protected $apiVersion = 'batch/v1beta1'; + protected string $apiVersion = 'batch/v1beta1'; } diff --git a/src/Models/DaemonSet.php b/src/Models/DaemonSet.php index 365039c..4a85297 100644 --- a/src/Models/DaemonSet.php +++ b/src/Models/DaemonSet.php @@ -4,8 +4,6 @@ class DaemonSet extends Model { /** * The api version. - * - * @var string */ - protected $apiVersion = 'extensions/v1beta1'; + protected string $apiVersion = 'extensions/v1beta1'; } diff --git a/src/Models/Deployment.php b/src/Models/Deployment.php index 683814f..b152300 100644 --- a/src/Models/Deployment.php +++ b/src/Models/Deployment.php @@ -4,8 +4,6 @@ class Deployment extends Model { /** * The api version. - * - * @var string */ - protected $apiVersion = 'apps/v1'; + protected string $apiVersion = 'apps/v1'; } diff --git a/src/Models/Endpoint.php b/src/Models/Endpoint.php index 2a9408b..70efd4e 100644 --- a/src/Models/Endpoint.php +++ b/src/Models/Endpoint.php @@ -4,8 +4,6 @@ class Endpoint extends Model { /** * Whether or not the kind is plural. - * - * @var boolean */ - protected $pluralKind = true; + protected bool $pluralKind = true; } diff --git a/src/Models/HorizontalPodAutoscaler.php b/src/Models/HorizontalPodAutoscaler.php index a76c81f..f24f970 100644 --- a/src/Models/HorizontalPodAutoscaler.php +++ b/src/Models/HorizontalPodAutoscaler.php @@ -4,8 +4,6 @@ class HorizontalPodAutoscaler extends \Maclof\Kubernetes\Models\Model { /** * The api version. - * - * @var string */ - protected $apiVersion = 'autoscaling/v2beta1'; + protected string $apiVersion = 'autoscaling/v2beta1'; } diff --git a/src/Models/Ingress.php b/src/Models/Ingress.php index 80e3226..804bcb1 100644 --- a/src/Models/Ingress.php +++ b/src/Models/Ingress.php @@ -4,8 +4,6 @@ class Ingress extends Model { /** * The api version. - * - * @var string */ - protected $apiVersion = 'networking.k8s.io/v1beta1'; + protected string $apiVersion = 'networking.k8s.io/v1beta1'; } diff --git a/src/Models/Issuer.php b/src/Models/Issuer.php index 231385e..54bbac1 100644 --- a/src/Models/Issuer.php +++ b/src/Models/Issuer.php @@ -3,6 +3,6 @@ class Issuer extends Model { - protected $apiVersion = 'certmanager.k8s.io/v1alpha1'; + protected string $apiVersion = 'certmanager.k8s.io/v1alpha1'; } diff --git a/src/Models/Job.php b/src/Models/Job.php index af13e35..555bb3c 100644 --- a/src/Models/Job.php +++ b/src/Models/Job.php @@ -4,8 +4,6 @@ class Job extends Model { /** * The api version. - * - * @var string */ - protected $apiVersion = 'batch/v1'; + protected string $apiVersion = 'batch/v1'; } diff --git a/src/Models/Model.php b/src/Models/Model.php index aaefc33..472b67b 100644 --- a/src/Models/Model.php +++ b/src/Models/Model.php @@ -12,40 +12,30 @@ abstract class Model implements Arrayable { /** * The schema. - * - * @var array */ - protected $schema = []; + protected array $schema = []; /** * The api version. - * - * @var string */ - protected $apiVersion = 'v1'; + protected string $apiVersion = 'v1'; /** * Whether or not the kind is plural. - * - * @var boolean */ - protected $pluralKind = false; + protected bool $pluralKind = false; /** * The attributes. - * - * @var array */ - protected $attributes = []; + protected array $attributes = []; /** * The constructor. * - * @param mixed $attributes - * @param string $attributeType * @throws \InvalidArgumentException */ - public function __construct($attributes = [], $attributeType = 'array') + public function __construct(array $attributes = [], string $attributeType = 'array') { if ($attributeType == 'array') { if (is_array($attributes)) { @@ -80,21 +70,16 @@ public function __construct($attributes = [], $attributeType = 'array') /** * Get the model as an array. - * - * @return array */ - public function toArray() + public function toArray(): array { return $this->attributes; } /** * Get some metadata. - * - * @param string $key - * @return string */ - public function getMetadata($key) + public function getMetadata(string $key): ?string { return isset($this->attributes['metadata'][$key]) ? $this->attributes['metadata'][$key] : null; } @@ -102,11 +87,9 @@ public function getMetadata($key) /** * Get data ussing Json Path. * - * @param string $expression * @throws JSONPathException - * @return mixed */ - public function getJsonPath($expression) + public function getJsonPath(string $expression): JSONPath { $jsonPath = new JSONPath($this->attributes); @@ -115,10 +98,8 @@ public function getJsonPath($expression) /** * Get the schema. - * - * @return string */ - public function getSchema() + public function getSchema(): string { if (!isset($this->schema['kind'])) { $this->schema['kind'] = basename(str_replace('\\', '/', get_class($this))); @@ -143,28 +124,22 @@ public function getSchema() /** * Get the api version. - * - * @return string */ - public function getApiVersion() + public function getApiVersion(): string { return $this->apiVersion; } /** * Set the api version. - * - * @param string $apiVersion */ - public function setApiVersion($apiVersion) + public function setApiVersion(string $apiVersion): void { $this->apiVersion = $apiVersion; } /** * Get the model as a string. - * - * @return string */ public function __toString() { diff --git a/src/Models/NamespaceModel.php b/src/Models/NamespaceModel.php index ad0face..1379c57 100644 --- a/src/Models/NamespaceModel.php +++ b/src/Models/NamespaceModel.php @@ -4,8 +4,6 @@ class NamespaceModel extends Model { /** * The schema. - * - * @var array */ - protected $schema = ['kind' => 'Namespace']; + protected array $schema = ['kind' => 'Namespace']; } diff --git a/src/Models/NetworkPolicy.php b/src/Models/NetworkPolicy.php index 4b9e674..e7887fd 100644 --- a/src/Models/NetworkPolicy.php +++ b/src/Models/NetworkPolicy.php @@ -4,8 +4,6 @@ class NetworkPolicy extends Model { /** * The api version. - * - * @var string */ - protected $apiVersion = 'networking.k8s.io/v1'; + protected string $apiVersion = 'networking.k8s.io/v1'; } diff --git a/src/Models/ReplicaSet.php b/src/Models/ReplicaSet.php index 7ad8021..5e91add 100644 --- a/src/Models/ReplicaSet.php +++ b/src/Models/ReplicaSet.php @@ -4,8 +4,6 @@ class ReplicaSet extends Model { /** * The api version. - * - * @var string */ - protected $apiVersion = 'extensions/v1beta1'; + protected string $apiVersion = 'extensions/v1beta1'; } diff --git a/src/Repositories/CertificateRepository.php b/src/Repositories/CertificateRepository.php index 1491e70..f7b67ed 100644 --- a/src/Repositories/CertificateRepository.php +++ b/src/Repositories/CertificateRepository.php @@ -7,9 +7,9 @@ class CertificateRepository extends Repository { use PatchMergeTrait; - protected $uri = 'certificates'; + protected string $uri = 'certificates'; - protected function createCollection($response) + protected function createCollection($response): CertificateCollection { return new CertificateCollection($response['items']); } diff --git a/src/Repositories/ConfigMapRepository.php b/src/Repositories/ConfigMapRepository.php index 45b5cd0..32d2377 100644 --- a/src/Repositories/ConfigMapRepository.php +++ b/src/Repositories/ConfigMapRepository.php @@ -4,9 +4,9 @@ class ConfigMapRepository extends Repository { - protected $uri = 'configmaps'; + protected string $uri = 'configmaps'; - protected function createCollection($response) + protected function createCollection($response): ConfigMapCollection { return new ConfigMapCollection($response['items']); } diff --git a/src/Repositories/CronJobRepository.php b/src/Repositories/CronJobRepository.php index d372085..5c6750f 100644 --- a/src/Repositories/CronJobRepository.php +++ b/src/Repositories/CronJobRepository.php @@ -4,9 +4,9 @@ class CronJobRepository extends Repository { - protected $uri = 'cronjobs'; + protected string $uri = 'cronjobs'; - protected function createCollection($response) + protected function createCollection($response): CronJobCollection { return new CronJobCollection($response['items']); } diff --git a/src/Repositories/DaemonSetRepository.php b/src/Repositories/DaemonSetRepository.php index 6537d17..145b736 100644 --- a/src/Repositories/DaemonSetRepository.php +++ b/src/Repositories/DaemonSetRepository.php @@ -4,9 +4,9 @@ class DaemonSetRepository extends Repository { - protected $uri = 'daemonsets'; + protected string $uri = 'daemonsets'; - protected function createCollection($response) + protected function createCollection($response): DaemonSetCollection { return new DaemonSetCollection($response['items']); } diff --git a/src/Repositories/DeploymentRepository.php b/src/Repositories/DeploymentRepository.php index 5850304..a357168 100644 --- a/src/Repositories/DeploymentRepository.php +++ b/src/Repositories/DeploymentRepository.php @@ -4,9 +4,9 @@ class DeploymentRepository extends Repository { - protected $uri = 'deployments'; + protected string $uri = 'deployments'; - protected function createCollection($response) + protected function createCollection($response): DeploymentCollection { return new DeploymentCollection($response['items']); } diff --git a/src/Repositories/EndpointRepository.php b/src/Repositories/EndpointRepository.php index 36024cd..8e0b236 100644 --- a/src/Repositories/EndpointRepository.php +++ b/src/Repositories/EndpointRepository.php @@ -4,9 +4,9 @@ class EndpointRepository extends Repository { - protected $uri = 'endpoints'; + protected string $uri = 'endpoints'; - protected function createCollection($response) + protected function createCollection($response): EndpointCollection { return new EndpointCollection($response['items']); } diff --git a/src/Repositories/EventRepository.php b/src/Repositories/EventRepository.php index 995982c..2a78972 100644 --- a/src/Repositories/EventRepository.php +++ b/src/Repositories/EventRepository.php @@ -4,9 +4,9 @@ class EventRepository extends Repository { - protected $uri = 'events'; + protected string $uri = 'events'; - protected function createCollection($response) + protected function createCollection($response): EventCollection { return new EventCollection($response['items']); } diff --git a/src/Repositories/HorizontalPodAutoscalerRepository.php b/src/Repositories/HorizontalPodAutoscalerRepository.php index 97cdf15..a4aedd8 100644 --- a/src/Repositories/HorizontalPodAutoscalerRepository.php +++ b/src/Repositories/HorizontalPodAutoscalerRepository.php @@ -4,9 +4,9 @@ class HorizontalPodAutoscalerRepository extends Repository { - protected $uri = 'horizontalpodautoscalers'; + protected string $uri = 'horizontalpodautoscalers'; - protected function createCollection($response) + protected function createCollection($response): HorizontalPodAutoscalerCollection { return new HorizontalPodAutoscalerCollection($response['items']); } diff --git a/src/Repositories/IngressRepository.php b/src/Repositories/IngressRepository.php index d1b1821..5ab2b3c 100644 --- a/src/Repositories/IngressRepository.php +++ b/src/Repositories/IngressRepository.php @@ -4,9 +4,9 @@ class IngressRepository extends Repository { - protected $uri = 'ingresses'; + protected string $uri = 'ingresses'; - protected function createCollection($response) + protected function createCollection($response): IngressCollection { return new IngressCollection($response['items']); } diff --git a/src/Repositories/IssuerRepository.php b/src/Repositories/IssuerRepository.php index a2ba86b..a68145e 100644 --- a/src/Repositories/IssuerRepository.php +++ b/src/Repositories/IssuerRepository.php @@ -7,9 +7,9 @@ class IssuerRepository extends Repository { use PatchMergeTrait; - protected $uri = 'issuers'; + protected string $uri = 'issuers'; - protected function createCollection($response) + protected function createCollection($response): IssuerCollection { return new IssuerCollection($response['items']); } diff --git a/src/Repositories/JobRepository.php b/src/Repositories/JobRepository.php index d9eb9c5..3119f62 100644 --- a/src/Repositories/JobRepository.php +++ b/src/Repositories/JobRepository.php @@ -4,9 +4,9 @@ class JobRepository extends Repository { - protected $uri = 'jobs'; + protected string $uri = 'jobs'; - protected function createCollection($response) + protected function createCollection($response): JobCollection { return new JobCollection($response['items']); } diff --git a/src/Repositories/NamespaceRepository.php b/src/Repositories/NamespaceRepository.php index f0f9620..5eba8bc 100644 --- a/src/Repositories/NamespaceRepository.php +++ b/src/Repositories/NamespaceRepository.php @@ -4,10 +4,10 @@ class NamespaceRepository extends Repository { - protected $uri = 'namespaces'; - protected $namespace = false; + protected string $uri = 'namespaces'; + protected bool $namespace = false; - protected function createCollection($response) + protected function createCollection($response): NamespaceCollection { return new NamespaceCollection($response['items']); } diff --git a/src/Repositories/NetworkPolicyRepository.php b/src/Repositories/NetworkPolicyRepository.php index b0ab11d..a9baee6 100644 --- a/src/Repositories/NetworkPolicyRepository.php +++ b/src/Repositories/NetworkPolicyRepository.php @@ -4,9 +4,9 @@ class NetworkPolicyRepository extends Repository { - protected $uri = 'networkpolicies'; + protected string $uri = 'networkpolicies'; - protected function createCollection($response) + protected function createCollection($response): NetworkPolicyCollection { return new NetworkPolicyCollection($response['items']); } diff --git a/src/Repositories/NodeRepository.php b/src/Repositories/NodeRepository.php index aece3fa..ab88db4 100644 --- a/src/Repositories/NodeRepository.php +++ b/src/Repositories/NodeRepository.php @@ -1,18 +1,19 @@ client->sendRequest($method, '/' . $this->uri . '/' . $node->getMetadata('name') . '/proxy/' . $proxy_uri, $queryParams, [], $this->namespace); return $response; diff --git a/src/Repositories/PersistentVolumeClaimRepository.php b/src/Repositories/PersistentVolumeClaimRepository.php index 4a00f15..d54f056 100644 --- a/src/Repositories/PersistentVolumeClaimRepository.php +++ b/src/Repositories/PersistentVolumeClaimRepository.php @@ -4,9 +4,9 @@ class PersistentVolumeClaimRepository extends Repository { - protected $uri = 'persistentvolumeclaims'; + protected string $uri = 'persistentvolumeclaims'; - protected function createCollection($response) + protected function createCollection($response): PersistentVolumeClaimCollection { return new PersistentVolumeClaimCollection($response['items']); } diff --git a/src/Repositories/PersistentVolumeRepository.php b/src/Repositories/PersistentVolumeRepository.php index b4aa4cc..b0a40cc 100644 --- a/src/Repositories/PersistentVolumeRepository.php +++ b/src/Repositories/PersistentVolumeRepository.php @@ -5,12 +5,12 @@ class PersistentVolumeRepository extends Repository { - protected $uri = 'persistentvolumes'; + protected string $uri = 'persistentvolumes'; /** * @see \Maclof\Kubernetes\Repositories\Repository::createCollection() */ - protected function createCollection($response) + protected function createCollection($response): PersistentVolumeCollection { return new PersistentVolumeCollection($response['items']); } @@ -18,14 +18,10 @@ protected function createCollection($response) /** * Send a request. * - * @param string $method - * @param string $uri - * @param array $query - * @param mixed $body - * @param boolean $namespace - * @return array + * @param mixed $body + * @return mixed */ - protected function sendRequest($method, $uri, $query = [], $body = [], $namespace = false) + protected function sendRequest(string $method, string $uri, array $query = [], $body = [], bool $namespace = false, array $requestOptions = []) { $namespace = false; $apiVersion = $this->getApiVersion(); diff --git a/src/Repositories/PodRepository.php b/src/Repositories/PodRepository.php index 2c8d9a0..56f6ac6 100644 --- a/src/Repositories/PodRepository.php +++ b/src/Repositories/PodRepository.php @@ -5,21 +5,17 @@ class PodRepository extends Repository { - protected $uri = 'pods'; + protected string $uri = 'pods'; - protected function createCollection($response) + protected function createCollection($response): PodCollection { return new PodCollection($response['items']); } /** * Get the logs for a pod. - * - * @param \Maclof\Kubernetes\Models\Pod $pod - * @param array $queryParams - * @return string */ - public function logs(Pod $pod, array $queryParams = []) + public function logs(Pod $pod, array $queryParams = []): string { $response = $this->client->sendRequest('GET', '/' . $this->uri . '/' . $pod->getMetadata('name') . '/log', $queryParams); return $response; @@ -28,10 +24,9 @@ public function logs(Pod $pod, array $queryParams = []) /** * Execute a command on a pod. * - * @param \Maclof\Kubernetes\Models\Pod $pod - * @param array $queryParams * @return mixed */ + #[\ReturnTypeWillChange] public function exec(Pod $pod, array $queryParams = []) { $response = $this->client->sendRequest('POST', '/' . $this->uri . '/' . $pod->getMetadata('name') . '/exec', $queryParams); diff --git a/src/Repositories/QuotaRepository.php b/src/Repositories/QuotaRepository.php index 35cfaf1..2a471e2 100644 --- a/src/Repositories/QuotaRepository.php +++ b/src/Repositories/QuotaRepository.php @@ -4,10 +4,10 @@ class QuotaRepository extends Repository { - protected $uri = 'resourcequotas'; - protected $namespace = false; + protected string $uri = 'resourcequotas'; + protected bool $namespace = false; - protected function createCollection($response) + protected function createCollection($response): QuotaCollection { return new QuotaCollection($response['items']); } diff --git a/src/Repositories/ReplicaSetRepository.php b/src/Repositories/ReplicaSetRepository.php index a74a319..7fbacd2 100644 --- a/src/Repositories/ReplicaSetRepository.php +++ b/src/Repositories/ReplicaSetRepository.php @@ -4,9 +4,9 @@ class ReplicaSetRepository extends Repository { - protected $uri = 'replicasets'; + protected string $uri = 'replicasets'; - protected function createCollection($response) + protected function createCollection($response): ReplicaSetCollection { return new ReplicaSetCollection($response['items']); } diff --git a/src/Repositories/ReplicationControllerRepository.php b/src/Repositories/ReplicationControllerRepository.php index 3c16a18..06af100 100644 --- a/src/Repositories/ReplicationControllerRepository.php +++ b/src/Repositories/ReplicationControllerRepository.php @@ -4,9 +4,9 @@ class ReplicationControllerRepository extends Repository { - protected $uri = 'replicationcontrollers'; + protected string $uri = 'replicationcontrollers'; - protected function createCollection($response) + protected function createCollection($response): ReplicationControllerCollection { return new ReplicationControllerCollection($response['items']); } diff --git a/src/Repositories/Repository.php b/src/Repositories/Repository.php index 83c0b56..64c5096 100644 --- a/src/Repositories/Repository.php +++ b/src/Repositories/Repository.php @@ -1,6 +1,8 @@ client = $client; } @@ -78,15 +66,10 @@ public function __construct($client) /** * Send a request. * - * @param string $method - * @param string $uri - * @param array $query - * @param mixed $body - * @param boolean $namespace - * @param array $requestOptions - * @return array + * @param mixed $body + * @return mixed */ - protected function sendRequest($method, $uri, $query = [], $body = [], $namespace = true, array $requestOptions = []) + protected function sendRequest(string $method, string $uri, array $query = [], $body = [], bool $namespace = true, array $requestOptions = []) { $apiVersion = $this->getApiVersion(); if ($apiVersion === 'v1') { @@ -98,10 +81,8 @@ protected function sendRequest($method, $uri, $query = [], $body = [], $namespac /** * Get the api version from the model. - * - * @return string|null */ - protected function getApiVersion() + protected function getApiVersion(): ?string { if ($this->apiVersion) { return $this->apiVersion; @@ -121,64 +102,48 @@ protected function getApiVersion() /** * Create a new model. - * - * @param \Maclof\Kubernetes\Models\Model $model - * @return array */ - public function create(Model $model) + public function create(Model $model): array { - return $this->sendRequest('POST', '/' . $this->uri, null, $model->getSchema(), $this->namespace); + return $this->sendRequest('POST', '/' . $this->uri, [], $model->getSchema(), $this->namespace); } /** * Update a model. - * - * @param \Maclof\Kubernetes\Models\Model $model - * @return array */ - public function update(Model $model) + public function update(Model $model): array { - return $this->sendRequest('PUT', '/' . $this->uri . '/' . $model->getMetadata('name'), null, $model->getSchema(), $this->namespace); + return $this->sendRequest('PUT', '/' . $this->uri . '/' . $model->getMetadata('name'), [], $model->getSchema(), $this->namespace); } /** * Patch a model. - * - * @param \Maclof\Kubernetes\Models\Model $model - * @return array */ - public function patch(Model $model) + public function patch(Model $model): array { - return $this->sendRequest('PATCH', '/' . $this->uri . '/' . $model->getMetadata('name'), null, $model->getSchema(), $this->namespace); + return $this->sendRequest('PATCH', '/' . $this->uri . '/' . $model->getMetadata('name'), [], $model->getSchema(), $this->namespace); } /** * Apply a json patch to a model. - * - * @param \Maclof\Kubernetes\Models\Model $model - * @param array $model - * @return array */ - public function applyJsonPatch(Model $model, array $patch) + public function applyJsonPatch(Model $model, array $patch): array { $patch = json_encode($patch); $this->client->setPatchType('json'); - return $this->sendRequest('PATCH', '/' . $this->uri . '/' . $model->getMetadata('name'), null, $patch, $this->namespace); + return $this->sendRequest('PATCH', '/' . $this->uri . '/' . $model->getMetadata('name'), [], $patch, $this->namespace); } /** * Apply a model. * * Creates a new api object if not exists, or patch. - * - * @param \Maclof\Kubernetes\Models\Model $model - * @return array */ - public function apply(Model $model) + public function apply(Model $model): array { - $exists = $this->exists($model->getMetadata("name")); + $exists = $this->exists((string)$model->getMetadata("name")); if ($exists) { return $this->patch($model); @@ -189,38 +154,26 @@ public function apply(Model $model) /** * Delete a model. - * - * @param \Maclof\Kubernetes\Models\Model $model - * @param \Maclof\Kubernetes\Models\DeleteOptions $options - * @return array */ - public function delete(Model $model, DeleteOptions $options = null) + public function delete(Model $model, DeleteOptions $options = null): array { - return $this->deleteByName($model->getMetadata('name'), $options); + return $this->deleteByName((string)$model->getMetadata('name'), $options); } /** * Delete a model by name. - * - * @param string $name - * @param \Maclof\Kubernetes\Models\DeleteOptions $options - * @return array */ - public function deleteByName($name, DeleteOptions $options = null) + public function deleteByName(string $name, DeleteOptions $options = null): array { $body = $options ? $options->getSchema() : null; - return $this->sendRequest('DELETE', '/' . $this->uri . '/' . $name, null, $body, $this->namespace); + return $this->sendRequest('DELETE', '/' . $this->uri . '/' . $name, [], $body, $this->namespace); } /** * Set the label selector including inequality search terms. - * - * @param array $labelSelector - * @param array $inequalityLabelSelector - * @return \Maclof\Kubernetes\Repositories\Repository */ - public function setLabelSelector(array $labelSelector, array $inequalityLabelSelector=[]) + public function setLabelSelector(array $labelSelector, array $inequalityLabelSelector=[]): Repository { $this->labelSelector = $labelSelector; $this->inequalityLabelSelector = $inequalityLabelSelector; @@ -229,10 +182,8 @@ public function setLabelSelector(array $labelSelector, array $inequalityLabelSel /** * Get the label selector query. - * - * @return string */ - protected function getLabelSelectorQuery() + protected function getLabelSelectorQuery(): string { $parts = []; foreach ($this->labelSelector as $key => $value) { @@ -250,12 +201,8 @@ protected function getLabelSelectorQuery() /** * Set the field selector including inequality search terms. - * - * @param array $fieldSelector - * @param array $inequalityFieldSelector - * @return \Maclof\Kubernetes\Repositories\Repository */ - public function setFieldSelector(array $fieldSelector, array $inequalityFieldSelector=[]) + public function setFieldSelector(array $fieldSelector, array $inequalityFieldSelector=[]): Repository { $this->fieldSelector = $fieldSelector; $this->inequalityFieldSelector = $inequalityFieldSelector; @@ -264,10 +211,8 @@ public function setFieldSelector(array $fieldSelector, array $inequalityFieldSel /** * Get the field selector query. - * - * @return string */ - protected function getFieldSelectorQuery() + protected function getFieldSelectorQuery(): string { $parts = []; foreach ($this->fieldSelector as $key => $value) { @@ -286,10 +231,8 @@ protected function getFieldSelectorQuery() /** * Reset the parameters. - * - * @return void */ - protected function resetParameters() + protected function resetParameters(): void { $this->labelSelector = []; $this->fieldSelector = []; @@ -297,11 +240,8 @@ protected function resetParameters() /** * Get a collection of items. - * - * @param array $query - * @return mixed */ - public function find(array $query = []) + public function find(array $query = []): Collection { $query = array_filter(array_merge([ 'labelSelector' => $this->getLabelSelectorQuery(), @@ -319,23 +259,16 @@ public function find(array $query = []) /** * Find the first item. - * - * @return \Maclof\Kubernetes\Models\Model|null */ - public function first() + public function first(): ?Model { return $this->find()->first(); } /** * Watch a model for changes. - * - * @param \Maclof\Kubernetes\Models\Model $model - * @param \Closure $closure - * @param array $query - * @return void */ - public function watch(Model $model, Closure $closure, array $query = []) + public function watch(Model $model, Closure $closure, array $query = []): void { $this->setFieldSelector([ 'metadata.name' => $model->getMetadata('name'), @@ -365,11 +298,8 @@ public function watch(Model $model, Closure $closure, array $query = []) /** * Check if an item exists by name. - * - * @param string $name - * @return boolean */ - public function exists($name) + public function exists(string $name): bool { $this->resetParameters(); return !is_null($this->setFieldSelector(['metadata.name' => $name])->first()); @@ -377,9 +307,6 @@ public function exists($name) /** * Create a collection of models from the response. - * - * @param array $response - * @return \Maclof\Kubernetes\Collections\Collection */ - abstract protected function createCollection($response); + abstract protected function createCollection(array $response): Collection; } diff --git a/src/Repositories/SecretRepository.php b/src/Repositories/SecretRepository.php index 4f7fba3..4b3976d 100644 --- a/src/Repositories/SecretRepository.php +++ b/src/Repositories/SecretRepository.php @@ -4,9 +4,9 @@ class SecretRepository extends Repository { - protected $uri = 'secrets'; + protected string $uri = 'secrets'; - protected function createCollection($response) + protected function createCollection($response): SecretCollection { return new SecretCollection($response['items']); } diff --git a/src/Repositories/ServiceRepository.php b/src/Repositories/ServiceRepository.php index 265c906..c94c833 100644 --- a/src/Repositories/ServiceRepository.php +++ b/src/Repositories/ServiceRepository.php @@ -4,9 +4,9 @@ class ServiceRepository extends Repository { - protected $uri = 'services'; + protected string $uri = 'services'; - protected function createCollection($response) + protected function createCollection($response): ServiceCollection { return new ServiceCollection($response['items']); } diff --git a/src/Repositories/Strategy/PatchMergeTrait.php b/src/Repositories/Strategy/PatchMergeTrait.php index f031c33..b38735a 100644 --- a/src/Repositories/Strategy/PatchMergeTrait.php +++ b/src/Repositories/Strategy/PatchMergeTrait.php @@ -4,7 +4,7 @@ trait PatchMergeTrait { - public function patch(Model $model) + public function patch(Model $model): array { $this->client->setPatchType("merge"); diff --git a/src/Repositories/Utils/JSONStreamingListener.php b/src/Repositories/Utils/JSONStreamingListener.php index 4d69e67..9ed9eb2 100644 --- a/src/Repositories/Utils/JSONStreamingListener.php +++ b/src/Repositories/Utils/JSONStreamingListener.php @@ -6,50 +6,36 @@ class JSONStreamingListener { /** * The closure to call. - * - * @var \Closure */ - protected $closure; + protected Closure $closure; /** * The current depth within the JSON stream. - * - * @var int */ - protected $depth = 0; + protected int $depth = 0; /** * The current JSON object stack. - * - * @var array */ - protected $stack = []; + protected array $stack = []; /** * The current key for each depth. - * - * @var array */ - protected $keyByDepth = []; + protected array $keyByDepth = []; /** * The current position within the JSON stream. - * - * @var array */ - protected $breadcrumbs = []; + protected array $breadcrumbs = []; /** * The target containing the JSON objects. - * - * @var array */ - protected $target = []; + protected array $target = []; /** * The constructor. - * - * @param \Closure $closure */ public function __construct(Closure $closure) { @@ -58,9 +44,6 @@ public function __construct(Closure $closure) /** * Set the target from the given key - * - * @param string $key - * @return void */ public function setTargetFromKey(string $key) : self { @@ -72,8 +55,6 @@ public function setTargetFromKey(string $key) : self /** * Listen to the start of the document. - * - * @return void */ public function startDocument() : void { @@ -82,8 +63,6 @@ public function startDocument() : void /** * Listen to the end of the document. - * - * @return void */ public function endDocument() : void { @@ -95,8 +74,6 @@ public function endDocument() : void /** * Listen to the start of the object. - * - * @return void */ public function startObject() : void { @@ -111,8 +88,6 @@ public function startObject() : void /** * Determine whether the current object should be extracted - * - * @return bool */ protected function shouldBeExtracted() : bool { @@ -128,8 +103,6 @@ protected function shouldBeExtracted() : bool /** * Listen to the end of the object. - * - * @return void */ public function endObject() : void { @@ -156,8 +129,6 @@ public function endObject() : void /** * Determine whether the current object should be skipped - * - * @return bool */ protected function shouldBeSkipped() : bool { @@ -166,11 +137,8 @@ protected function shouldBeSkipped() : bool /** * Process the given extracted object. - * - * @param array $extractedObject - * @return void */ - protected function processExtractedObject(array $extractedObject) + protected function processExtractedObject(array $extractedObject): void { $type = isset($extractedObject['type']) ? $extractedObject['type'] : null; $object = isset($extractedObject['object']) ? $extractedObject['object'] : null; @@ -183,8 +151,6 @@ protected function processExtractedObject(array $extractedObject) /** * Listen to the start of the array. - * - * @return void */ public function startArray() : void { @@ -208,8 +174,6 @@ public function startArray() : void /** * Determine whether the current element is the target - * - * @return bool */ protected function isTarget() : bool { @@ -223,8 +187,6 @@ protected function isTarget() : bool /** * Listen to the end of the array. - * - * @return void */ public function endArray() : void { @@ -251,9 +213,6 @@ public function endArray() : void /** * Listen to the key. - * - * @param string $key - * @return void */ public function key(string $key) : void { @@ -270,7 +229,6 @@ public function key(string $key) : void * Listen to the value. * * @param mixed $value - * @return void */ public function value($value) : void { @@ -293,12 +251,9 @@ public function value($value) : void /** * Listen to the whitespace. - * - * @param string $whitespace - * @return void */ public function whitespace(string $whitespace) : void { // Ignore the whitespaces } -} \ No newline at end of file +} diff --git a/src/Repositories/Utils/JSONStreamingParser.php b/src/Repositories/Utils/JSONStreamingParser.php index 31ef0b8..41afabb 100644 --- a/src/Repositories/Utils/JSONStreamingParser.php +++ b/src/Repositories/Utils/JSONStreamingParser.php @@ -30,84 +30,44 @@ class JSONStreamingParser const UTF16_BOM = 2; const UTF32_BOM = 3; - /** - * @var int - */ - private $state; + private int $state; /** * @var int[] */ - private $stack = []; + private array $stack = []; - /** - * @var \GuzzleHttp\Psr7\Stream - */ - private $stream; + private Stream $stream; - /** - * @var bool - */ - private $emitWhitespace; + private JSONStreamingListener $listener; - /** - * @var string - */ - private $buffer = ''; + private bool $emitWhitespace; - /** - * @var int - */ - private $bufferSize; + private string $buffer = ''; + + private int $bufferSize; /** * @var string[] */ - private $unicodeBuffer = []; + private array $unicodeBuffer = []; - /** - * @var int - */ - private $unicodeHighSurrogate = -1; + private int $unicodeHighSurrogate = -1; - /** - * @var string - */ - private $unicodeEscapeBuffer = ''; + private string $unicodeEscapeBuffer = ''; - /** - * @var string - */ - private $lineEnding; + private string $lineEnding; - /** - * @var int - */ - private $lineNumber; + private int $lineNumber; - /** - * @var int - */ - private $charNumber; + private int $charNumber; - /** - * @var bool - */ - private $stopParsing = false; + private bool $stopParsing = false; - /** - * @var int - */ - private $utfBom = 0; + private int $utfBom = 0; /** * The constructor. - * - * @param \GuzzleHttp\Psr7\Stream $stream - * @param \Maclof\Kubernetes\Repositories\Utils\JSONStreamingListener $listener - * @param string $lineEnding - * @param bool|boolean $emitWhitespace - * @param int|integer $bufferSize */ public function __construct( Stream $stream, @@ -126,10 +86,8 @@ public function __construct( /** * Parse the stream. - * - * @return void */ - public function parse() + public function parse(): void { $this->lineNumber = 1; $this->charNumber = 1; @@ -151,12 +109,12 @@ public function parse() } } - public function stop() + public function stop(): void { $this->stopParsing = true; } - private function consumeChar(string $char) + private function consumeChar(string $char): void { // see https://en.wikipedia.org/wiki/Byte_order_mark if ($this->charNumber < 5 @@ -380,7 +338,7 @@ private function checkAndSkipUtfBom(string $c): bool /** * @throws ParsingException */ - private function startValue(string $c) + private function startValue(string $c): void { if ('[' === $c) { $this->startArray(); @@ -404,14 +362,14 @@ private function startValue(string $c) } } - private function startArray() + private function startArray(): void { $this->listener->startArray(); $this->state = self::STATE_IN_ARRAY; $this->stack[] = self::STACK_ARRAY; } - private function endArray() + private function endArray(): void { $popped = array_pop($this->stack); if (self::STACK_ARRAY !== $popped) { @@ -425,14 +383,14 @@ private function endArray() } } - private function startObject() + private function startObject(): void { $this->listener->startObject(); $this->state = self::STATE_IN_OBJECT; $this->stack[] = self::STACK_OBJECT; } - private function endObject() + private function endObject(): void { $popped = array_pop($this->stack); if (self::STACK_OBJECT !== $popped) { @@ -446,19 +404,19 @@ private function endObject() } } - private function startString() + private function startString(): void { $this->stack[] = self::STACK_STRING; $this->state = self::STATE_IN_STRING; } - private function startKey() + private function startKey(): void { $this->stack[] = self::STACK_KEY; $this->state = self::STATE_IN_STRING; } - private function endString() + private function endString(): void { $popped = array_pop($this->stack); if (self::STACK_KEY === $popped) { @@ -476,7 +434,7 @@ private function endString() /** * @throws ParsingException */ - private function processEscapeCharacter(string $c) + private function processEscapeCharacter(string $c): void { if ('"' === $c) { $this->buffer .= '"'; @@ -508,7 +466,7 @@ private function processEscapeCharacter(string $c) /** * @throws ParsingException */ - private function processUnicodeCharacter(string $char) + private function processUnicodeCharacter(string $char): void { if (!JSONStreamingParserHelper::isHexCharacter($char)) { $this->throwParseError( @@ -541,7 +499,7 @@ private function processUnicodeCharacter(string $char) } } - private function endUnicodeSurrogateInterstitial() + private function endUnicodeSurrogateInterstitial(): void { $unicodeEscape = $this->unicodeEscapeBuffer; if ('\\u' !== $unicodeEscape) { @@ -551,7 +509,7 @@ private function endUnicodeSurrogateInterstitial() $this->state = self::STATE_UNICODE; } - private function endUnicodeCharacter(int $codepoint) + private function endUnicodeCharacter(int $codepoint): void { $this->buffer .= JSONStreamingParserHelper::convertCodepointToCharacter($codepoint); $this->unicodeBuffer = []; @@ -559,35 +517,35 @@ private function endUnicodeCharacter(int $codepoint) $this->state = self::STATE_IN_STRING; } - private function startNumber(string $c) + private function startNumber(string $c): void { $this->state = self::STATE_IN_NUMBER; $this->buffer .= $c; } - private function endNumber() + private function endNumber(): void { $this->listener->value(JSONStreamingParserHelper::convertToNumber($this->buffer)); $this->buffer = ''; $this->state = self::STATE_AFTER_VALUE; } - private function endTrue() + private function endTrue(): void { $this->endSpecialValue(true, 'true'); } - private function endFalse() + private function endFalse(): void { $this->endSpecialValue(false, 'false'); } - private function endNull() + private function endNull(): void { $this->endSpecialValue(null, 'null'); } - private function endSpecialValue($value, string $stringValue) + private function endSpecialValue($value, string $stringValue): void { if ($this->buffer === $stringValue) { $this->listener->value($value); @@ -598,7 +556,7 @@ private function endSpecialValue($value, string $stringValue) $this->state = self::STATE_AFTER_VALUE; } - private function endDocument() + private function endDocument(): void { $this->listener->endDocument(); $this->state = self::STATE_END_DOCUMENT; @@ -607,8 +565,8 @@ private function endDocument() /** * @throws ParsingException */ - private function throwParseError(string $message) + private function throwParseError(string $message): void { throw new ParsingException($this->lineNumber, $this->charNumber, $message); } -} \ No newline at end of file +} diff --git a/src/RepositoryRegistry.php b/src/RepositoryRegistry.php index d6c8e74..f027792 100644 --- a/src/RepositoryRegistry.php +++ b/src/RepositoryRegistry.php @@ -4,9 +4,9 @@ class RepositoryRegistry implements \ArrayAccess, \Countable { /** - * @var array Initial registry class map. Contains only package builtin repositories. + * Initial registry class map. Contains only package builtin repositories. */ - protected $map = [ + protected array $map = [ 'nodes' => Repositories\NodeRepository::class, 'quotas' => Repositories\QuotaRepository::class, 'pods' => Repositories\PodRepository::class, @@ -51,27 +51,28 @@ public function __construct() } - public function offsetExists($method) + public function offsetExists($offset): bool { - return isset($this->map[$method]); + return isset($this->map[$offset]); } - public function offsetGet($method) + #[\ReturnTypeWillChange] + public function offsetGet($offset) { - return $this->map[$method]; + return $this->map[$offset]; } - public function offsetSet($method, $class) + public function offsetSet($offset, $value): void { - $this->map[$method] = $class; + $this->map[$offset] = $value; } - public function offsetUnset($method) + public function offsetUnset($offset): void { - unset($this->map[$method]); + unset($this->map[$offset]); } - public function count() + public function count(): int { return count($this->map); } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 3567bd3..dac02d5 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -10,7 +10,7 @@ class ClientTest extends TestCase { - public function testSendRequestJsonParsesResponse() + public function testSendRequestJsonParsesResponse(): void { $httpClientProp = new ReflectionProperty(Client::class, 'httpClient'); $httpClientProp->setAccessible(true); @@ -58,7 +58,7 @@ private function setMockHttpResponse( array $expectedSendArgs, int $respStatusCode = 200, array $respHeaders = [] - ) { + ): void { $httpClientProp = new ReflectionProperty(Client::class, 'httpClient'); $httpClientProp->setAccessible(true); @@ -78,7 +78,7 @@ private function setMockHttpResponse( $httpClientProp->setValue($client, $mockHttpMethodsClient); } - public function testGetPodsFromApi() + public function testGetPodsFromApi(): void { $client = new Client(); @@ -102,7 +102,7 @@ public function testGetPodsFromApi() $this->assertInstanceOf(Pod::class, $pod1); } - public function providerForFailedResponses() + public function providerForFailedResponses(): array { return [ [ @@ -126,7 +126,7 @@ public function providerForFailedResponses() /** * @dataProvider providerForFailedResponses */ - public function testExceptionIsThrownOnFailureResponse(int $respCode, string $exceptionClass, string $msgRegEx) + public function testExceptionIsThrownOnFailureResponse(int $respCode, string $exceptionClass, string $msgRegEx): void { $client = new Client(); diff --git a/tests/RepositoryRegistryTest.php b/tests/RepositoryRegistryTest.php index d963555..ba7f50f 100644 --- a/tests/RepositoryRegistryTest.php +++ b/tests/RepositoryRegistryTest.php @@ -5,14 +5,14 @@ class RepositoryRegistryTest extends TestCase { - public function test_builtin_repositories() + public function test_builtin_repositories(): void { $registry = new RepositoryRegistry(); $this->assertCount(22, $registry); } - public function test_add_repository() + public function test_add_repository(): void { $registry = new RepositoryRegistry(); $class = '\Example\Class'; diff --git a/tests/TestCase.php b/tests/TestCase.php index a30b8ae..e247d06 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,30 +6,23 @@ class TestCase extends PHPUnitTestCase { /** * The api version. - * - * @var string */ - protected $apiVersion = 'v1'; + protected string $apiVersion = 'v1'; /** * The namespace. - * - * @var string */ - protected $namespace = 'default'; + protected string $namespace = 'default'; /** * Get the contents of a fixture. - * - * @param string $path - * @return string|null */ - protected function getFixture($path) + protected function getFixture(string $path): ?string { $path = __DIR__ . '/fixtures/' . $path; if (!file_exists($path)) { - return; + return null; } $contents = file_get_contents($path); diff --git a/tests/collections/CertificateCollectionTest.php b/tests/collections/CertificateCollectionTest.php index 88cc475..24987ff 100644 --- a/tests/collections/CertificateCollectionTest.php +++ b/tests/collections/CertificateCollectionTest.php @@ -4,20 +4,20 @@ class CertificateCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getCertificateCollection() + protected function getCertificateCollection(): CertificateCollection { $configMapCollection = new CertificateCollection($this->items); return $configMapCollection; } - public function test_get_items() + public function test_get_items(): void { $certificateCollection = $this->getCertificateCollection(); $items = $certificateCollection->toArray(); diff --git a/tests/collections/ConfigMapCollectionTest.php b/tests/collections/ConfigMapCollectionTest.php index c1d1d0d..e389363 100644 --- a/tests/collections/ConfigMapCollectionTest.php +++ b/tests/collections/ConfigMapCollectionTest.php @@ -4,20 +4,20 @@ class ConfigMapCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getConfigMapCollection() + protected function getConfigMapCollection(): ConfigMapCollection { $configMapCollection = new ConfigMapCollection($this->items); return $configMapCollection; } - public function test_get_items() + public function test_get_items(): void { $configMapCollection = $this->getConfigMapCollection(); $items = $configMapCollection->toArray(); diff --git a/tests/collections/DeploymentCollectionTest.php b/tests/collections/DeploymentCollectionTest.php index 6ec3583..a70a4d1 100644 --- a/tests/collections/DeploymentCollectionTest.php +++ b/tests/collections/DeploymentCollectionTest.php @@ -4,20 +4,20 @@ class DeploymentCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getDeploymentCollection() + protected function getDeploymentCollection(): DeploymentCollection { $deploymentCollection = new DeploymentCollection($this->items); return $deploymentCollection; } - public function test_get_items() + public function test_get_items(): void { $deploymentCollection = $this->getDeploymentCollection(); $items = $deploymentCollection->toArray(); diff --git a/tests/collections/EndpointCollectionTest.php b/tests/collections/EndpointCollectionTest.php index 85875a5..43532ee 100644 --- a/tests/collections/EndpointCollectionTest.php +++ b/tests/collections/EndpointCollectionTest.php @@ -4,20 +4,20 @@ class EndpointCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getEndpointCollection() + protected function getEndpointCollection(): EndpointCollection { $nodeCollection = new EndpointCollection($this->items); return $nodeCollection; } - public function test_get_items() + public function test_get_items(): void { $nodeCollection = $this->getEndpointCollection(); $items = $nodeCollection->toArray(); diff --git a/tests/collections/EventCollectionTest.php b/tests/collections/EventCollectionTest.php index f3bf1b2..2ffa411 100644 --- a/tests/collections/EventCollectionTest.php +++ b/tests/collections/EventCollectionTest.php @@ -4,20 +4,20 @@ class EventCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getEventCollection() + protected function getEventCollection(): EventCollection { $eventCollection = new EventCollection($this->items); return $eventCollection; } - public function test_get_items() + public function test_get_items(): void { $eventCollection = $this->getEventCollection(); $items = $eventCollection->toArray(); diff --git a/tests/collections/IngressCollectionTest.php b/tests/collections/IngressCollectionTest.php index 885352d..f1cdfa3 100644 --- a/tests/collections/IngressCollectionTest.php +++ b/tests/collections/IngressCollectionTest.php @@ -4,20 +4,20 @@ class IngressCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getIngressCollection() + protected function getIngressCollection(): IngressCollection { $ingressCollection = new IngressCollection($this->items); return $ingressCollection; } - public function test_get_items() + public function test_get_items(): void { $ingressCollection = $this->getIngressCollection(); $items = $ingressCollection->toArray(); diff --git a/tests/collections/IssuerCollectionTest.php b/tests/collections/IssuerCollectionTest.php index 0b8a727..fb06cf7 100644 --- a/tests/collections/IssuerCollectionTest.php +++ b/tests/collections/IssuerCollectionTest.php @@ -4,20 +4,20 @@ class IssuerCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getIssuerCollection() + protected function getIssuerCollection(): IssuerCollection { $issuerCollection = new IssuerCollection($this->items); return $issuerCollection; } - public function test_get_items() + public function test_get_items(): void { $issuerCollection = $this->getIssuerCollection(); $items = $issuerCollection->toArray(); diff --git a/tests/collections/JobCollectionTest.php b/tests/collections/JobCollectionTest.php index 895aac1..125c321 100644 --- a/tests/collections/JobCollectionTest.php +++ b/tests/collections/JobCollectionTest.php @@ -4,20 +4,20 @@ class JobCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getJobCollection() + protected function getJobCollection(): JobCollection { $jobCollection = new JobCollection($this->items); return $jobCollection; } - public function test_get_items() + public function test_get_items(): void { $jobCollection = $this->getJobCollection(); $items = $jobCollection->toArray(); diff --git a/tests/collections/NamespaceCollectionTest.php b/tests/collections/NamespaceCollectionTest.php index ed35907..73b1704 100644 --- a/tests/collections/NamespaceCollectionTest.php +++ b/tests/collections/NamespaceCollectionTest.php @@ -4,20 +4,20 @@ class NamespaceCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getNamespaceCollection() + protected function getNamespaceCollection(): NamespaceCollection { $namespaceCollection = new NamespaceCollection($this->items); return $namespaceCollection; } - public function test_get_items() + public function test_get_items(): void { $namespaceCollection = $this->getNamespaceCollection(); $items = $namespaceCollection->toArray(); diff --git a/tests/collections/NetworkPolicyCollectionTest.php b/tests/collections/NetworkPolicyCollectionTest.php index 094ad87..d195a75 100644 --- a/tests/collections/NetworkPolicyCollectionTest.php +++ b/tests/collections/NetworkPolicyCollectionTest.php @@ -4,20 +4,20 @@ class NetworkPolicyCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getNetworkPolicyCollection() + protected function getNetworkPolicyCollection(): NetworkPolicyCollection { $podCollection = new NetworkPolicyCollection($this->items); return $podCollection; } - public function test_get_items() + public function test_get_items(): void { $podCollection = $this->getNetworkPolicyCollection(); $items = $podCollection->toArray(); diff --git a/tests/collections/NodeCollectionTest.php b/tests/collections/NodeCollectionTest.php index 5d08f95..42d2fb4 100644 --- a/tests/collections/NodeCollectionTest.php +++ b/tests/collections/NodeCollectionTest.php @@ -4,20 +4,20 @@ class NodeCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getNodeCollection() + protected function getNodeCollection(): NodeCollection { $nodeCollection = new NodeCollection($this->items); return $nodeCollection; } - public function test_get_items() + public function test_get_items(): void { $nodeCollection = $this->getNodeCollection(); $items = $nodeCollection->toArray(); diff --git a/tests/collections/PodCollectionTest.php b/tests/collections/PodCollectionTest.php index 9b28043..ab20785 100644 --- a/tests/collections/PodCollectionTest.php +++ b/tests/collections/PodCollectionTest.php @@ -4,20 +4,20 @@ class PodCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getPodCollection() + protected function getPodCollection(): PodCollection { $podCollection = new PodCollection($this->items); return $podCollection; } - public function test_get_items() + public function test_get_items(): void { $podCollection = $this->getPodCollection(); $items = $podCollection->toArray(); diff --git a/tests/collections/ReplicaSetCollectionTest.php b/tests/collections/ReplicaSetCollectionTest.php index ebb249f..955f1bb 100644 --- a/tests/collections/ReplicaSetCollectionTest.php +++ b/tests/collections/ReplicaSetCollectionTest.php @@ -4,20 +4,20 @@ class ReplicaSetCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getReplicaSetCollection() + protected function getReplicaSetCollection(): ReplicaSetCollection { $replicaSetCollection = new ReplicaSetCollection($this->items); return $replicaSetCollection; } - public function test_get_items() + public function test_get_items(): void { $replicaSetCollection = $this->getReplicaSetCollection(); $items = $replicaSetCollection->toArray(); diff --git a/tests/collections/ReplicationControllerCollectionTest.php b/tests/collections/ReplicationControllerCollectionTest.php index 298658d..8c59fc0 100644 --- a/tests/collections/ReplicationControllerCollectionTest.php +++ b/tests/collections/ReplicationControllerCollectionTest.php @@ -4,20 +4,20 @@ class ReplicationControllerCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getReplicationControllerCollection() + protected function getReplicationControllerCollection(): ReplicationControllerCollection { $replicationControllerCollection = new ReplicationControllerCollection($this->items); return $replicationControllerCollection; } - public function test_get_items() + public function test_get_items(): void { $replicationControllerCollection = $this->getReplicationControllerCollection(); $items = $replicationControllerCollection->toArray(); diff --git a/tests/collections/SecretCollectionTest.php b/tests/collections/SecretCollectionTest.php index 9a0d7df..7cfbf98 100644 --- a/tests/collections/SecretCollectionTest.php +++ b/tests/collections/SecretCollectionTest.php @@ -4,20 +4,20 @@ class SecretCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getSecretCollection() + protected function getSecretCollection(): SecretCollection { $secretCollection = new SecretCollection($this->items); return $secretCollection; } - public function test_get_items() + public function test_get_items(): void { $secretCollection = $this->getSecretCollection(); $items = $secretCollection->toArray(); diff --git a/tests/collections/ServiceCollectionTest.php b/tests/collections/ServiceCollectionTest.php index cc5088e..809edba 100644 --- a/tests/collections/ServiceCollectionTest.php +++ b/tests/collections/ServiceCollectionTest.php @@ -4,20 +4,20 @@ class ServiceCollectionTest extends TestCase { - protected $items = [ + protected array $items = [ [], [], [], ]; - protected function getServiceCollection() + protected function getServiceCollection(): ServiceCollection { $serviceCollection = new ServiceCollection($this->items); return $serviceCollection; } - public function test_get_items() + public function test_get_items(): void { $serviceCollection = $this->getServiceCollection(); $items = $serviceCollection->toArray(); diff --git a/tests/models/CertificateTest.php b/tests/models/CertificateTest.php index f724825..5a1fd01 100644 --- a/tests/models/CertificateTest.php +++ b/tests/models/CertificateTest.php @@ -4,7 +4,7 @@ class CertificateTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $certificate = new Certificate; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($fixture, $schema); } - public function test_get_metadata() + public function test_get_metadata(): void { $certificate = new Certificate([ 'metadata' => [ diff --git a/tests/models/ConfigMapTest.php b/tests/models/ConfigMapTest.php index 99a5abb..82c1d10 100644 --- a/tests/models/ConfigMapTest.php +++ b/tests/models/ConfigMapTest.php @@ -4,7 +4,7 @@ class ConfigMapTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $configMap = new ConfigMap; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $configMap = new ConfigMap([ 'metadata' => [ diff --git a/tests/models/CronJobTest.php b/tests/models/CronJobTest.php index 2f3bf27..2fd77ea 100644 --- a/tests/models/CronJobTest.php +++ b/tests/models/CronJobTest.php @@ -4,7 +4,7 @@ class CronJobTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $cronJob = new CronJob; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $cronJob = new CronJob([ 'metadata' => [ @@ -27,7 +27,7 @@ public function test_get_metadata() $this->assertEquals($metadata, 'test'); } - public function test_set_api_version() + public function test_set_api_version(): void { $cronJob = new CronJob; diff --git a/tests/models/DeploymentTest.php b/tests/models/DeploymentTest.php index 38b9191..146617e 100644 --- a/tests/models/DeploymentTest.php +++ b/tests/models/DeploymentTest.php @@ -4,7 +4,7 @@ class DeploymentTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $deployment = new Deployment; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $deployment = new Deployment([ 'metadata' => [ diff --git a/tests/models/EndpointTest.php b/tests/models/EndpointTest.php index 59d1896..c802bce 100644 --- a/tests/models/EndpointTest.php +++ b/tests/models/EndpointTest.php @@ -4,7 +4,7 @@ class EndpointTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $node = new Endpoint; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $node = new Endpoint([ 'metadata' => [ diff --git a/tests/models/EventTest.php b/tests/models/EventTest.php index 222a38c..2deeaba 100644 --- a/tests/models/EventTest.php +++ b/tests/models/EventTest.php @@ -4,7 +4,7 @@ class EventTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $event = new Event; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $event = new Event([ 'metadata' => [ diff --git a/tests/models/IngressTest.php b/tests/models/IngressTest.php index 9edcb38..1e9b7e0 100644 --- a/tests/models/IngressTest.php +++ b/tests/models/IngressTest.php @@ -4,7 +4,7 @@ class IngressTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $ingress = new Ingress; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $ingress = new Ingress([ 'metadata' => [ diff --git a/tests/models/IssuerTest.php b/tests/models/IssuerTest.php index ffca792..3344848 100644 --- a/tests/models/IssuerTest.php +++ b/tests/models/IssuerTest.php @@ -4,7 +4,7 @@ class IssuerTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $issuer = new Issuer; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($fixture, $schema); } - public function test_get_metadata() + public function test_get_metadata(): void { $issuer = new Issuer([ 'metadata' => [ diff --git a/tests/models/JobTest.php b/tests/models/JobTest.php index 8d00af7..b47fd22 100644 --- a/tests/models/JobTest.php +++ b/tests/models/JobTest.php @@ -4,7 +4,7 @@ class JobTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $job = new Job; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $job = new Job([ 'metadata' => [ diff --git a/tests/models/ModelTest.php b/tests/models/ModelTest.php index 58af503..849f745 100644 --- a/tests/models/ModelTest.php +++ b/tests/models/ModelTest.php @@ -7,7 +7,7 @@ class ModelTest extends TestCase { - public function testGetJsonPath() + public function testGetJsonPath(): void { $expected = 'foo'; @@ -20,7 +20,7 @@ public function testGetJsonPath() $this->assertEquals($expected, $actual[0]); } - public function testIsGettingSchema() + public function testIsGettingSchema(): void { $expected = json_encode([ 'kind' => 'ConcreteModel', @@ -35,7 +35,7 @@ public function testIsGettingSchema() $this->assertEquals($expected, $actual); } - public function testGetApiVersion() + public function testGetApiVersion(): void { $expected = 'v1'; @@ -46,7 +46,7 @@ public function testGetApiVersion() $this->assertEquals($expected, $actual); } - public function testGetMetadata() + public function testGetMetadata(): void { $expected = 'foo'; @@ -57,7 +57,7 @@ public function testGetMetadata() $this->assertEquals($expected, $actual); } - public function testIsConvertingToArray() + public function testIsConvertingToArray(): void { $expected = ['foo' => 'bar']; @@ -69,7 +69,7 @@ public function testIsConvertingToArray() } - public function testIsReturningSchemaOnToStringCall() + public function testIsReturningSchemaOnToStringCall(): void { $model = new ConcreteModel(); @@ -79,4 +79,4 @@ public function testIsReturningSchemaOnToStringCall() } } -class ConcreteModel extends Model {} \ No newline at end of file +class ConcreteModel extends Model {} diff --git a/tests/models/NamespaceTest.php b/tests/models/NamespaceTest.php index 1437573..f65096a 100644 --- a/tests/models/NamespaceTest.php +++ b/tests/models/NamespaceTest.php @@ -4,7 +4,7 @@ class NamespaceTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $namespace = new NamespaceModel; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $node = new NamespaceModel([ 'metadata' => [ diff --git a/tests/models/NetworkPolicyTest.php b/tests/models/NetworkPolicyTest.php index eb0a1ee..c6fb48e 100644 --- a/tests/models/NetworkPolicyTest.php +++ b/tests/models/NetworkPolicyTest.php @@ -4,7 +4,7 @@ class NetworkPolicyTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $policy = new NetworkPolicy(); @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $policy = new NetworkPolicy([ 'metadata' => [ diff --git a/tests/models/NodeTest.php b/tests/models/NodeTest.php index b37dc79..3988739 100644 --- a/tests/models/NodeTest.php +++ b/tests/models/NodeTest.php @@ -4,7 +4,7 @@ class NodeTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $node = new Node; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $node = new Node([ 'metadata' => [ diff --git a/tests/models/PodTest.php b/tests/models/PodTest.php index fc60fef..5488bd8 100644 --- a/tests/models/PodTest.php +++ b/tests/models/PodTest.php @@ -4,7 +4,7 @@ class PodTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $pod = new Pod; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $pod = new Pod([ 'metadata' => [ @@ -26,4 +26,4 @@ public function test_get_metadata() $this->assertEquals($metadata, 'test'); } -} \ No newline at end of file +} diff --git a/tests/models/ReplicaSetTest.php b/tests/models/ReplicaSetTest.php index dcb6eb1..abeced7 100644 --- a/tests/models/ReplicaSetTest.php +++ b/tests/models/ReplicaSetTest.php @@ -4,7 +4,7 @@ class ReplicaSetTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $replicaSet = new ReplicaSet; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $replicaSet = new ReplicaSet([ 'metadata' => [ diff --git a/tests/models/ReplicationControllerTest.php b/tests/models/ReplicationControllerTest.php index d46cf08..20a0b06 100644 --- a/tests/models/ReplicationControllerTest.php +++ b/tests/models/ReplicationControllerTest.php @@ -4,7 +4,7 @@ class ReplicationControllerTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $replicationController = new ReplicationController; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $replicationController = new ReplicationController([ 'metadata' => [ @@ -26,4 +26,4 @@ public function test_get_metadata() $this->assertEquals($metadata, 'test'); } -} \ No newline at end of file +} diff --git a/tests/models/SecretTest.php b/tests/models/SecretTest.php index 95a18eb..8ad472a 100644 --- a/tests/models/SecretTest.php +++ b/tests/models/SecretTest.php @@ -4,7 +4,7 @@ class SecretTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $secret = new Secret; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $secret = new Secret([ 'metadata' => [ diff --git a/tests/models/ServiceTest.php b/tests/models/ServiceTest.php index 7020f6b..46850bb 100644 --- a/tests/models/ServiceTest.php +++ b/tests/models/ServiceTest.php @@ -4,7 +4,7 @@ class ServiceTest extends TestCase { - public function test_get_schema() + public function test_get_schema(): void { $service = new Service; @@ -14,7 +14,7 @@ public function test_get_schema() $this->assertEquals($schema, $fixture); } - public function test_get_metadata() + public function test_get_metadata(): void { $service = new Service([ 'metadata' => [ @@ -26,4 +26,4 @@ public function test_get_metadata() $this->assertEquals($metadata, 'test'); } -} \ No newline at end of file +}