Skip to content

Commit

Permalink
drop php 7.4 support
Browse files Browse the repository at this point in the history
update composer.json minimums, and run rector over the code to update what it can. changed some static analysis
config to fix some rector-induced failures.
  • Loading branch information
brettmc committed Feb 29, 2024
1 parent 258e586 commit 8342aba
Show file tree
Hide file tree
Showing 179 changed files with 662 additions and 1,623 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3']
php-version: ['8.0', '8.1', '8.2', '8.3']
experimental: [false]
composer_args: [""]
include:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-otel-php-base-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: OpenTelemetry PHP base docker image creation
strategy:
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3']
php-version: ['8.0', '8.1', '8.2', '8.3']
runs-on: ubuntu-latest
permissions:
packages: write
Expand Down
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' => '7.4',
'target_php_version' => '8.0',

// If enabled, missing properties will be created when
// they are first seen. If false, we'll report an
Expand Down
4 changes: 2 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ This does the following things:
### Other PHP versions

We aim to support officially supported PHP versions, according to https://www.php.net/supported-versions.php. The
developer image `ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base` is tagged as `7.4`, `8.0`, `8.1` and `8.2`
respectively, with `7.4` being the default. You can execute the test suite against other PHP versions by running the
developer image `ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base` is tagged as `8.0`, `8.1`, `8.2` and `8.3`
respectively, with `8.0` being the default. You can execute the test suite against other PHP versions by running the
following command:

```bash
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include .env

PHP_VERSION ?= 7.4
PHP_VERSION ?= 8.0
DOCKER_COMPOSE ?= docker-compose
DC_RUN_PHP = $(DOCKER_COMPOSE) run --rm php

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"readme": "./README.md",
"license": "Apache-2.0",
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"ext-json": "*",
"google/protobuf": "^3.22",
"php-http/discovery": "^1.14",
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.collector.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.7'
services:
php:
image: ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base:${PHP_VERSION:-7.4}
image: ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base:${PHP_VERSION:-8.0}
volumes:
- ./:/usr/src/myapp
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.prometheus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
context: .
dockerfile: docker/examples/Dockerfile
args:
- PHP_VERSION=7.4-fpm
- PHP_VERSION=8.0-fpm
- EXT_ENABLE=redis
volumes:
- ./examples/prometheus/index.php:/var/www/public/index.php
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.w3cTraceContext.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.7'
services:
php:
image: ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base:${PHP_VERSION:-7.4}
image: ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base:${PHP_VERSION:-8.0}
volumes:
- ./:/usr/src/myapp
- ./:/usr/src/open-telemetry/
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.7'
services:
php:
image: ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base:${PHP_VERSION:-7.4}
image: ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base:${PHP_VERSION:-8.0}
volumes:
- ./:/usr/src/myapp
user: "${PHP_USER}:root"
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PHP_VERSION=7.4
ARG PHP_VERSION=8.0
FROM php:${PHP_VERSION}-cli-alpine as php_build

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
Expand Down
25 changes: 25 additions & 0 deletions examples/traces/features/batch_exporting_with_self_diagnostics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace OpenTelemetry\Example;

use OpenTelemetry\API\Globals;
use OpenTelemetry\SDK\Trace\TracerProviderInterface;

putenv('OTEL_PHP_AUTOLOAD_ENABLED=true');
putenv('OTEL_TRACES_EXPORTER=console');
putenv('OTEL_METRICS_EXPORTER=console');
putenv('OTEL_PHP_INTERNAL_METRICS_ENABLED=true');

require __DIR__ . '/../../../vendor/autoload.php';

$tracerProvider = Globals::tracerProvider();

$tracer = $tracerProvider->getTracer('io.opentelemetry.contrib.php');

$span = $tracer->spanBuilder('root')->startSpan();
$span->end();

echo PHP_EOL;
$tracerProvider instanceof TracerProviderInterface && $tracerProvider->shutdown();
2 changes: 1 addition & 1 deletion proto/otel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"google/protobuf": "^3.3.0"
},
"autoload": {
Expand Down
7 changes: 7 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
<pluginClass class="Psalm\MockeryPlugin\Plugin"/>
</plugins>
<issueHandlers>
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="GMP" />
</errorLevel>
</UndefinedClass>
</issueHandlers>
</psalm>
6 changes: 3 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\ValueObject\PhpVersion;
use Rector\Set\ValueObject\SetList;

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

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

$rectorConfig->sets([
SetList::PHP_74,
SetList::PHP_80,
SetList::CODE_QUALITY,
]);
$rectorConfig->skip([
Expand Down
6 changes: 1 addition & 5 deletions src/API/Baggage/Baggage.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@ public static function getEmpty(): BaggageInterface
return self::$emptyBaggage;
}

/** @var array<string, Entry> */
private array $entries;

/** @param array<string, Entry> $entries */
public function __construct(array $entries = [])
public function __construct(private array $entries = [])
{
$this->entries = $entries;
}

/** @inheritDoc */
Expand Down
6 changes: 1 addition & 5 deletions src/API/Baggage/BaggageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

final class BaggageBuilder implements BaggageBuilderInterface
{
/** @var array<string, Entry> */
private array $entries;

/** @param array<string, Entry> $entries */
public function __construct(array $entries = [])
public function __construct(private array $entries = [])
{
$this->entries = $entries;
}

/** @inheritDoc */
Expand Down
3 changes: 1 addition & 2 deletions src/API/Baggage/BaggageBuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ interface BaggageBuilderInterface
{
/**
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/baggage/api.md#set-value
* @param mixed $value
*/
public function set(string $key, $value, API\MetadataInterface $metadata = null): API\BaggageBuilderInterface;
public function set(string $key, mixed $value, API\MetadataInterface $metadata = null): API\BaggageBuilderInterface;

/**
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/baggage/api.md#remove-value
Expand Down
17 changes: 2 additions & 15 deletions src/API/Baggage/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,8 @@

final class Entry
{
/** @var mixed */
private $value;

private MetadataInterface $metadata;

/**
* @param mixed $value
* @param MetadataInterface $metadata
*/
public function __construct(
$value,
MetadataInterface $metadata
) {
$this->value = $value;
$this->metadata = $metadata;
public function __construct(private mixed $value, private MetadataInterface $metadata)
{
}

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

private string $metadata;

public function __construct(string $metadata)
public function __construct(private string $metadata)
{
$this->metadata = $metadata;
}

public function getValue(): string
Expand Down
10 changes: 4 additions & 6 deletions src/API/Baggage/Propagation/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ final class Parser
private const EXCLUDED_VALUE_CHARS = [' ', '"', ',', ';', '\\'];
private const EQUALS = '=';

/** @readonly */
private string $baggageHeader;

public function __construct(string $baggageHeader)
{
$this->baggageHeader = $baggageHeader;
public function __construct(
/** @readonly */
private string $baggageHeader
) {
}

public function parseInto(BaggageBuilderInterface $baggageBuilder): void
Expand Down
5 changes: 1 addition & 4 deletions src/API/Behavior/Internal/LogWriter/Psr3LogWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

class Psr3LogWriter implements LogWriterInterface
{
private LoggerInterface $logger;

public function __construct(LoggerInterface $logger)
public function __construct(private LoggerInterface $logger)
{
$this->logger = $logger;
}

public function write($level, string $message, array $context): void
Expand Down
17 changes: 2 additions & 15 deletions src/API/Globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,8 @@ final class Globals
private static array $initializers = [];
private static ?self $globals = null;

private TracerProviderInterface $tracerProvider;
private MeterProviderInterface $meterProvider;
private TextMapPropagatorInterface $propagator;
private LoggerProviderInterface $loggerProvider;

public function __construct(
TracerProviderInterface $tracerProvider,
MeterProviderInterface $meterProvider,
LoggerProviderInterface $loggerProvider,
TextMapPropagatorInterface $propagator
) {
$this->tracerProvider = $tracerProvider;
$this->meterProvider = $meterProvider;
$this->loggerProvider = $loggerProvider;
$this->propagator = $propagator;
public function __construct(private TracerProviderInterface $tracerProvider, private MeterProviderInterface $meterProvider, private LoggerProviderInterface $loggerProvider, private TextMapPropagatorInterface $propagator)
{
}

public static function tracerProvider(): TracerProviderInterface
Expand Down
10 changes: 1 addition & 9 deletions src/API/Instrumentation/CachedInstrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,15 @@
*/
final class CachedInstrumentation
{
private string $name;
private ?string $version;
private ?string $schemaUrl;
private iterable $attributes;
/** @var ArrayAccess<TracerProviderInterface, TracerInterface>|null */
private ?ArrayAccess $tracers;
/** @var ArrayAccess<MeterProviderInterface, MeterInterface>|null */
private ?ArrayAccess $meters;
/** @var ArrayAccess<LoggerProviderInterface, LoggerInterface>|null */
private ?ArrayAccess $loggers;

public function __construct(string $name, ?string $version = null, ?string $schemaUrl = null, iterable $attributes = [])
public function __construct(private string $name, private ?string $version = null, private ?string $schemaUrl = null, private iterable $attributes = [])
{
$this->name = $name;
$this->version = $version;
$this->schemaUrl = $schemaUrl;
$this->attributes = $attributes;
$this->tracers = self::createWeakMap();
$this->meters = self::createWeakMap();
$this->loggers = self::createWeakMap();
Expand Down
7 changes: 1 addition & 6 deletions src/API/Logs/EventLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@

class EventLogger implements EventLoggerInterface
{
private LoggerInterface $logger;
private string $domain;

public function __construct(LoggerInterface $logger, string $domain)
public function __construct(private LoggerInterface $logger, private string $domain)
{
$this->logger = $logger;
$this->domain = $domain;
}

public function logEvent(string $eventName, LogRecord $logRecord): void
Expand Down
9 changes: 2 additions & 7 deletions src/API/Logs/LogRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ class LogRecord
protected ?ContextInterface $context = null;
protected int $severityNumber = 0;
protected ?string $severityText = null;
protected $body = null;
protected array $attributes = [];

/**
* @param mixed $body
*/
public function __construct($body = null)
public function __construct(protected mixed $body = null)
{
$this->body = $body;
}

/**
Expand Down Expand Up @@ -89,7 +84,7 @@ public function setAttribute(string $name, $value): self
/**
* @param mixed $body The log record body
*/
public function setBody($body = null): self
public function setBody(mixed $body = null): self
{
$this->body = $body;

Expand Down
Loading

0 comments on commit 8342aba

Please sign in to comment.