Skip to content

Commit

Permalink
Add (strict) typing
Browse files Browse the repository at this point in the history
  • Loading branch information
kdambekalns committed Dec 1, 2021
1 parent da63e06 commit 28a11aa
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 41 deletions.
9 changes: 5 additions & 4 deletions Classes/Collector/AbstractCollector.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace Flownative\Prometheus\Collector;

/*
Expand All @@ -14,22 +15,22 @@ abstract class AbstractCollector
/**
* @var StorageInterface
*/
protected $storage;
protected StorageInterface $storage;

/**
* @var string
*/
protected $name;
protected string $name;

/**
* @var string
*/
protected $help = '';
protected string $help = '';

/**
* @var array
*/
protected $labels = [];
protected array $labels = [];

/**
* @param StorageInterface $storage
Expand Down
1 change: 1 addition & 0 deletions Classes/Collector/Counter.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace Flownative\Prometheus\Collector;

/*
Expand Down
1 change: 1 addition & 0 deletions Classes/Collector/Gauge.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace Flownative\Prometheus\Collector;

/*
Expand Down
6 changes: 3 additions & 3 deletions Classes/CollectorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ class CollectorRegistry
/**
* @var StorageInterface
*/
protected $storage;
protected StorageInterface $storage;

/**
* @var array
*/
protected $counters = [];
protected array $counters = [];

/**
* @var array
*/
protected $gauges = [];
protected array $gauges = [];

/**
* @param StorageInterface $storage
Expand Down
7 changes: 4 additions & 3 deletions Classes/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace Flownative\Prometheus;

/*
Expand All @@ -16,17 +17,17 @@ class Configuration
/**
* @var string
*/
protected $type;
protected string $type;

/**
* @var string
*/
protected $help = '';
protected string $help = '';

/**
* @var array
*/
protected $labels = [];
protected array $labels = [];

/**
* @param string $type
Expand Down
2 changes: 1 addition & 1 deletion Classes/DefaultCollectorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class DefaultCollectorRegistry extends CollectorRegistry
* @Flow\InjectConfiguration(path="metrics")
* @var array
*/
protected $settings;
protected array $settings = [];

/**
* @throws Exception\InvalidCollectorTypeException
Expand Down
8 changes: 4 additions & 4 deletions Classes/Http/MetricsExporterMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ class MetricsExporterMiddleware implements MiddlewareInterface
/**
* @var CollectorRegistry
*/
protected $collectorRegistry;
protected CollectorRegistry $collectorRegistry;

/**
* @var LoggerInterface
* @var LoggerInterface|null
*/
protected $logger;
protected ?LoggerInterface $logger = null;

/**
* @var array
*/
protected $options = [
protected array $options = [
'telemetryPath' => '/metrics',
'basicAuth' => []
];
Expand Down
1 change: 1 addition & 0 deletions Classes/Renderer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace Flownative\Prometheus;

/*
Expand Down
5 changes: 3 additions & 2 deletions Classes/Sample.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace Flownative\Prometheus;

/*
Expand All @@ -12,12 +13,12 @@ class Sample
/**
* @var string
*/
private $name;
private string $name;

/**
* @var array
*/
private $labels;
private array $labels;

/**
* @var int|float
Expand Down
11 changes: 6 additions & 5 deletions Classes/SampleCollection.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace Flownative\Prometheus;

/*
Expand All @@ -12,27 +13,27 @@ class SampleCollection
/**
* @var string
*/
private $name;
private string $name;

/**
* @var string
*/
private $type;
private string $type;

/**
* @var string
*/
private $help;
private string $help;

/**
* @var array
*/
private $labels;
private array $labels;

/**
* @var Sample[]
*/
private $samples = [];
private array $samples;

/**
* @param string $name
Expand Down
4 changes: 2 additions & 2 deletions Classes/Storage/CounterUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CounterUpdate
*
* @var string
*/
private $operation;
private string $operation;

/**
* A positive number
Expand All @@ -27,7 +27,7 @@ class CounterUpdate
/**
* @var array
*/
private $labels;
private array $labels;

/**
* @param string $operation
Expand Down
4 changes: 2 additions & 2 deletions Classes/Storage/GaugeUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GaugeUpdate
*
* @var string
*/
private $operation;
private string $operation;

/**
* A positive number
Expand All @@ -27,7 +27,7 @@ class GaugeUpdate
/**
* @var array
*/
private $labels;
private array $labels;

/**
* @param string $operation
Expand Down
4 changes: 2 additions & 2 deletions Classes/Storage/InMemoryStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class InMemoryStorage extends AbstractStorage
/**
* @var array
*/
private $countersData = [];
private array $countersData = [];

/**
* @var array
*/
private $gaugesData = [];
private array $gaugesData = [];

/**
* @return SampleCollection[]
Expand Down
22 changes: 11 additions & 11 deletions Classes/Storage/RedisStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,57 +31,57 @@ class RedisStorage extends AbstractStorage
/**
* @var Counter[]
*/
protected $counters;
protected array $counters = [];

/**
* @var Gauge[]
*/
protected $gauges;
protected array $gauges = [];

/**
* @var Predis\Client
*/
protected $redis;
protected Predis\Client $redis;

/**
* @var string
*/
protected $hostname = '127.0.0.1';
protected string $hostname = '127.0.0.1';

/**
* @var int
*/
protected $port = 6379;
protected int $port = 6379;

/**
* @var array
*/
protected $sentinels = [];
protected array $sentinels = [];

/**
* @var string
*/
protected $service = 'mymaster';
protected string $service = 'mymaster';

/**
* @var int
*/
protected $database = 0;
protected int $database = 0;

/**
* @var string
*/
protected $password = '';
protected string $password = '';

/**
* @var string
*/
protected $keyPrefix = 'flownative_prometheus';
protected string $keyPrefix = 'flownative_prometheus';

/**
* @var bool
*/
protected $ignoreConnectionErrors = false;
protected bool $ignoreConnectionErrors = false;

/**
* @param array $options
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Http/DummyRequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DummyRequestHandler implements RequestHandlerInterface
/**
* @var bool
*/
protected $handleCalled = false;
protected bool $handleCalled = false;

/**
* @param ServerRequestInterface $request
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Storage/AbstractStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class AbstractStorageTest extends UnitTestCase
/**
* @var StorageInterface
*/
protected $storage;
protected StorageInterface $storage;

/**
* @test
Expand Down

0 comments on commit 28a11aa

Please sign in to comment.