Skip to content

Commit f22e0a3

Browse files
SerafimArtswolfy-j
andauthored
Remove debug handlers (#66)
* - minor CS * Remove debug handlers * - update README Co-authored-by: Wolfy-J <wolfy.jd@gmail.com>
1 parent 6e12e28 commit f22e0a3

File tree

3 files changed

+2
-79
lines changed

3 files changed

+2
-79
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ $ composer require temporal/sdk
2424

2525
## Usage
2626

27-
See [example](/example) to get started.
28-
29-
27+
See [examples](https://github.com/temporalio/samples-php) to get started.
3028

3129
No documentation available at this time.

src/Internal/Support/DateTime.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ public static function parse($time = null, $tz = null): CarbonInterface
3535

3636
// Note: PHP does not support accuracy greater than 8 (microseconds)
3737
if (\strlen($accuracy) > 8) {
38-
//$rounded = \sprintf('%s.%sZ', $datetime, \substr($accuracy, 0, 8));
39-
40-
// Trigger warning
41-
//$message = \sprintf(self::NOTICE_PRECISION_LOSS, $time, $rounded);
42-
//@\trigger_error($message, \E_USER_NOTICE);
43-
4438
$time = \sprintf('%s.%sZ', $datetime, \substr($accuracy, 0, 8));
4539
}
4640
}

src/Worker/Transport/RoadRunner.php

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Spiral\RoadRunner\EnvironmentInterface;
1919
use Spiral\RoadRunner\Payload;
2020
use Spiral\RoadRunner\Worker;
21-
use Symfony\Component\VarDumper\Dumper\CliDumper;
2221
use Temporal\Exception\ProtocolException;
2322
use Temporal\Exception\TransportException;
2423
use Spiral\RoadRunner\WorkerInterface as RoadRunnerWorker;
@@ -47,7 +46,6 @@ public function __construct(RoadRunnerWorker $worker)
4746
{
4847
$this->worker = $worker;
4948
$this->codec = new JsonCodec();
50-
$this->bootStdoutHandlers();
5149
}
5250

5351
/**
@@ -67,9 +65,7 @@ public static function create(EnvironmentInterface $env = null): HostConnectionI
6765
public function waitBatch(): ?CommandBatch
6866
{
6967
/** @var Payload $payload */
70-
$payload = $this->interceptErrors(
71-
fn() => $this->worker->waitPayload()
72-
);
68+
$payload = $this->worker->waitPayload();
7369

7470
if ($payload === null) {
7571
return null;
@@ -107,71 +103,6 @@ public function error(\Throwable $error): void
107103
}
108104
}
109105

110-
/**
111-
* @return $this
112-
*/
113-
private function bootStdoutHandlers(): self
114-
{
115-
// symfony/var-dumper interceptor
116-
if (\class_exists(CliDumper::class)) {
117-
CliDumper::$defaultOutput = 'php://stderr';
118-
}
119-
120-
// Intercept all output messages
121-
\ob_start(fn(string $chunk) => $this->write($chunk), 10 * 1024);
122-
123-
// Intercept all exceptions
124-
\set_exception_handler(fn(\Throwable $e) => $this->writeException($e));
125-
126-
// Intercept all errors
127-
\set_error_handler(
128-
function (int $code, string $message, string $file, int $line): void {
129-
$this->writeException(
130-
new \ErrorException($message, $code, $code, $file, $line)
131-
);
132-
}
133-
);
134-
135-
return $this;
136-
}
137-
138-
/**
139-
* @param string $message
140-
*/
141-
private function write(string $message): void
142-
{
143-
\file_put_contents('php://stderr', $message);
144-
}
145-
146-
/**
147-
* @param \Throwable $e
148-
*/
149-
private function writeException(\Throwable $e): void
150-
{
151-
$this->write((string)$e);
152-
}
153-
154-
/**
155-
* @param \Closure $expr
156-
* @return mixed
157-
*/
158-
private function interceptErrors(\Closure $expr)
159-
{
160-
$handler = static function (int $code, string $message, string $file, int $line): void {
161-
$error = new \ErrorException($message, $code, $code, $file, $line);
162-
163-
throw new TransportException($message, $code, $error);
164-
};
165-
166-
\set_error_handler($handler);
167-
168-
try {
169-
return $expr();
170-
} finally {
171-
\restore_error_handler();
172-
}
173-
}
174-
175106
/**
176107
* @param JsonHeaders|null $headers
177108
* @return array<string, string>

0 commit comments

Comments
 (0)