magento / magento/magento2-phpstorm-plugin

Generate CLI command creates the function execute as void while int is expected

Open
#1,788 1 comment 1 reaction 0 assignees View on GitHub
bug
Dominant language
Java
Stars
463
Forks
98
Avg merge
1h 6m
Merged PRs (30d)
3

Description

**Describe the bug** (*)

Generate a CLI command via the plugin and it will create a function like

```
/**
* CLI command description.
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output): void
{

}
```

However it should create it as int based on the superclass

```
/**
* Executes the current command.
*
* This method is not abstract because you can use this class
* as a concrete class. In this case, instead of defining the
* execute() method, you set the code to execute by passing
* a Closure to the setCode() method.
*
* @return int 0 if everything went fine, or an exit code
*
* @throws LogicException When this abstract method is not implemented
*
* @see setCode()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
throw new LogicException('You must override the execute() method in the concrete command class.');
}
```

**To Reproduce** (*)

Steps to reproduce the behavior:
1. Generate a new CLI command with the plugin

**Expected behavior** (*)

Returns `int` instead of `void`

**Screenshots**

If applicable, add screenshots to help explain your problem.

**Please complete the following information:** (*)

- OS: [e.g. MacOS or Ubuntu Linux 20.04]
- PhpStorm/Intellij version: [e.g. 2019.3.3]
- Plugin Version: [e.g. 1.0.0]

**Additional context**

Add any other context about the problem here.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the generated CLI command in the Magento PhpStorm plugin and inspect where the execute method template is defined. Compare the generated return type with the superclass signature; done when new commands generate execute with an int return type.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, php
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.