Skip to content

Commit

Permalink
style: fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Jul 6, 2024
1 parent 51cf8c2 commit 28985af
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ senders using the `-s` option.
For instance, to simultaneously use the console, file, and server senders, you would input:

```bash
vendor/bin/trap -s console -s file -s server
vendor/bin/trap -sconsole -sfile -sserver
```

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"@putenv XDEBUG_MODE=coverage",
"roave-infection-static-analysis-plugin --ansi --configuration=infection.json.dist --logger-github --ignore-msi-with-no-mutations --only-covered"
],
"psalm": "psalm --show-info=true",
"psalm": "psalm",
"psalm:baseline": "psalm --set-baseline=psalm-baseline.xml",
"psalm:ci": "psalm --output-format=github --shepherd --show-info=false --stats --threads=4",
"refactor": "rector process --config=rector.php",
Expand Down
67 changes: 64 additions & 3 deletions src/Command/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ protected function execute(
): int {
$this->logger = new Logger($output);

// XHProf
$this->sendContent('yii-xhprof.http');
$this->mail2($output, true);
// $this->sendContent('yii-xhprof.http');
die;

$this->dump();

Check failure on line 42 in src/Command/Test.php

View workflow job for this annotation

GitHub Actions / phpstan (ubuntu-latest, 8.2, locked)

Unreachable statement - code above always terminates.

Check failure on line 42 in src/Command/Test.php

View workflow job for this annotation

GitHub Actions / phpstan (ubuntu-latest, 8.2, locked)

Unreachable statement - code above always terminates.
\usleep(100_000);
Expand All @@ -59,6 +60,17 @@ private function dump(): void
$_SERVER['VAR_DUMPER_FORMAT'] = 'server';
$_SERVER['VAR_DUMPER_SERVER'] = "$this->addr:$this->port";

trap(
index: \substr(\file_get_contents(__FILE__), 0, 312),
)->code(
syntax: 'php',
// editable: true,
// decorated: 'twitter',
// theme: 'dark',
);

trap(fuck: true);

trap(['foo' => 'bar']);
trap(123);
trap(new \DateTimeImmutable());
Expand Down Expand Up @@ -94,6 +106,36 @@ private function dump(): void
}
}

private function mail2(OutputInterface $output, bool $multipart = false): void
{
try {
$socket = \socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
\socket_connect($socket, $this->addr, $this->port);

$this->sendMailPackage($output, $socket, '', '220 ');
$this->sendMailPackage($output, $socket, "HELO\r\n", '250 ');
$this->sendMailPackage($output, $socket, "MAIL FROM: <someusername@foo.bar>\r\n", '250 ');
$this->sendMailPackage($output, $socket, "RCPT TO: <user1@company.tld>\r\n", '250 ');
$this->sendMailPackage($output, $socket, "RCPT TO: <user2@company.tld>\r\n", '250 ');
$this->sendMailPackage($output, $socket, "DATA\r\n", '354 ');

$this->sendMailPackage(
$output,
$socket,
\file_get_contents(Info::TRAP_ROOT . '/resources/payloads/yii-mail.http'),
'250 ',
);

// End of data
$this->sendMailPackage($output, $socket, "QUIT\r\n", '221 ');

\socket_close($socket);

} catch (\Throwable $e) {
$this->logger->exception($e, 'Mail protocol error', important: true);
}
}

private function mail(OutputInterface $output, bool $multipart = false): void

Check failure on line 139 in src/Command/Test.php

View workflow job for this annotation

GitHub Actions / phpstan (ubuntu-latest, 8.2, locked)

Method Buggregator\Trap\Command\Test::mail() is unused.

Check failure on line 139 in src/Command/Test.php

View workflow job for this annotation

GitHub Actions / phpstan (ubuntu-latest, 8.2, locked)

Method Buggregator\Trap\Command\Test::mail() is unused.
{
try {
Expand Down Expand Up @@ -141,7 +183,26 @@ private function mail(OutputInterface $output, bool $multipart = false): void
$this->sendMailPackage(
$output,
$socket,
"<p>This is what displays in most modern email clients</p>\r\n",
'<img src="cid:4486bda9ad8b1f422deaf6a750194668@trap">'
. "<p>This is what displays in most modern email clients</p>\r\n",
'',
);
$this->sendMailPackage($output, $socket, "\r\n", '');
$this->sendMailPackage($output, $socket, "--boundary-string--\r\n", '');
// Image
$this->sendMailPackage(
$output,
$socket,
"Content-Type: image/png; name=4486bda9ad8b1f422deaf6a750194668@trap\r\n",
'',
);
$this->sendMailPackage($output, $socket, "Content-Transfer-Encoding: base64\r\n", '');
$this->sendMailPackage($output, $socket, "Content-Disposition: inline; name=\"4486bda9ad8b1f422deaf6a750194668@trap\"; filename=logo-embeddable\r\n", '');
$this->sendMailPackage($output, $socket, "\r\n", '');
$this->sendMailPackage(
$output,
$socket,
\base64_encode(\file_get_contents(Info::TRAP_ROOT . '/resources/payloads/logo.png')) . "\r\n",
'',
);
$this->sendMailPackage($output, $socket, "\r\n", '');
Expand Down

0 comments on commit 28985af

Please sign in to comment.