diff options
author | Derick Alangi <alangiderick@gmail.com> | 2024-11-07 19:30:11 +0300 |
---|---|---|
committer | Cwhite <cwhite@wikimedia.org> | 2024-11-08 17:55:52 +0000 |
commit | 2b71bd066695de59c9799d9d0e369e50625c0d46 (patch) | |
tree | 0eb816612d588a897c412b50d5327d341a4bcd67 /includes/libs | |
parent | 22a7070df9c042acad69026908ae12eafe974e93 (diff) | |
download | mediawikicore-2b71bd066695de59c9799d9d0e369e50625c0d46.tar.gz mediawikicore-2b71bd066695de59c9799d9d0e369e50625c0d46.zip |
Stats: Remove redundant docs, remove unused method
This patch does some cosmetic changes to the Stats library like:
- Remove some redundant class properties doc especially when file
is in strict type mode
- Cleanup class level doc that adds little meaning to what the class
already does
- Remove unused `mergeLabels()` method. This can be directly removed
without deprecation, as the feature ended up never being used in
the first place and it's only here because during the efforts in
I60c497727fdae493c3bb18de3bd1a4db338132cc, we forgot to remove this
particular method.
This patch also fixes a phan issue that detected that `getMetric()`
in StatsFactory class calls BaseMetric::withStatsdDataFactory() with
a null because the member's default value is null but doesn't say
this in the BaseMetricInterface, this fixes it.
Change-Id: Id9fbdeed3e8cd9ddd9e48031139b4f31c40c2558
Diffstat (limited to 'includes/libs')
-rw-r--r-- | includes/libs/Stats/Metrics/BaseMetricInterface.php | 5 | ||||
-rw-r--r-- | includes/libs/Stats/Sample.php | 4 | ||||
-rw-r--r-- | includes/libs/Stats/StatsFactory.php | 13 | ||||
-rw-r--r-- | includes/libs/Stats/StatsUtils.php | 24 |
4 files changed, 4 insertions, 42 deletions
diff --git a/includes/libs/Stats/Metrics/BaseMetricInterface.php b/includes/libs/Stats/Metrics/BaseMetricInterface.php index f3113619e76a..611f54d1c1e6 100644 --- a/includes/libs/Stats/Metrics/BaseMetricInterface.php +++ b/includes/libs/Stats/Metrics/BaseMetricInterface.php @@ -156,8 +156,9 @@ interface BaseMetricInterface { /** * StatsD Data Factory instance to copy metrics to. * - * @param IBufferingStatsdDataFactory $statsdDataFactory + * @param IBufferingStatsdDataFactory|null $statsdDataFactory + * * @return BaseMetricInterface */ - public function withStatsdDataFactory( IBufferingStatsdDataFactory $statsdDataFactory ); + public function withStatsdDataFactory( ?IBufferingStatsdDataFactory $statsdDataFactory ); } diff --git a/includes/libs/Stats/Sample.php b/includes/libs/Stats/Sample.php index 9796882a1d22..5ce07f1285db 100644 --- a/includes/libs/Stats/Sample.php +++ b/includes/libs/Stats/Sample.php @@ -22,8 +22,6 @@ declare( strict_types=1 ); namespace Wikimedia\Stats; /** - * Sample Data Class - * * A container for a metric sample to be passed to the rendering function. * * @author Cole White @@ -33,8 +31,6 @@ class Sample { /** @var string[] */ private array $labelValues; - - /** @var float */ private float $value; /** diff --git a/includes/libs/Stats/StatsFactory.php b/includes/libs/Stats/StatsFactory.php index 7e09ca9d63de..b24d540fe86d 100644 --- a/includes/libs/Stats/StatsFactory.php +++ b/includes/libs/Stats/StatsFactory.php @@ -35,9 +35,7 @@ use Wikimedia\Stats\Metrics\NullMetric; use Wikimedia\Stats\Metrics\TimingMetric; /** - * StatsFactory Implementation - * - * This is the primary interface for validating metrics definitions + * This is the primary interface for validating metrics definitions, * caching defined metrics, and returning metric instances from cache * if previously defined. * @@ -46,19 +44,10 @@ use Wikimedia\Stats\Metrics\TimingMetric; */ class StatsFactory { - /** @var string */ private string $component; - - /** @var StatsCache */ private StatsCache $cache; - - /** @var EmitterInterface */ private EmitterInterface $emitter; - - /** @var LoggerInterface */ private LoggerInterface $logger; - - /** @var IBufferingStatsdDataFactory|null */ private ?IBufferingStatsdDataFactory $statsdDataFactory = null; /** diff --git a/includes/libs/Stats/StatsUtils.php b/includes/libs/Stats/StatsUtils.php index 7d0ec292b1fd..7ecbcef8d36a 100644 --- a/includes/libs/Stats/StatsUtils.php +++ b/includes/libs/Stats/StatsUtils.php @@ -25,9 +25,6 @@ use InvalidArgumentException; use Wikimedia\Stats\Exceptions\InvalidConfigurationException; /** - * - * StatsUtils Implementation - * * Functionality common to all metric types. * * @author Cole White @@ -112,27 +109,6 @@ class StatsUtils { } /** - * Merges two associative arrays of labels. Prioritizes leftmost labels. - * - * @param array $leftLabels - * @param array $rightLabels - * @return array - */ - public static function mergeLabels( array $leftLabels, array $rightLabels ): array { - $output = []; - foreach ( $leftLabels as $key => $value ) { - $output[$key] = $value; - } - foreach ( $rightLabels as $key => $value ) { - if ( array_key_exists( $key, $output ) ) { - continue; - } - $output[$key] = $value; - } - return $output; - } - - /** * Normalize an array of strings. * * @param string[] $entities |