Skip to content

Commit

Permalink
new rector rules (#964)
Browse files Browse the repository at this point in the history
apply one new rector rule, and disable FlipTypeControlToUseExclusiveTypeRector (which changes about 40 files, and IMO makes it harder to comprehend)
  • Loading branch information
brettmc authored Apr 7, 2023
1 parent ca2df9f commit 653a726
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\SetList;
Expand All @@ -23,5 +24,6 @@
__DIR__ . '/src/SDK/SdkBuilder.php',
__DIR__ . '/src/SDK/SdkAutoloader.php',
],
FlipTypeControlToUseExclusiveTypeRector::class,
]);
};
46 changes: 19 additions & 27 deletions src/Contrib/Otlp/AttributesConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,25 @@ final class AttributesConverter
public static function convertAnyValue($value): AnyValue
{
$result = new AnyValue();

switch (true) {
case is_array($value):
$values = new ArrayValue();
foreach ($value as $element) {
/** @psalm-suppress InvalidArgument */
$values->getValues()[] = self::convertAnyValue($element);
}
$result->setArrayValue($values);

break;
case is_int($value):
$result->setIntValue($value);

break;
case is_bool($value):
$result->setBoolValue($value);

break;
case is_float($value):
$result->setDoubleValue($value);

break;
case is_string($value):
$result->setStringValue($value);

break;
if (is_array($value)) {
$values = new ArrayValue();
foreach ($value as $element) {
/** @psalm-suppress InvalidArgument */
$values->getValues()[] = self::convertAnyValue($element);
}
$result->setArrayValue($values);
}
if (is_int($value)) {
$result->setIntValue($value);
}
if (is_bool($value)) {
$result->setBoolValue($value);
}
if (is_float($value)) {
$result->setDoubleValue($value);
}
if (is_string($value)) {
$result->setStringValue($value);
}

return $result;
Expand Down

0 comments on commit 653a726

Please sign in to comment.