Repository: open-telemetry/opentelemetry-php (php)

Issue:
self.version in composer.json incompatible with subtree splits
**Describe your environment**
Since we decided to version all of our packages independently, it's quite likely (and desired) that we have different packages at different tags.
However, many of our packages are incompatible with each other due to composer requirements using `self.version` which were originally set up when we deployed the whole repository via one release on the monorepo.

**Steps to reproduce**
Require open-telemetry/sdk 1.0.0beta2 and open-telemetry/exporter-otlp 1.0.0beta1 specifically.

**What is the expected behavior?**
Packages installed via composer

**What is the actual behavior?**
```
$ composer update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires open-telemetry/exporter-otlp 1.0.0beta1 -> satisfiable by open-telemetry/exporter-otlp[1.0.0beta1].
    - open-telemetry/exporter-otlp 1.0.0beta1 requires open-telemetry/sdk 1.0.0beta1 -> found open-telemetry/sdk[1.0.0beta1] but it conflicts with your root composer.json require (1.0.0beta2).
```

Pull request description:
relax composer version requirements
using self.version does not work when we have different components being released individually. ^1.0 seems like a sensible initial setting now that we have reached beta.
Fixes #917 

Patch:
diff --git a/.phan/config.php b/.phan/config.php
index 8e65007f..f0e92471 100644
--- a/.phan/config.php
+++ b/.phan/config.php
@@ -376,7 +376,6 @@ return [
         'vendor/php-http',
         'vendor/phan/phan/src/Phan',
         'vendor/phpunit/phpunit/src',
-        'vendor/promphp/prometheus_client_php/src',
         'vendor/google/protobuf/src',
     ],
 
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c4da90ea..52ba829c 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -3,7 +3,7 @@
 
 - [Bob Strecansky](https://github.com/bobstrecansky)
 - [Brett McBride](https://github.com/brettmc/)
-- [Przemek Delewski](https://github.com/pdelewski)
+- [Przemek Delewski](https://github.com/pdelewski), Sumo Logic
 
 Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#maintainer)
 
diff --git a/composer.json b/composer.json
index 612bd49e..286fc615 100644
--- a/composer.json
+++ b/composer.json
@@ -24,6 +24,7 @@
         "sort-packages": true,
         "allow-plugins": {
             "composer/package-versions-deprecated": true,
+            "php-http/discovery": true,
             "symfony/runtime": true
         }
     },
@@ -90,7 +91,7 @@
         "phpstan/phpstan": "^1.1",
         "phpstan/phpstan-mockery": "^1.0",
         "phpstan/phpstan-phpunit": "^1.0",
-        "phpunit/phpunit": "^9.3",
+        "phpunit/phpunit": "^9.6",
         "psalm/plugin-mockery": "^0.9",
         "psalm/plugin-phpunit": "^0.18",
         "psalm/psalm": "^4.0",
diff --git a/src/API/composer.json b/src/API/composer.json
index efebb4db..0ac612e8 100644
--- a/src/API/composer.json
+++ b/src/API/composer.json
@@ -12,8 +12,8 @@
     ],
     "require": {
         "php": "^7.4 || ^8.0",
-        "open-telemetry/context": "self.version",
-        "open-telemetry/sem-conv": "self.version",
+        "open-telemetry/context": "^1.0",
+        "open-telemetry/sem-conv": "^1.0",
         "psr/log": "^1.1|^2.0|^3.0",
         "symfony/polyfill-php80": "^1.26",
         "symfony/polyfill-php81": "^1.26",
diff --git a/src/Contrib/Grpc/composer.json b/src/Contrib/Grpc/composer.json
index 3da1bf14..c6393ce8 100644
--- a/src/Contrib/Grpc/composer.json
+++ b/src/Contrib/Grpc/composer.json
@@ -14,7 +14,7 @@
     "php": "^7.4 || ^8.0",
     "ext-grpc": "*",
     "grpc/grpc": "*",
-    "open-telemetry/sdk": "self.version"
+    "open-telemetry/sdk": "^1.0"
   },
   "autoload": {
     "psr-4": {
diff --git a/src/Contrib/Newrelic/composer.json b/src/Contrib/Newrelic/composer.json
index b62996be..9013ef0e 100644
--- a/src/Contrib/Newrelic/composer.json
+++ b/src/Contrib/Newrelic/composer.json
@@ -12,7 +12,7 @@
   ],
   "require": {
     "php": "^7.4 || ^8.0",
-    "open-telemetry/sdk": "self.version",
+    "open-telemetry/sdk": "^1.0",
     "php-http/async-client-implementation": "^1.0",
     "php-http/discovery": "^1.14",
     "psr/http-factory-implementation": "^1.0"
diff --git a/src/Contrib/Otlp/composer.json b/src/Contrib/Otlp/composer.json
index 2615188d..71ddb647 100644
--- a/src/Contrib/Otlp/composer.json
+++ b/src/Contrib/Otlp/composer.json
@@ -13,9 +13,9 @@
   "require": {
     "php": "^7.4 || ^8.0",
     "php-http/discovery": "^1.14",
-    "open-telemetry/gen-otlp-protobuf": "self.version",
-    "open-telemetry/api": "self.version",
-    "open-telemetry/sdk": "self.version"
+    "open-telemetry/gen-otlp-protobuf": "^1.0",
+    "open-telemetry/api": "^1.0",
+    "open-telemetry/sdk": "^1.0"
   },
   "suggest": {
     "php-http/async-client-implementation": "For otlp/http exporting",
diff --git a/src/Contrib/Zipkin/composer.json b/src/Contrib/Zipkin/composer.json
index c551dc63..04669ae1 100644
--- a/src/Contrib/Zipkin/composer.json
+++ b/src/Contrib/Zipkin/composer.json
@@ -12,8 +12,8 @@
   ],
   "require": {
     "php": "^7.4 || ^8.0",
-    "open-telemetry/api": "self.version",
-    "open-telemetry/sdk": "self.version",
+    "open-telemetry/api": "^1.0",
+    "open-telemetry/sdk": "^1.0",
     "php-http/async-client-implementation": "^1.0",
     "php-http/discovery": "^1.14",
     "psr/http-factory-implementation": "^1.0"
diff --git a/src/Contrib/ZipkinToNewrelic/composer.json b/src/Contrib/ZipkinToNewrelic/composer.json
index c736e5f2..f4c998b1 100644
--- a/src/Contrib/ZipkinToNewrelic/composer.json
+++ b/src/Contrib/ZipkinToNewrelic/composer.json
@@ -12,7 +12,7 @@
   ],
   "require": {
     "php": "^7.4 || ^8.0",
-    "open-telemetry/sdk": "self.version",
+    "open-telemetry/sdk": "^1.0",
     "php-http/async-client-implementation": "^1.0",
     "php-http/discovery": "^1.14",
     "psr/http-factory-implementation": "^1.0"
diff --git a/src/Contrib/composer.json b/src/Contrib/composer.json
index edd6b306..9a7d87cd 100644
--- a/src/Contrib/composer.json
+++ b/src/Contrib/composer.json
@@ -13,11 +13,11 @@
     "require": {
         "php": "^7.4 || ^8.0",
         "ext-json": "*",
-        "open-telemetry/api": "self.version",
-        "open-telemetry/context": "self.version",
-        "open-telemetry/gen-otlp-protobuf": "self.version",
-        "open-telemetry/sdk": "self.version",
-        "open-telemetry/sem-conv": "self.version",
+        "open-telemetry/api": "^1.0",
+        "open-telemetry/context": "^1.0",
+        "open-telemetry/gen-otlp-protobuf": "^1.0",
+        "open-telemetry/sdk": "^1.0",
+        "open-telemetry/sem-conv": "^1.0",
         "php-http/async-client-implementation": "^1.0",
         "php-http/discovery": "^1.14",
         "psr/http-factory-implementation": "^1.0",
diff --git a/src/Extension/Propagator/B3/composer.json b/src/Extension/Propagator/B3/composer.json
index 18307869..1e050a0b 100644
--- a/src/Extension/Propagator/B3/composer.json
+++ b/src/Extension/Propagator/B3/composer.json
@@ -12,8 +12,8 @@
     ],
     "require": {
         "php": "^7.4 || ^8.0",
-        "open-telemetry/api": "self.version",
-        "open-telemetry/context": "self.version"
+        "open-telemetry/api": "^1.0",
+        "open-telemetry/context": "^1.0"
     },
     "autoload": {
         "psr-4": {
diff --git a/src/SDK/Common/Dev/Compatibility/BC/AbstractClock.php b/src/SDK/Common/Dev/Compatibility/BC/AbstractClock.php
deleted file mode 100644
index 185b8c61..00000000
--- a/src/SDK/Common/Dev/Compatibility/BC/AbstractClock.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\SDK\Common\Dev\Compatibility\BC;
-
-use OpenTelemetry\SDK\Common\Dev\Compatibility\Util;
-use OpenTelemetry\SDK\Common\Time\ClockFactory;
-use OpenTelemetry\SDK\Common\Time\ClockInterface;
-use OpenTelemetry\SDK\Common\Time\Util as TimeUtil;
-
-/**
- * @codeCoverageIgnoreStart
- */
-abstract class AbstractClock implements ClockInterface
-{
-    public static function getDefault(): ClockInterface
-    {
-        Util::triggerMethodDeprecationNotice(
-            'OpenTelemetry\SDK\AbstractClock::getDefault',
-            'getDefault',
-            ClockFactory::class
-        );
-
-        return ClockFactory::getDefault();
-    }
-
-    public static function setTestClock(?ClockInterface $clock = null): void
-    {
-        Util::triggerMethodDeprecationNotice(
-            'OpenTelemetry\SDK\AbstractClock::setTestClock',
-            'setDefault',
-            ClockFactory::class
-        );
-
-        ClockFactory::setDefault($clock);
-    }
-
-    public static function nanosToMicro(int $nanoseconds): int
-    {
-        Util::triggerMethodDeprecationNotice(
-            'OpenTelemetry\SDK\AbstractClock::nanosToMicro',
-            'nanosToMicros',
-            TimeUtil::class
-        );
-
-        return TimeUtil::nanosToMicros($nanoseconds);
-    }
-
-    public static function nanosToMilli(int $nanoseconds): int
-    {
-        Util::triggerMethodDeprecationNotice(
-            'OpenTelemetry\SDK\AbstractClock::nanosToMilli',
-            'nanosToMillis',
-            TimeUtil::class
-        );
-
-        return TimeUtil::nanosToMillis($nanoseconds);
-    }
-
-    public static function secondsToNanos(int $seconds): int
-    {
-        Util::triggerMethodDeprecationNotice(
-            'OpenTelemetry\SDK\AbstractClock::secondsToNanos',
-            'nanosToMillis',
-            TimeUtil::class
-        );
-
-        return TimeUtil::nanosToMillis($seconds);
-    }
-}
-
-/**
- * BC class alias
- * @todo: remove in future release. Also in composer.json autoload/files.
- */
-class_alias(AbstractClock::class, 'OpenTelemetry\SDK\AbstractClock');
diff --git a/src/SDK/Common/Dev/Compatibility/BC/ClockInterface.php b/src/SDK/Common/Dev/Compatibility/BC/ClockInterface.php
deleted file mode 100644
index f2e540ad..00000000
--- a/src/SDK/Common/Dev/Compatibility/BC/ClockInterface.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\SDK\Common\Dev\Compatibility\BC;
-
-use OpenTelemetry\SDK\Common\Time\ClockInterface as Moved;
-
-interface ClockInterface extends Moved
-{
-}
-
-/**
- * @codeCoverageIgnoreStart
- */
-class_alias(ClockInterface::class, 'OpenTelemetry\SDK\ClockInterface');
-/**
- * @codeCoverageIgnoreEnd
- */
diff --git a/src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibrary.php b/src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibrary.php
deleted file mode 100644
index c3eebf92..00000000
--- a/src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibrary.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\SDK\Common\Dev\Compatibility\BC;
-
-use OpenTelemetry\SDK\Common\Attribute\Attributes;
-use OpenTelemetry\SDK\Common\Attribute\AttributesInterface;
-use OpenTelemetry\SDK\Common\Dev\Compatibility\Util;
-use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScope as Moved;
-
-/**
- * @codeCoverageIgnoreStart
- */
-const OpenTelemetry_SDK_InstrumentationLibrary = 'OpenTelemetry\SDK\InstrumentationLibrary';
-
-final class InstrumentationLibrary implements InstrumentationLibraryInterface
-{
-    private Moved $adapted;
-
-    public function __construct(string $name, ?string $version = null, ?string $schemaUrl = null)
-    {
-        $this->adapted = new Moved($name, $version, $schemaUrl, Attributes::create([]));
-
-        Util::triggerClassDeprecationNotice(
-            OpenTelemetry_SDK_InstrumentationLibrary,
-            Moved::class
-        );
-    }
-
-    public function getName(): string
-    {
-        return $this->adapted->getName();
-    }
-
-    public function getVersion(): ?string
-    {
-        return $this->adapted->getVersion();
-    }
-
-    public function getSchemaUrl(): ?string
-    {
-        return $this->adapted->getSchemaUrl();
-    }
-
-    public function getAttributes(): AttributesInterface
-    {
-        return $this->adapted->getAttributes();
-    }
-}
-
-class_alias(InstrumentationLibrary::class, OpenTelemetry_SDK_InstrumentationLibrary);
-/**
- * @codeCoverageIgnoreEnd
- */
diff --git a/src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibraryInterface.php b/src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibraryInterface.php
deleted file mode 100644
index b7da1080..00000000
--- a/src/SDK/Common/Dev/Compatibility/BC/InstrumentationLibraryInterface.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\SDK\Common\Dev\Compatibility\BC;
-
-use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeInterface as Moved;
-
-interface InstrumentationLibraryInterface extends Moved
-{
-}
-
-/**
- * @codeCoverageIgnoreStart
- */
-class_alias(InstrumentationLibraryInterface::class, 'OpenTelemetry\SDK\Common\Instrumentation\InstrumentationLibraryInterface');
-/**
- * @codeCoverageIgnoreEnd
- */
diff --git a/src/SDK/Common/Dev/Compatibility/BC/LoggerHolder.php b/src/SDK/Common/Dev/Compatibility/BC/LoggerHolder.php
index 57d87b21..cd6dc5d5 100644
--- a/src/SDK/Common/Dev/Compatibility/BC/LoggerHolder.php
+++ b/src/SDK/Common/Dev/Compatibility/BC/LoggerHolder.php
@@ -25,7 +25,9 @@ final class LoggerHolder
     }
 }
 
-class_alias(LoggerHolder::class, OpenTelemetry_SDK_Common_Log_LoggerHolder);
+if (!class_exists(OpenTelemetry_SDK_Common_Log_LoggerHolder, false)) {
+    class_alias(LoggerHolder::class, OpenTelemetry_SDK_Common_Log_LoggerHolder);
+}
 /**
  * @codeCoverageIgnoreEnd
  */
diff --git a/src/SDK/Common/Dev/Compatibility/BC/OtlpExporter.php b/src/SDK/Common/Dev/Compatibility/BC/OtlpExporter.php
index 07ec0e9a..b2ce4ac4 100644
--- a/src/SDK/Common/Dev/Compatibility/BC/OtlpExporter.php
+++ b/src/SDK/Common/Dev/Compatibility/BC/OtlpExporter.php
@@ -46,6 +46,8 @@ class OtlpExporter implements SpanExporterInterface
     }
 }
 
-class_alias(OtlpExporter::class, 'OpenTelemetry\Contrib\OtlpGrpc\Exporter');
-class_alias(OtlpExporter::class, 'OpenTelemetry\Contrib\OtlpHttp\Exporter');
-class_alias(OtlpExporter::class, 'OpenTelemetry\Contrib\Otlp\Exporter');
+if (!class_exists('OpenTelemetry\Contrib\Otlp\Exporter', false)) {
+    class_alias(OtlpExporter::class, 'OpenTelemetry\Contrib\OtlpGrpc\Exporter');
+    class_alias(OtlpExporter::class, 'OpenTelemetry\Contrib\OtlpHttp\Exporter');
+    class_alias(OtlpExporter::class, 'OpenTelemetry\Contrib\Otlp\Exporter');
+}
diff --git a/src/SDK/Common/Dev/Compatibility/BC/SystemClock.php b/src/SDK/Common/Dev/Compatibility/BC/SystemClock.php
deleted file mode 100644
index a420346b..00000000
--- a/src/SDK/Common/Dev/Compatibility/BC/SystemClock.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\SDK\Common\Dev\Compatibility\BC;
-
-use OpenTelemetry\SDK\Common\Dev\Compatibility\Util;
-use OpenTelemetry\SDK\Common\Time\SystemClock as Moved;
-
-/**
- * @codeCoverageIgnoreStart
- */
-const OpenTelemetry_SDK_SystemClock = 'OpenTelemetry\SDK\SystemClock';
-
-class SystemClock implements ClockInterface
-{
-    private Moved $adapted;
-
-    public function __construct()
-    {
-        $this->adapted = new Moved();
-        Util::triggerClassDeprecationNotice(
-            OpenTelemetry_SDK_SystemClock,
-            Moved::class
-        );
-    }
-
-    public static function getInstance(): self
-    {
-        return new self();
-    }
-
-    public function now(): int
-    {
-        return $this->adapted->now();
-    }
-
-    public function nanoTime(): int
-    {
-        return $this->adapted->now();
-    }
-}
-
-class_alias(SystemClock::class, OpenTelemetry_SDK_SystemClock);
-/**
- * @codeCoverageIgnoreEnd
- */
diff --git a/src/SDK/Common/Dev/Compatibility/_load.php b/src/SDK/Common/Dev/Compatibility/_load.php
index 3b8f9277..c8d95e0a 100644
--- a/src/SDK/Common/Dev/Compatibility/_load.php
+++ b/src/SDK/Common/Dev/Compatibility/_load.php
@@ -2,10 +2,5 @@
 
 declare(strict_types=1);
 
-require_once __DIR__ . '/BC/ClockInterface.php';
-require_once __DIR__ . '/BC/AbstractClock.php';
-require_once __DIR__ . '/BC/SystemClock.php';
-require_once __DIR__ . '/BC/InstrumentationLibraryInterface.php';
-require_once __DIR__ . '/BC/InstrumentationLibrary.php';
 require_once __DIR__ . '/BC/OtlpExporter.php';
 require_once __DIR__ . '/BC/LoggerHolder.php';
diff --git a/src/SDK/composer.json b/src/SDK/composer.json
index ff670fa3..0a47ed24 100644
--- a/src/SDK/composer.json
+++ b/src/SDK/composer.json
@@ -13,9 +13,9 @@
     "require": {
         "php": "^7.4 || ^8.0",
         "ext-json": "*",
-        "open-telemetry/api": "self.version",
-        "open-telemetry/context": "self.version",
-        "open-telemetry/sem-conv": "self.version",
+        "open-telemetry/api": "^1.0",
+        "open-telemetry/context": "^1.0",
+        "open-telemetry/sem-conv": "^1.0",
         "php-http/async-client-implementation": "^1.0",
         "php-http/discovery": "^1.14",
         "psr/http-factory-implementation": "^1.0",


Test patch:
diff --git a/tests/Unit/API/Behavior/LogsMessagesTraitTest.php b/tests/Unit/API/Behavior/LogsMessagesTraitTest.php
index a517e427..142c8031 100644
--- a/tests/Unit/API/Behavior/LogsMessagesTraitTest.php
+++ b/tests/Unit/API/Behavior/LogsMessagesTraitTest.php
@@ -6,6 +6,7 @@ namespace OpenTelemetry\Tests\Unit\API\Behavior;
 
 use OpenTelemetry\API\Behavior\LogsMessagesTrait;
 use OpenTelemetry\API\Common\Log\LoggerHolder;
+use PHPUnit\Framework\Exception as PHPUnitFrameworkException;
 use PHPUnit\Framework\MockObject\MockObject;
 use PHPUnit\Framework\TestCase;
 use Psr\Log\LoggerInterface;
@@ -37,8 +38,8 @@ class LogsMessagesTraitTest extends TestCase
         $this->assertFalse(LoggerHolder::isSet());
         $instance = $this->createInstance();
 
-        $this->expectWarning();
-        $this->expectWarningMessageMatches(sprintf('/%s/', $message));
+        $this->expectException(PHPUnitFrameworkException::class);
+        $this->expectExceptionMessageMatches(sprintf('/%s/', $message));
         $instance->run('logWarning', 'foo', ['exception' => new \Exception($message)]);
     }
 
@@ -49,8 +50,8 @@ class LogsMessagesTraitTest extends TestCase
         $this->assertFalse(LoggerHolder::isSet());
         $instance = $this->createInstance();
 
-        $this->expectError();
-        $this->expectErrorMessageMatches(sprintf('/%s/', $message));
+        $this->expectException(PHPUnitFrameworkException::class);
+        $this->expectExceptionMessageMatches(sprintf('/%s/', $message));
         $instance->run('logError', 'foo', ['exception' => new \Exception($message)]);
     }
 
diff --git a/tests/Unit/Context/DebugScopeTest.php b/tests/Unit/Context/DebugScopeTest.php
index 2f26dddd..8e1e7c86 100644
--- a/tests/Unit/Context/DebugScopeTest.php
+++ b/tests/Unit/Context/DebugScopeTest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
 namespace OpenTelemetry\Tests\Unit\Context;
 
 use OpenTelemetry\Context\Context;
+use PHPUnit\Framework\Exception as PHPUnitFrameworkException;
 use PHPUnit\Framework\TestCase;
 
 /**
@@ -18,8 +19,8 @@ final class DebugScopeTest extends TestCase
 
         $scope1->detach();
 
-        $this->expectNotice();
-        $this->expectNoticeMessage('already detached');
+        $this->expectException(PHPUnitFrameworkException::class);
+        $this->expectExceptionMessage('already detached');
         $scope1->detach();
     }
 
@@ -29,8 +30,8 @@ final class DebugScopeTest extends TestCase
         $scope2 = Context::getCurrent()->activate();
 
         try {
-            $this->expectNotice();
-            $this->expectNoticeMessage('another scope');
+            $this->expectException(PHPUnitFrameworkException::class);
+            $this->expectExceptionMessage('another scope');
             $scope1->detach();
         } finally {
             $scope2->detach();
@@ -45,8 +46,8 @@ final class DebugScopeTest extends TestCase
         Context::storage()->switch(1);
 
         try {
-            $this->expectNotice();
-            $this->expectNoticeMessage('different execution context');
+            $this->expectException(PHPUnitFrameworkException::class);
+            $this->expectExceptionMessage('different execution context');
             $scope1->detach();
         } finally {
             Context::storage()->switch(0);
@@ -57,8 +58,8 @@ final class DebugScopeTest extends TestCase
     public function test_missing_scope_detach(): void
     {
         try {
-            $this->expectNotice();
-            $this->expectNoticeMessage('missing call');
+            $this->expectException(PHPUnitFrameworkException::class);
+            $this->expectExceptionMessage('missing call');
             Context::getCurrent()->activate();
         } finally {
             /** @psalm-suppress PossiblyNullReference */
diff --git a/tests/Unit/SDK/Common/Dev/Compatibility/UtilTest.php b/tests/Unit/SDK/Common/Dev/Compatibility/UtilTest.php
index c0d9aacd..21f250c2 100644
--- a/tests/Unit/SDK/Common/Dev/Compatibility/UtilTest.php
+++ b/tests/Unit/SDK/Common/Dev/Compatibility/UtilTest.php
@@ -6,6 +6,7 @@ namespace OpenTelemetry\Tests\Unit\SDK\Common\Dev\Compatibility;
 
 use Generator;
 use OpenTelemetry\SDK\Common\Dev\Compatibility\Util;
+use PHPUnit\Framework\Exception as PHPUnitFrameworkException;
 use PHPUnit\Framework\TestCase;
 
 /**
@@ -41,11 +42,11 @@ class UtilTest extends TestCase
     /**
      * @dataProvider errorLevelProvider
      */
-    public function test_trigger_class_deprecation_notice(int $level, string $expectedError): void
+    public function test_trigger_class_deprecation_notice(int $level): void
     {
         Util::setErrorLevel($level);
 
-        $this->{$expectedError}();
+        $this->expectException(PHPUnitFrameworkException::class);
 
         Util::triggerClassDeprecationNotice(Util::class, self::class);
     }
@@ -53,11 +54,11 @@ class UtilTest extends TestCase
     /**
      * @dataProvider errorLevelProvider
      */
-    public function test_trigger_method_deprecation_notice_without_class(int $level, string $expectedError): void
+    public function test_trigger_method_deprecation_notice_without_class(int $level): void
     {
         Util::setErrorLevel($level);
 
-        $this->{$expectedError}();
+        $this->expectException(PHPUnitFrameworkException::class);
 
         Util::triggerMethodDeprecationNotice(Util::class, __METHOD__);
     }
@@ -65,21 +66,21 @@ class UtilTest extends TestCase
     /**
      * @dataProvider errorLevelProvider
      */
-    public function test_trigger_method_deprecation_notice_with_class(int $level, string $expectedError): void
+    public function test_trigger_method_deprecation_notice_with_class(int $level): void
     {
         Util::setErrorLevel($level);
 
-        $this->{$expectedError}();
+        $this->expectException(PHPUnitFrameworkException::class);
 
         Util::triggerMethodDeprecationNotice(Util::class, 'foo', self::class);
     }
 
     public function errorLevelProvider(): Generator
     {
-        yield [E_USER_DEPRECATED, 'expectDeprecation'];
-        yield [E_USER_NOTICE, 'expectNotice'];
-        yield [E_USER_WARNING, 'expectWarning'];
-        yield [E_USER_ERROR, 'expectError'];
+        yield [E_USER_DEPRECATED];
+        yield [E_USER_NOTICE];
+        yield [E_USER_WARNING];
+        yield [E_USER_ERROR];
     }
 
     public function test_turn_errors_off(): void
diff --git a/tests/Unit/SDK/FactoryRegistryTest.php b/tests/Unit/SDK/FactoryRegistryTest.php
index f5a28f73..9e8b1eb8 100644
--- a/tests/Unit/SDK/FactoryRegistryTest.php
+++ b/tests/Unit/SDK/FactoryRegistryTest.php
@@ -8,6 +8,7 @@ use OpenTelemetry\SDK\Common\Export\TransportFactoryInterface;
 use OpenTelemetry\SDK\Metrics\MetricExporterFactoryInterface;
 use OpenTelemetry\SDK\Registry;
 use OpenTelemetry\SDK\Trace\SpanExporter\SpanExporterFactoryInterface;
+use PHPUnit\Framework\Exception as PHPUnitFrameworkException;
 use PHPUnit\Framework\TestCase;
 
 /**
@@ -79,7 +80,7 @@ class FactoryRegistryTest extends TestCase
      */
     public function test_register_invalid_transport_factory($factory): void
     {
-        $this->expectWarning();
+        $this->expectException(PHPUnitFrameworkException::class);
         Registry::registerTransportFactory('http', $factory, true);
     }
 
@@ -88,7 +89,7 @@ class FactoryRegistryTest extends TestCase
      */
     public function test_register_invalid_span_exporter_factory($factory): void
     {
-        $this->expectWarning();
+        $this->expectException(PHPUnitFrameworkException::class);
         Registry::registerSpanExporterFactory('foo', $factory, true);
     }
 
@@ -97,7 +98,7 @@ class FactoryRegistryTest extends TestCase
      */
     public function test_register_invalid_metric_exporter_factory($factory): void
     {
-        $this->expectWarning();
+        $this->expectException(PHPUnitFrameworkException::class);
         Registry::registerMetricExporterFactory('foo', $factory, true);
     }
 
diff --git a/tests/Unit/SDK/Metrics/Stream/MetricStreamTest.php b/tests/Unit/SDK/Metrics/Stream/MetricStreamTest.php
index aba5c919..2b043ed4 100644
--- a/tests/Unit/SDK/Metrics/Stream/MetricStreamTest.php
+++ b/tests/Unit/SDK/Metrics/Stream/MetricStreamTest.php
@@ -19,6 +19,7 @@ use OpenTelemetry\SDK\Metrics\Stream\MetricAggregator;
 use OpenTelemetry\SDK\Metrics\Stream\StreamWriter;
 use OpenTelemetry\SDK\Metrics\Stream\SynchronousMetricStream;
 use const PHP_INT_SIZE;
+use PHPUnit\Framework\Exception as PHPUnitFrameworkException;
 use PHPUnit\Framework\TestCase;
 
 /**
@@ -337,8 +338,8 @@ final class MetricStreamTest extends TestCase
             $s->register(Temporality::DELTA);
         }
 
-        $this->expectWarning();
-        $this->expectWarningMessageMatches('/^GMP extension required to register over \d++ readers$/');
+        $this->expectException(PHPUnitFrameworkException::class);
+        $this->expectExceptionMessageMatches('/^GMP extension required to register over \d++ readers$/');
         $s->register(Temporality::DELTA);
     }