Skip to content

symfony 7 #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ jobs:
dependencies: highest
behat-suite: cli

- php-version: '8.3'
dependencies: highest
behat-suite: standalone
composer-stability: 'dev'

- php-version: '8.3'
dependencies: highest
behat-suite: embedded
composer-stability: 'dev'

- php-version: '8.3'
dependencies: highest
behat-suite: cli
composer-stability: 'dev'

steps:
- name: Checkout project
uses: actions/checkout@v4
Expand All @@ -74,6 +89,10 @@ jobs:
php-version: ${{ matrix.php-version }}
tools: 'composer:v2'

- name: Set composer stability
if: ${{ matrix.composer-stability }}
run: composer config minimum-stability ${{ matrix.composer-stability }}

- name: Install dependencies with Composer
uses: ramsey/composer-install@v2
with:
Expand All @@ -95,4 +114,4 @@ jobs:
run: |
vendor/bin/phpunit
vendor/bin/phpspec run
vendor/bin/behat --suite=${{ matrix.behat-suite }}
vendor/bin/behat -vv --suite=${{ matrix.behat-suite }}
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"description": "Shell for PHPCR",
"require": {
"php": "^8.0",
"symfony/console": "^5.0 || ^6.0",
"jackalope/jackalope": "^1.3.4 || ^2.0",
"symfony/console": "^5.4 || ^6.4 || ^7.0",
"phpcr/phpcr": "^2.1",
"phpcr/phpcr-utils": "^1.2",
"symfony/finder": "^5.0 || ^6.0",
"symfony/serializer": "^5.0 || ^6.0",
"symfony/yaml": "^5.0 || ^6.0",
"symfony/dependency-injection": "^5.0 || ^6.0",
"symfony/expression-language": "^5.0 || ^6.0",
"phpcr/phpcr-utils": "^1.2 || ^2.0",
"symfony/finder": "^5.4 || ^6.4 || ^7.0",
"symfony/serializer": "^5.4 || ^6.4 || ^7.0",
"symfony/yaml": "^5.4 || ^6.4 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0",
"symfony/expression-language": "^5.4 || ^6.4 || ^7.0",
"dantleech/glob-finder": "^1.0"
},
"require-dev": {
Expand Down
24 changes: 12 additions & 12 deletions spec/PHPCR/Shell/Query/UpdateParserSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use PHPCR\Query\QOM\PropertyValueInterface;
use PHPCR\Query\QOM\QueryObjectModelConstantsInterface;
use PHPCR\Query\QOM\QueryObjectModelFactoryInterface;
use PHPCR\Query\QOM\SourceInterface;
use PHPCR\Query\QOM\SelectorInterface;
use PHPCR\Query\QueryInterface;
use PhpSpec\ObjectBehavior;

Expand All @@ -42,17 +42,17 @@ public function it_should_provide_a_qom_object_for_selecting(
QueryObjectModelFactoryInterface $qomf,
ChildNodeJoinConditionInterface $joinCondition,
JoinInterface $join,
SourceInterface $parentSource,
SourceInterface $childSource,
SelectorInterface $parentSelector,
SelectorInterface $childSelector,
PropertyValueInterface $childValue,
LiteralInterface $literalValue,
ComparisonInterface $comparison,
QueryInterface $query
) {
$qomf->selector('parent', 'mgnl:page')->willReturn($parentSource);
$qomf->selector('child', 'mgnl:metaData')->willReturn($childSource);
$qomf->selector('parent', 'mgnl:page')->willReturn($parentSelector);
$qomf->selector('child', 'mgnl:metaData')->willReturn($childSelector);
$qomf->childNodeJoinCondition('child', 'parent')->willReturn($joinCondition);
$qomf->join($parentSource, $childSource, QueryObjectModelConstantsInterface::JCR_JOIN_TYPE_INNER, $joinCondition)->willReturn($join);
$qomf->join($parentSelector, $childSelector, QueryObjectModelConstantsInterface::JCR_JOIN_TYPE_INNER, $joinCondition)->willReturn($join);
$qomf->propertyValue('child', 'mgnl:template')->willReturn($childValue);
$qomf->literal('standard-templating-kit:stkNews')->willReturn($literalValue);
$qomf->comparison($childValue, QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO, $literalValue)->willReturn($comparison);
Expand All @@ -68,9 +68,9 @@ public function it_should_provide_a_qom_object_for_selecting(
WHERE
child.[mgnl:template] = 'standard-templating-kit:stkNews'
EOT;
$res = $this->parse($sql);
$res = $this->parseUpdate($sql);

$res->offsetGet(0)->shouldHaveType('PHPCR\Query\QueryInterface');
$res->offsetGet(0)->shouldHaveType(QueryInterface::class);
$res->offsetGet(1)->shouldReturn([
[
'selector' => 'parent',
Expand All @@ -87,7 +87,7 @@ public function it_should_provide_a_qom_object_for_selecting(

public function it_should_parse_functions(
QueryObjectModelFactoryInterface $qomf,
SourceInterface $source,
SelectorInterface $source,
QueryInterface $query
) {
$qomf->selector('a', 'dtl:article')->willReturn($source);
Expand All @@ -96,14 +96,14 @@ public function it_should_parse_functions(
$sql = <<<'EOT'
UPDATE [dtl:article] AS a SET a.tags = array_replace(a.tags, 'asd', 'dsa')
EOT;
$res = $this->parse($sql);
$res = $this->parseUpdate($sql);

$res->offsetGet(0)->shouldHaveType('PHPCR\Query\QueryInterface');
}

public function it_should_parse_apply(
QueryObjectModelFactoryInterface $qomf,
SourceInterface $source,
SelectorInterface $source,
QueryInterface $query
) {
$qomf->selector('a', 'dtl:article')->willReturn($source);
Expand All @@ -112,7 +112,7 @@ public function it_should_parse_apply(
$sql = <<<'EOT'
UPDATE [dtl:article] AS a APPLY nodetype_add('nt:barbar')
EOT;
$res = $this->parse($sql);
$res = $this->parseUpdate($sql);

$res->offsetGet(0)->shouldHaveType('PHPCR\Query\QueryInterface');
}
Expand Down
30 changes: 14 additions & 16 deletions src/PHPCR/Shell/Console/Application/ShellApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
use PHPCR\Shell\Console\Command\Phpcr as CommandPhpcr;
use PHPCR\Shell\Console\Command\Phpcr\BasePhpcrCommand;
use PHPCR\Shell\Console\Command\Shell as CommandShell;
use PHPCR\Shell\DependencyInjection\ContainerAwareInterface;
use PHPCR\Shell\Event;
use PHPCR\Shell\Event\ApplicationInitEvent;
use PHPCR\Shell\Event\PhpcrShellEvents;
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;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\EventDispatcher\EventDispatcher;

/**
Expand All @@ -42,7 +43,7 @@ class ShellApplication extends Application
protected $showUnsupported = false;

/**
* @var Symfony\Component\DependencyInjection\ContainerBuilder
* @var ContainerBuilder
*/
protected $container;

Expand Down Expand Up @@ -200,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 @@ -233,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 @@ -278,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 @@ -306,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
7 changes: 5 additions & 2 deletions src/PHPCR/Shell/Console/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@

namespace PHPCR\Shell\Console\Command;

use PHPCR\Shell\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class BaseCommand extends Command implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
private $container;

public function setContainer(ContainerInterface $container = null)
public function setContainer(ContainerInterface $container = null): void
{
$this->container = $container;
}
Expand Down
3 changes: 2 additions & 1 deletion src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ public function execute(InputInterface $input, OutputInterface $output): int
if (!$globHelper->isGlobbed($session->getAbsPath($path))) {
throw $e;
}
$path = $session->getAbsPath($path);

$parentPath = $this->get('helper.path')->getParentPath($path);

$filter = substr($path, strlen($parentPath));

if ($filter[0] == '/') {
if ('/' === $filter[0]) {
$filter = substr($filter, 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
$qm = $session->getWorkspace()->getQueryManager();

$updateParser = new UpdateParser($qm->getQOMFactory());
$res = $updateParser->parse($sql);
$res = $updateParser->parseUpdate($sql);
$query = $res->offsetGet(0);
$updates = $res->offsetGet(1);
$applies = $res->offsetGet(3);
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
Loading
Loading