Skip to content

Commit

Permalink
Add deprecated Server alias for new HttpServer class to ensure BC
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Jul 27, 2021
1 parent e654f59 commit 255e891
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Server.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace React\Http;

// Deprecated `Server` is an alias for new `HttpServer` to ensure existing code continues to work as-is.
\class_alias(__NAMESPACE__ . '\\HttpServer', __NAMESPACE__ . '\\Server', true);

// Aid static analysis and IDE autocompletion about this deprecation,
// but don't actually execute during runtime because `HttpServer` is final.
if (!\class_exists(__NAMESPACE__ . '\\Server', false)) {
/**
* @deprecated 1.5.0 See HttpServer instead
* @see HttpServer
*/
final class Server extends HttpServer
{
}
}
15 changes: 15 additions & 0 deletions tests/ServerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace React\Tests\Http;

use React\Http\Server;

class ServerTest extends TestCase
{
public function testDeprecatedServerIsInstanceOfNewHttpServer()
{
$http = new Server(function () { });

$this->assertInstanceOf('React\Http\HttpServer', $http);
}
}

0 comments on commit 255e891

Please sign in to comment.