Skip to content

Commit

Permalink
Fix psalm issues, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Apr 22, 2024
1 parent a8bef6b commit 6793004
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,22 @@ $responder->respond(trap($response)->return());
### Default port

By default, the Trap server operates on port `9912`. However, if you wish to utilize a different port, you can easily
make this adjustment using the `-p` option.

For example, to switch to port 8000, you would use the following command:
Trap automatically recognizes the type of traffic.
Therefore, there is no need to open separate ports for different protocols.
By default, it operates on port `9912`.
However, if you wish to utilize a different port, you can easily make this adjustment using the `-p` option:

```bash
vendor/bin/trap -p 8000
```

Sometimes, it's convenient to run Trap on the same ports that [Buggregator](https://github.com/buggregator/server)
uses by default. Well, that's also possible:

```bash
vendor/bin/trap -p 1025 -p 9912 -p 9913 -p 8000
```

### Choosing Your Senders

Buggregator Trap provides a variety of "senders" that dictate where the dumps will be sent. Currently, the available
Expand Down
11 changes: 9 additions & 2 deletions src/Command/Run.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,18 @@ protected function execute(
* @var SocketServer[] $servers
*/
$servers = [];
foreach ($input->getOption('port') ?: [9912] as $port) {
$ports = $input->getOption('port') ?: [9912];
\assert(\is_array($ports));
foreach ($ports as $port) {
\assert(\is_scalar($port));
\is_numeric($port) or throw new \InvalidArgumentException(
\sprintf('Invalid port `%s`. It must be a number.', $port),

Check failure on line 71 in src/Command/Run.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

PossiblyInvalidArgument

src/Command/Run.php:71:73: PossiblyInvalidArgument: Argument 2 of sprintf expects float|int|object{__tostring()}|string, but possibly different type bool|string provided (see https://psalm.dev/092)

Check failure on line 71 in src/Command/Run.php

View workflow job for this annotation

GitHub Actions / Psalm Validation (PHP 8.2, OS ubuntu-latest)

PossiblyInvalidArgument

src/Command/Run.php:71:73: PossiblyInvalidArgument: Argument 2 of sprintf expects float|int|object{__tostring()}|string, but possibly different type bool|string provided (see https://psalm.dev/092)
);
$servers[] = new SocketServer((int)$port);
$port = (int)$port;
$port > 0 && $port < 65536 or throw new \InvalidArgumentException(
\sprintf('Invalid port `%s`. It must be in range 1-65535.', $port),
);
$servers[] = new SocketServer($port);
}

/** @var non-empty-string[] $senders */
Expand Down

0 comments on commit 6793004

Please sign in to comment.