diff --git a/phpstan.neon b/phpstan.neon index 7ee3062..69bdbb4 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,30 @@ parameters: - level: 3 + level: 5 + treatPhpDocTypesAsCertain: false paths: - src - tests + ignoreErrors: + - + message: '#^Call to function is_array\(\) with mixed will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: src/Bucketer.php + + - + message: '#^Offset ''or'' on \*NEVER\* in isset\(\) always exists and is not nullable\.$#' + identifier: isset.offset + count: 1 + path: src/Bucketer.php + + - + message: '#^Strict comparison using \!\=\= between mixed and null will always evaluate to true\.$#' + identifier: notIdentical.alwaysTrue + count: 1 + path: src/EvaluateSticky.php + + - + message: '#^Call to function method_exists\(\) with Featurevisor\\Featurevisor and ''getVariation'' will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: tests/FeaturevisorTest.php diff --git a/src/CompareVersions.php b/src/CompareVersions.php index a362eca..b185dd0 100644 --- a/src/CompareVersions.php +++ b/src/CompareVersions.php @@ -32,10 +32,6 @@ public static function compare(string $v1, string $v2): int private static function validateAndParse(string $version): array { - if (!is_string($version)) { - throw new \TypeError('Invalid argument expected string'); - } - if (!preg_match(self::$semver, $version, $match)) { throw new \Exception("Invalid argument not valid semver ('$version' received)"); } diff --git a/src/Featurevisor.php b/src/Featurevisor.php index d58ae9e..151e869 100644 --- a/src/Featurevisor.php +++ b/src/Featurevisor.php @@ -23,10 +23,10 @@ class Featurevisor * sticky?: array, * hooks?: array * } $options * @return self @@ -560,20 +560,18 @@ public function getAllEvaluations(array $context = [], array $featureKeys = [], 'flagEvaluation' => $flagEvaluation, ]); // variation - if (method_exists($this->datafileReader, 'hasVariations') && $this->datafileReader->hasVariations($featureKey)) { + if ($this->datafileReader->hasVariations($featureKey)) { $variation = $this->getVariation($featureKey, $context, $opts); if ($variation !== null) { $evaluatedFeature['variation'] = $variation; } } // variables - if (method_exists($this->datafileReader, 'getVariableKeys')) { - $variableKeys = $this->datafileReader->getVariableKeys($featureKey); - if (!empty($variableKeys)) { - $evaluatedFeature['variables'] = []; - foreach ($variableKeys as $variableKey) { - $evaluatedFeature['variables'][$variableKey] = $this->getVariable($featureKey, $variableKey, $context, $opts); - } + $variableKeys = $this->datafileReader->getVariableKeys($featureKey); + if (!empty($variableKeys)) { + $evaluatedFeature['variables'] = []; + foreach ($variableKeys as $variableKey) { + $evaluatedFeature['variables'][$variableKey] = $this->getVariable($featureKey, $variableKey, $context, $opts); } } $evaluations[$featureKey] = $evaluatedFeature; diff --git a/src/Logger.php b/src/Logger.php index 92e12b4..2dc9364 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -72,7 +72,7 @@ public function log($level, $message, array $context = []): void private static function defaultLogHandler($level, $message, ?array $details = null): void { - if (STDOUT === false) { + if (STDOUT == false) { return; } diff --git a/tests/ChildTest.php b/tests/ChildTest.php index 1d75715..9b7153f 100644 --- a/tests/ChildTest.php +++ b/tests/ChildTest.php @@ -147,14 +147,12 @@ public function testCreateChildInstanceAndAllBehaviors() { 'context' => [ 'appVersion' => '1.0.0' ], ]); - self::assertNotNull($f); self::assertEquals(['appVersion' => '1.0.0'], $f->getContext()); $childF = $f->spawn([ 'userId' => '123', 'country' => 'nl', ]); - self::assertNotNull($childF); self::assertEquals([ 'appVersion' => '1.0.0', 'userId' => '123',