Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Console run commands when they are SignalableCommandInterface and don´t have signalsToDispatchEvent #42076

Closed
@PaolaRuby

Description

@PaolaRuby

Description
When a command extends a class wich implements SignalableCommandInterface but the command has empty signals to dispatch, it still can be executed, It can be useful when the extension is not available and the command is necessary.
Also, it can be used like a workaround for support other environments, for example windows servers, they don't have pcntl extension

Example
If change this

if ($command instanceof SignalableCommandInterface) {
if (!$this->signalRegistry) {
throw new RuntimeException('Unable to subscribe to signal events. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.');
}
if ($this->dispatcher) {
foreach ($this->signalsToDispatchEvent as $signal) {

for this

if ($command instanceof SignalableCommandInterface) {
    if (!$this->signalRegistry && !(empty($this->signalsToDispatchEvent) && empty($command->getSubscribedSignals()))) {
        throw new RuntimeException('Unable to subscribe to signal events. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.');
    }

Now when signalsToDispatchEvent has signals still throws RuntimeException, but when it don't has, it continues, maybe i can make a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions