Skip to content

Commit

Permalink
adjust to symfony BC break
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Feb 20, 2024
1 parent e7c2f73 commit 4666529
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 37 deletions.
25 changes: 11 additions & 14 deletions src/PHPCR/Shell/Console/Application/ShellApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use PHPCR\Shell\PhpcrShell;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -201,7 +201,7 @@ protected function registerShellCommands()
/**
* Configure the output formatter.
*/
private function configureFormatter(OutputFormatter $formatter)
private function configureFormatter(OutputFormatterInterface $formatter)
{
$style = new OutputFormatterStyle('yellow', null, ['bold']);
$formatter->setStyle('pathbold', $style);
Expand Down Expand Up @@ -234,10 +234,7 @@ private function configureFormatter(OutputFormatter $formatter)
$formatter->setStyle('exception', $style);
}

/**
* {@inheritdoc}
*/
public function doRun(InputInterface $input, OutputInterface $output)
public function doRun(InputInterface $input, OutputInterface $output): int
{
$this->init();

Expand Down Expand Up @@ -279,19 +276,19 @@ protected function getDefaultCommand()
*
* {@inheritdoc}
*/
public function add(Command $command)
public function add(Command $command): ?Command
{
if ($command instanceof ContainerAwareInterface) {
$command->setContainer($this->container);
}

if ($command instanceof BasePhpcrCommand) {
if ($this->showUnsupported || $command->isSupported()) {
parent::add($command);
}
} else {
parent::add($command);
if ($command instanceof BasePhpcrCommand
&& ($this->showUnsupported || $command->isSupported())
) {
return parent::add($command);
}

return parent::add($command);
}

public function dispatchProfileInitEvent(InputInterface $sessionInput, OutputInterface $output)
Expand All @@ -307,7 +304,7 @@ public function dispatchProfileInitEvent(InputInterface $sessionInput, OutputInt
*
* {@inheritdoc}
*/
public function all($namespace = null)
public function all($namespace = null): array
{
$this->init();

Expand Down
4 changes: 2 additions & 2 deletions src/PHPCR/Shell/Console/Helper/EditorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function fromStringWithMessage($string, $message, $messagePrefix = '# ',

$line = current($res);

while (0 === strpos($line, $messagePrefix)) {
while (str_starts_with($line, $messagePrefix)) {
$line = next($res);
}

Expand All @@ -99,7 +99,7 @@ public function fromStringWithMessage($string, $message, $messagePrefix = '# ',
return implode("\n", $out);
}

public function getName()
public function getName(): string
{
return 'editor';
}
Expand Down
2 changes: 1 addition & 1 deletion src/PHPCR/Shell/Console/Helper/NodeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function assertNodeIsVersionable(NodeInterface $node)
}
}

public function getName()
public function getName(): string
{
return 'node';
}
Expand Down
5 changes: 1 addition & 4 deletions src/PHPCR/Shell/Console/Helper/PathHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ public function getNodeName($path)
return StaticPathHelper::getNodeName($path);
}

/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return 'path';
}
Expand Down
3 changes: 2 additions & 1 deletion src/PHPCR/Shell/Console/Helper/RepositoryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace PHPCR\Shell\Console\Helper;

use PHPCR\Shell\Phpcr\SessionManager;
use PHPCR\Util\Console\Helper\PhpcrHelper;
use Symfony\Component\Console\Helper\Helper;

class RepositoryHelper extends Helper
Expand Down Expand Up @@ -80,7 +81,7 @@ private function loadDescriptors()
}
}

public function getName()
public function getName(): string
{
return 'repository';
}
Expand Down
5 changes: 1 addition & 4 deletions src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ public function __construct(TextHelper $textHelper, Config $config)
$this->config = $config;
}

/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return 'result_formatter';
}
Expand Down
10 changes: 4 additions & 6 deletions src/PHPCR/Shell/Console/Helper/TextHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TextHelper extends Helper
/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return 'text';
}
Expand All @@ -43,17 +43,15 @@ public function getName()
* @param int $length Truncate to this length
* @param string $alignment Align to the "left" or the "right"
* @param string $delimString String to use to use to indicate the truncation
*
* @return string
*/
public function truncate($string, $length = null, $alignment = null, $delimString = null)
public function truncate($string, $length = null, $alignment = null, $delimString = null): string
{
if (null === $length) {
$length = $this->truncateLength;
}

$alignment = $alignment === null ? 'left' : $alignment;
$delimString = $delimString === null ? '...' : $delimString;
$alignment = $alignment ?? 'left';
$delimString = $delimString ?? '...';
$delimLen = strlen($delimString);

if (!in_array($alignment, ['left', 'right'])) {
Expand Down
6 changes: 3 additions & 3 deletions src/PHPCR/Shell/Console/Input/StringInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ public function __construct($command)
{
$this->rawCommand = trim($command);

if (strpos(strtolower($this->rawCommand), 'select') === 0) {
if (stripos($this->rawCommand, 'select') === 0) {
$command = 'select'.substr($command, 6);
$this->isQuery = true;
}

if (strpos(strtolower($this->rawCommand), 'update') === 0) {
if (stripos($this->rawCommand, 'update') === 0) {
$command = 'update'.substr($command, 6);
$this->isQuery = true;
}

if (strpos(strtolower($this->rawCommand), 'delete') === 0) {
if (stripos($this->rawCommand, 'delete') === 0) {
$command = 'delete'.substr($command, 6);
$this->isQuery = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/PHPCR/Shell/Test/ContextBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ public function iShouldSeeATableContainingTheFollowingRows(TableNode $table)
continue;
}

if (false !== strpos($line, $cell)) {
if (str_contains($line, $cell)) {
$foundCells++;
}
}

if ($foundCells == count($row)) {
if ($foundCells === count($row)) {
$foundRows++;
}
}
Expand Down

0 comments on commit 4666529

Please sign in to comment.