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 7d1423b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 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
13 changes: 10 additions & 3 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),
\sprintf('Invalid port `%s`. It must be a number.', (string)$port),
);
$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 7d1423b

Please sign in to comment.