Skip to content

Commit

Permalink
bump php to 8.1, apply rector
Browse files Browse the repository at this point in the history
  • Loading branch information
brettmc committed Mar 13, 2024
1 parent 01c46a2 commit 5e17db3
Show file tree
Hide file tree
Showing 118 changed files with 244 additions and 278 deletions.
2 changes: 1 addition & 1 deletion .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
//
// Note that the **only** effect of choosing `'5.6'` is to infer that functions removed in php 7.0 exist.
// (See `backward_compatibility_checks` for additional options)
'target_php_version' => '8.0',
'target_php_version' => '8.1',

// If enabled, missing properties will be created when
// they are first seen. If false, we'll report an
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"readme": "./README.md",
"license": "Apache-2.0",
"require": {
"php": "^8.0",
"ext-json": "*",
"php": "^8.1",
"google/protobuf": "^3.22",
"php-http/discovery": "^1.14",
"psr/http-client-implementation": "^1.0",
Expand Down
4 changes: 2 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->phpVersion(PhpVersion::PHP_80);
$rectorConfig->phpVersion(PhpVersion::PHP_81);

$rectorConfig->paths([
__DIR__ . '/src',
]);

$rectorConfig->sets([
SetList::PHP_80,
SetList::PHP_81,
SetList::CODE_QUALITY,
]);
$rectorConfig->skip([
Expand Down
4 changes: 2 additions & 2 deletions src/API/Baggage/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
final class Entry
{
public function __construct(
private mixed $value,
private MetadataInterface $metadata,
private readonly mixed $value,
private readonly MetadataInterface $metadata,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/API/Baggage/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static function getEmpty(): Metadata
return self::$instance ??= new self('');
}

public function __construct(private string $metadata)
public function __construct(private readonly string $metadata)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/API/Baggage/Propagation/BaggagePropagator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function inject(&$carrier, PropagationSetterInterface $setter = null, Con

/** @var Entry $entry */
foreach ($baggage->getAll() as $key => $entry) {
$value = urlencode($entry->getValue());
$value = urlencode((string) $entry->getValue());
$headerString.= "{$key}={$value}";

if (($metadata = $entry->getMetadata()->getValue()) !== '' && ($metadata = $entry->getMetadata()->getValue()) !== '0') {
Expand Down
2 changes: 1 addition & 1 deletion src/API/Baggage/Propagation/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class Parser

public function __construct(
/** @readonly */
private string $baggageHeader,
private readonly string $baggageHeader,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/API/Behavior/Internal/LogWriter/Psr3LogWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Psr3LogWriter implements LogWriterInterface
{
public function __construct(private LoggerInterface $logger)
public function __construct(private readonly LoggerInterface $logger)
{
}

Expand Down
8 changes: 4 additions & 4 deletions src/API/Globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ final class Globals
private static ?self $globals = null;

public function __construct(
private TracerProviderInterface $tracerProvider,
private MeterProviderInterface $meterProvider,
private LoggerProviderInterface $loggerProvider,
private TextMapPropagatorInterface $propagator,
private readonly TracerProviderInterface $tracerProvider,
private readonly MeterProviderInterface $meterProvider,
private readonly LoggerProviderInterface $loggerProvider,
private readonly TextMapPropagatorInterface $propagator,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/API/Instrumentation/CachedInstrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ final class CachedInstrumentation
* @psalm-suppress PropertyTypeCoercion
*/
public function __construct(
private string $name,
private ?string $version = null,
private ?string $schemaUrl = null,
private iterable $attributes = [],
private readonly string $name,
private readonly ?string $version = null,
private readonly ?string $schemaUrl = null,
private readonly iterable $attributes = [],
) {
$this->tracers = new \WeakMap();
$this->meters = new \WeakMap();
Expand Down
4 changes: 2 additions & 2 deletions src/API/Logs/EventLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class EventLogger implements EventLoggerInterface
{
public function __construct(
private LoggerInterface $logger,
private string $domain,
private readonly LoggerInterface $logger,
private readonly string $domain,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/API/Trace/NonRecordingSpan.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
final class NonRecordingSpan extends Span
{
public function __construct(private SpanContextInterface $context)
public function __construct(private readonly SpanContextInterface $context)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/API/Trace/NoopSpanBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class NoopSpanBuilder implements SpanBuilderInterface
{
private ContextInterface|false|null $parentContext = null;

public function __construct(private ContextStorageInterface $contextStorage)
public function __construct(private readonly ContextStorageInterface $contextStorage)
{
}

Expand Down
8 changes: 4 additions & 4 deletions src/API/Trace/SpanContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ final class SpanContext implements SpanContextInterface
* @see https://www.w3.org/TR/trace-context/#trace-flags
* @see https://www.w3.org/TR/trace-context/#sampled-flag
*/
private bool $isSampled;
private readonly bool $isSampled;
private bool $isValid = true;

private function __construct(
private string $traceId,
private string $spanId,
private int $traceFlags,
private bool $isRemote,
private ?TraceStateInterface $traceState = null,
private readonly int $traceFlags,
private readonly bool $isRemote,
private readonly ?TraceStateInterface $traceState = null,
) {
// TraceId must be exactly 16 bytes (32 chars) and at least one non-zero byte
// SpanId must be exactly 8 bytes (16 chars) and at least one non-zero byte
Expand Down
2 changes: 1 addition & 1 deletion src/API/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"open-telemetry/context": "^1.0",
"psr/log": "^1.1|^2.0|^3.0",
"symfony/polyfill-php81": "^1.26",
Expand Down
2 changes: 1 addition & 1 deletion src/Context/ContextKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
final class ContextKey implements ContextKeyInterface
{
public function __construct(private ?string $name = null)
public function __construct(private readonly ?string $name = null)
{
}

Expand Down
8 changes: 4 additions & 4 deletions src/Context/DebugScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ final class DebugScope implements ScopeInterface
{
private static bool $shutdownHandlerInitialized = false;
private static bool $finalShutdownPhase = false;
private ?int $fiberId;
private array $createdAt;
private readonly ?int $fiberId;
private readonly array $createdAt;
private ?array $detachedAt = null;

public function __construct(private ContextStorageScopeInterface $scope)
public function __construct(private readonly ContextStorageScopeInterface $scope)
{
$this->fiberId = self::currentFiberId();
$this->createdAt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
Expand Down Expand Up @@ -114,7 +114,7 @@ private static function formatBacktrace(array $trace): string
$s .= strtr($trace[$i]['function'] ?? '{main}', ['\\' => '.']);
$s .= '(';
if (isset($trace[$i - 1]['file'])) {
$s .= basename($trace[$i - 1]['file']);
$s .= basename((string) $trace[$i - 1]['file']);
if (isset($trace[$i - 1]['line'])) {
$s .= ':';
$s .= $trace[$i - 1]['line'];
Expand Down
2 changes: 1 addition & 1 deletion src/Context/FiberBoundContextStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class FiberBoundContextStorage implements ContextStorageInterface, Executi
/**
* @param ContextStorageInterface&ExecutionContextAwareInterface $storage
*/
public function __construct(private ContextStorageInterface $storage)
public function __construct(private readonly ContextStorageInterface $storage)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Context/Propagation/MultiTextMapPropagator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class MultiTextMapPropagator implements TextMapPropagatorInterface
* @readonly
* @var list<string>
*/
private array $fields;
private readonly array $fields;

/**
* @no-named-arguments
Expand All @@ -26,7 +26,7 @@ final class MultiTextMapPropagator implements TextMapPropagatorInterface
*/
public function __construct(
/** @readonly */
private array $propagators,
private readonly array $propagators,
) {
$this->fields = $this->extractFields($this->propagators);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class SanitizeCombinedHeadersPropagationGetter implements PropagationGette
private const SERVER_CONCAT_HEADERS_REGEX = '/;(?=[^,=;]*=|$)/';
private const TRAILING_LEADING_SEPARATOR_REGEX = '/^' . self::LIST_MEMBERS_SEPARATOR . '+|' . self::LIST_MEMBERS_SEPARATOR . '+$/';

public function __construct(private PropagationGetterInterface $getter)
public function __construct(private readonly PropagationGetterInterface $getter)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Context/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"symfony/polyfill-php81": "^1.26",
"symfony/polyfill-php82": "^1.26"
},
Expand Down
6 changes: 3 additions & 3 deletions src/Contrib/Grpc/GrpcTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
*/
final class GrpcTransport implements TransportInterface
{
private array $metadata;
private Channel $channel;
private readonly array $metadata;
private readonly Channel $channel;
private bool $closed = false;

public function __construct(
string $endpoint,
array $opts,
private string $method,
private readonly string $method,
array $headers = [],
) {
$this->channel = new Channel($endpoint, $opts);
Expand Down
2 changes: 1 addition & 1 deletion src/Contrib/Grpc/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-grpc": "*",
"grpc/grpc": "*",
"open-telemetry/sdk": "^1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/Contrib/Otlp/HttpEndpointResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class HttpEndpointResolver implements HttpEndpointResolverInterface
private const DEFAULT_SCHEME = 'https';
private const ROOT_PATH = '/';

private FactoryResolverInterface $httpFactoryResolver;
private readonly FactoryResolverInterface $httpFactoryResolver;

public function __construct(?FactoryResolverInterface $httpFactoryResolver = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Contrib/Otlp/LogsConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class LogsConverter
{
private ProtobufSerializer $serializer;
private readonly ProtobufSerializer $serializer;

public function __construct(?ProtobufSerializer $serializer = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Contrib/Otlp/LogsExporterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class LogsExporterFactory implements LogRecordExporterFactoryInterface
{
private const DEFAULT_COMPRESSION = 'none';

public function __construct(private ?TransportFactoryInterface $transportFactory = null)
public function __construct(private readonly ?TransportFactoryInterface $transportFactory = null)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Contrib/Otlp/MetricConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

final class MetricConverter
{
private ProtobufSerializer $serializer;
private readonly ProtobufSerializer $serializer;

public function __construct(?ProtobufSerializer $serializer = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Contrib/Otlp/MetricExporterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MetricExporterFactory implements MetricExporterFactoryInterface
{
private const DEFAULT_COMPRESSION = 'none';

public function __construct(private ?TransportFactoryInterface $transportFactory = null)
public function __construct(private readonly ?TransportFactoryInterface $transportFactory = null)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Contrib/Otlp/ProtobufSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
final class ProtobufSerializer
{
private function __construct(private string $contentType)
private function __construct(private readonly string $contentType)
{
}

Expand Down Expand Up @@ -120,7 +120,7 @@ private static function traverseDescriptor(object $data, Descriptor $desc): void
for ($i = 0, $n = $desc->getFieldCount(); $i < $n; $i++) {
// @phan-suppress-next-line PhanParamTooManyInternal
$field = $desc->getField($i);
$name = lcfirst(strtr(ucwords($field->getName(), '_'), ['_' => '']));
$name = lcfirst(strtr(ucwords((string) $field->getName(), '_'), ['_' => '']));
if (!property_exists($data, $name)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Contrib/Otlp/SpanConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

final class SpanConverter
{
private ProtobufSerializer $serializer;
private readonly ProtobufSerializer $serializer;

public function __construct(?ProtobufSerializer $serializer = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Contrib/Otlp/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"php-http/discovery": "^1.14",
"open-telemetry/gen-otlp-protobuf": "^1.1",
"open-telemetry/api": "^1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Contrib/Zipkin/SpanConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SpanConverter implements SpanConverterInterface

const NET_PEER_IP_KEY = 'net.peer.ip';

private string $defaultServiceName;
private readonly string $defaultServiceName;

public function __construct()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Contrib/Zipkin/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"open-telemetry/api": "^1.0",
"open-telemetry/sdk": "^1.0",
"php-http/async-client-implementation": "^1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Contrib/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-json": "*",
"open-telemetry/api": "^1.0",
"open-telemetry/context": "^1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Extension/Propagator/B3/B3Propagator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
final class B3Propagator implements TextMapPropagatorInterface
{
private function __construct(private TextMapPropagatorInterface $propagator)
private function __construct(private readonly TextMapPropagatorInterface $propagator)
{
}

Expand Down
Loading

0 comments on commit 5e17db3

Please sign in to comment.