Skip to content

Commit

Permalink
Apply fixes from StyleCI (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze authored Jul 28, 2018
1 parent 3b8bf4d commit f99cea9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
29 changes: 15 additions & 14 deletions src/Screens/Completers/Completer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(Readline $readline)
}

/**
* Start completion
* Start completion.
*
* @param string $word
* @param int $startOffset
Expand All @@ -59,7 +59,7 @@ public function __invoke($word, $startOffset, $endOffset)
}

/**
* Search for things related to the completed word and return an array of suggestions
* Search for things related to the completed word and return an array of suggestions.
*
* Use an array with one element to autocomplete the word
*
Expand All @@ -68,7 +68,7 @@ public function __invoke($word, $startOffset, $endOffset)
abstract protected function search();

/**
* Display suggestions or complete the word depending on number of results
* Display suggestions or complete the word depending on number of results.
*
* When returning an array reactphp-stdio will display suggestions with the default behavior.
*
Expand All @@ -78,7 +78,7 @@ abstract protected function search();
protected function handleSearchResults($searchResults)
{
if (empty($searchResults)) {
return null;
return;
}

if (count($searchResults) > 1) {
Expand All @@ -89,7 +89,7 @@ protected function handleSearchResults($searchResults)
}

/**
* Filter suggestions to display
* Filter suggestions to display.
*
* @param array $suggestions
* @return array|null
Expand All @@ -99,11 +99,12 @@ protected function filterSuggestions($suggestions)
if (is_callable($this->filterSuggestionsCallback)) {
$suggestions = ($this->filterSuggestionsCallback)($suggestions);
}

return $suggestions;
}

/**
* Register callback called when more than one suggestion is available
* Register callback called when more than one suggestion is available.
*
* You can use this callback to filter suggestions or to abort the
* default display behavior by returning null
Expand All @@ -116,7 +117,7 @@ public function onSuggestions($callback)
}

/**
* Refresh the input with the completed word and move cursor to end of the word
* Refresh the input with the completed word and move cursor to end of the word.
*
* @param string $newWord
*/
Expand All @@ -125,14 +126,14 @@ protected function completeWord($newWord)
$endQuotedWord = $this->appendQuoteIfNeeded($newWord);

$this->readline->setInput(
$this->getInputBeforeWord() . $endQuotedWord . $this->getInputAfterWord()
$this->getInputBeforeWord().$endQuotedWord.$this->getInputAfterWord()
);

$this->readline->moveCursorTo($this->wordStartOffset + mb_strlen($endQuotedWord));
}

/**
* Return input string before the word
* Return input string before the word.
*
* @return string
*/
Expand All @@ -142,7 +143,7 @@ protected function getInputBeforeWord()
}

/**
* Return input string after the word
* Return input string after the word.
*
* @return string
*/
Expand All @@ -152,7 +153,7 @@ protected function getInputAfterWord()
}

/**
* Return the character before the word
* Return the character before the word.
*
* @return null|string
*/
Expand All @@ -164,7 +165,7 @@ protected function getCharBeforeWord()
}

/**
* Append a quote if word is prefixed with a quote
* Append a quote if word is prefixed with a quote.
*
* @param string $word
* @return string
Expand All @@ -174,12 +175,12 @@ protected function appendQuoteIfNeeded($word)
$char = $this->getCharBeforeWord();

return ($char === '"' || $char === '\'')
? $word . $char
? $word.$char
: $word;
}

/**
* Return the input string
* Return the input string.
*
* @return string
*/
Expand Down
11 changes: 6 additions & 5 deletions src/Screens/Completers/FilenameCompleter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
class FilenameCompleter extends Completer
{
/**
* Search for files and directories corresponding to the word to complete
* Search for files and directories corresponding to the word to complete.
*
* @return array
*/
protected function search() {
return glob($this->word . '*', GLOB_MARK) ?: [];
protected function search()
{
return glob($this->word.'*', GLOB_MARK) ?: [];
}

/**
* Append a quote if path is prefixed with a quote, except for directories
* Append a quote if path is prefixed with a quote, except for directories.
*
* @param string $path
* @return string
Expand All @@ -28,7 +29,7 @@ protected function appendQuoteIfNeeded($path)
$char = $this->getCharBeforeWord();

return ($char === '"' || $char === '\'')
? $path . $char
? $path.$char
: $path;
}
}
4 changes: 2 additions & 2 deletions src/Screens/FilterFileName.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ protected function registerAutocompleter()

protected function refreshScreenWithSuggestions($suggestions, $limit)
{
$firstSuggestions = array_slice($suggestions, 0 , $limit);
$firstSuggestions = array_slice($suggestions, 0, $limit);

$this->terminal->refreshScreen();

$stdio = $this->terminal->getStdio();

$stdio->write("\n" . implode("\n", $firstSuggestions) . "\n");
$stdio->write("\n".implode("\n", $firstSuggestions)."\n");

$count = count($suggestions) - $limit;
if ($count > 0) {
Expand Down

0 comments on commit f99cea9

Please sign in to comment.