for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of Railt package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Railt\SDL\Frontend;
use Railt\SDL\Frontend\Context\ContextInterface;
use Railt\SDL\Frontend\Interceptor\Factory;
* Class Process
class Process
{
* @var Factory
private $factory;
* Process constructor.
* @param Factory $factory
public function __construct(Factory $factory)
$this->factory = $factory;
}
* @param ContextInterface $ctx
* @param mixed $result
* @return array
public function run(ContextInterface $ctx, $result): array
if ($result instanceof \Generator) {
return $this->await($ctx, $result);
return $this->factory->resolve($ctx, $result);
* @param \Generator $process
public function await(ContextInterface $ctx, \Generator $process): array
while ($process->valid()) {
[$ctx, $value] = $this->factory->resolve($ctx, $process->current());
$value
This error can happen if you refactor code and forget to move the variable initialization.
Let’s take a look at a simple example:
function someFunction() { $x = 5; echo $x; }
The above code is perfectly fine. Now imagine that we re-order the statements:
function someFunction() { echo $x; $x = 5; }
In that case, $x would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.
$x
$process->send($value);
if ($value = $process->getReturn()) {
return $this->factory->resolve($ctx, $value);
return [$ctx, $value];
This error can happen if you refactor code and forget to move the variable initialization.
Let’s take a look at a simple example:
The above code is perfectly fine. Now imagine that we re-order the statements:
In that case,
$x
would be read before it is initialized. This was a very basic example, however the principle is the same for the found issue.