Skip to content

Commit

Permalink
Change the visibility of properties from public to private
Browse files Browse the repository at this point in the history
  • Loading branch information
msmakouz committed Feb 29, 2024
1 parent 2fc2fa7 commit 706ab24
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[![Latest Stable Version](https://poser.pugx.org/spiral/roadrunner-tcp/v/stable)](https://packagist.org/packages/spiral/roadrunner-tcp)
[![phpunit](https://github.com/spiral/roadrunner-tcp/actions/workflows/phpunit.yml/badge.svg)](https://github.com/spiral/roadrunner-tcp/actions)
[![psalm](https://github.com/spiral/roadrunner-tcp/actions/workflows/psalm.yml/badge.svg)](https://github.com/spiral/roadrunner-tcp/actions)
[![Codecov](https://codecov.io/gh/roadrunner-php/tcp/branch/3.x/graph/badge.svg)](https://codecov.io/gh/roadrunner-php/tcp)
[![Codecov](https://codecov.io/gh/roadrunner-php/tcp/branch/4.x/graph/badge.svg)](https://codecov.io/gh/roadrunner-php/tcp)
[![Total Downloads](https://poser.pugx.org/spiral/roadrunner-tcp/downloads)](https://packagist.org/packages/spiral/roadrunner-tcp)
[![type-coverage](https://shepherd.dev/github/roadrunner-php/tcp/coverage.svg)](https://shepherd.dev/github/spiral/roadrunner-php/tcp)
[![psalm-level](https://shepherd.dev/github/roadrunner-php/tcp/level.svg)](https://shepherd.dev/github/roadrunner-php/tcp)
Expand Down Expand Up @@ -94,7 +94,7 @@ $tcpWorker = new TcpWorker($worker);
while ($request = $tcpWorker->waitRequest()) {

try {
if ($request->event === TcpEvent::Connected) {
if ($request->getEvent() === TcpEvent::Connected) {
// You can close connection according your restrictions
if ($request->getRemoteAddress() !== '127.0.0.1') {
$tcpWorker->close();
Expand Down
15 changes: 5 additions & 10 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,11 @@ final class Request implements RequestInterface
* @param non-empty-string $server Server name, which received data
*/
public function __construct(
/** @since 4.0 This property will be private, use {@see getRemoteAddress()} method. */
public readonly string $remoteAddr,
/** @since 4.0 This property will be private, use {@see getEvent()} method. */
public readonly TcpEvent $event,
/** @since 4.0 This property will be private, use {@see getBody()} method. */
public readonly string $body,
/** @since 4.0 This property will be private, use {@see getConnectionUuid()} method. */
public readonly string $connectionUuid,
/** @since 4.0 This property will be private, use {@see getServer()} method. */
public readonly string $server,
private readonly string $remoteAddr,
private readonly TcpEvent $event,
private readonly string $body,
private readonly string $connectionUuid,
private readonly string $server,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions tests/TcpWorkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public function testRequestShouldBeCreated()

$request = $this->tcpWorker->waitRequest();

$this->assertSame($remoteIp, $request->remoteAddr);
$this->assertSame($server, $request->server);
$this->assertSame($uuid, $request->connectionUuid);
$this->assertSame($event, $request->event);
$this->assertSame($remoteIp, $request->getRemoteAddress());
$this->assertSame($server, $request->getServer());
$this->assertSame($uuid, $request->getConnectionUuid());
$this->assertSame($event, $request->getEvent());
}

public function testReadResponse()
Expand Down

0 comments on commit 706ab24

Please sign in to comment.