Skip to content

Commit 206f8cd

Browse files
authored
Merge pull request #225 from phpcr/feature/symfony-7
symfony 7
2 parents 633ff31 + d397b64 commit 206f8cd

20 files changed

+149
-112
lines changed

Diff for: .github/workflows/test-application.yaml

+20-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ jobs:
5757
dependencies: highest
5858
behat-suite: cli
5959

60+
- php-version: '8.3'
61+
dependencies: highest
62+
behat-suite: standalone
63+
composer-stability: 'dev'
64+
65+
- php-version: '8.3'
66+
dependencies: highest
67+
behat-suite: embedded
68+
composer-stability: 'dev'
69+
70+
- php-version: '8.3'
71+
dependencies: highest
72+
behat-suite: cli
73+
composer-stability: 'dev'
74+
6075
steps:
6176
- name: Checkout project
6277
uses: actions/checkout@v4
@@ -74,6 +89,10 @@ jobs:
7489
php-version: ${{ matrix.php-version }}
7590
tools: 'composer:v2'
7691

92+
- name: Set composer stability
93+
if: ${{ matrix.composer-stability }}
94+
run: composer config minimum-stability ${{ matrix.composer-stability }}
95+
7796
- name: Install dependencies with Composer
7897
uses: ramsey/composer-install@v2
7998
with:
@@ -95,4 +114,4 @@ jobs:
95114
run: |
96115
vendor/bin/phpunit
97116
vendor/bin/phpspec run
98-
vendor/bin/behat --suite=${{ matrix.behat-suite }}
117+
vendor/bin/behat -vv --suite=${{ matrix.behat-suite }}

Diff for: composer.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
"description": "Shell for PHPCR",
44
"require": {
55
"php": "^8.0",
6-
"symfony/console": "^5.0 || ^6.0",
76
"jackalope/jackalope": "^1.3.4 || ^2.0",
7+
"symfony/console": "^5.4 || ^6.4 || ^7.0",
88
"phpcr/phpcr": "^2.1",
9-
"phpcr/phpcr-utils": "^1.2",
10-
"symfony/finder": "^5.0 || ^6.0",
11-
"symfony/serializer": "^5.0 || ^6.0",
12-
"symfony/yaml": "^5.0 || ^6.0",
13-
"symfony/dependency-injection": "^5.0 || ^6.0",
14-
"symfony/expression-language": "^5.0 || ^6.0",
9+
"phpcr/phpcr-utils": "^1.2 || ^2.0",
10+
"symfony/finder": "^5.4 || ^6.4 || ^7.0",
11+
"symfony/serializer": "^5.4 || ^6.4 || ^7.0",
12+
"symfony/yaml": "^5.4 || ^6.4 || ^7.0",
13+
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0",
14+
"symfony/expression-language": "^5.4 || ^6.4 || ^7.0",
1515
"dantleech/glob-finder": "^1.0"
1616
},
1717
"require-dev": {

Diff for: spec/PHPCR/Shell/Query/UpdateParserSpec.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use PHPCR\Query\QOM\PropertyValueInterface;
2020
use PHPCR\Query\QOM\QueryObjectModelConstantsInterface;
2121
use PHPCR\Query\QOM\QueryObjectModelFactoryInterface;
22-
use PHPCR\Query\QOM\SourceInterface;
22+
use PHPCR\Query\QOM\SelectorInterface;
2323
use PHPCR\Query\QueryInterface;
2424
use PhpSpec\ObjectBehavior;
2525

@@ -42,17 +42,17 @@ public function it_should_provide_a_qom_object_for_selecting(
4242
QueryObjectModelFactoryInterface $qomf,
4343
ChildNodeJoinConditionInterface $joinCondition,
4444
JoinInterface $join,
45-
SourceInterface $parentSource,
46-
SourceInterface $childSource,
45+
SelectorInterface $parentSelector,
46+
SelectorInterface $childSelector,
4747
PropertyValueInterface $childValue,
4848
LiteralInterface $literalValue,
4949
ComparisonInterface $comparison,
5050
QueryInterface $query
5151
) {
52-
$qomf->selector('parent', 'mgnl:page')->willReturn($parentSource);
53-
$qomf->selector('child', 'mgnl:metaData')->willReturn($childSource);
52+
$qomf->selector('parent', 'mgnl:page')->willReturn($parentSelector);
53+
$qomf->selector('child', 'mgnl:metaData')->willReturn($childSelector);
5454
$qomf->childNodeJoinCondition('child', 'parent')->willReturn($joinCondition);
55-
$qomf->join($parentSource, $childSource, QueryObjectModelConstantsInterface::JCR_JOIN_TYPE_INNER, $joinCondition)->willReturn($join);
55+
$qomf->join($parentSelector, $childSelector, QueryObjectModelConstantsInterface::JCR_JOIN_TYPE_INNER, $joinCondition)->willReturn($join);
5656
$qomf->propertyValue('child', 'mgnl:template')->willReturn($childValue);
5757
$qomf->literal('standard-templating-kit:stkNews')->willReturn($literalValue);
5858
$qomf->comparison($childValue, QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO, $literalValue)->willReturn($comparison);
@@ -68,9 +68,9 @@ public function it_should_provide_a_qom_object_for_selecting(
6868
WHERE
6969
child.[mgnl:template] = 'standard-templating-kit:stkNews'
7070
EOT;
71-
$res = $this->parse($sql);
71+
$res = $this->parseUpdate($sql);
7272

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

8888
public function it_should_parse_functions(
8989
QueryObjectModelFactoryInterface $qomf,
90-
SourceInterface $source,
90+
SelectorInterface $source,
9191
QueryInterface $query
9292
) {
9393
$qomf->selector('a', 'dtl:article')->willReturn($source);
@@ -96,14 +96,14 @@ public function it_should_parse_functions(
9696
$sql = <<<'EOT'
9797
UPDATE [dtl:article] AS a SET a.tags = array_replace(a.tags, 'asd', 'dsa')
9898
EOT;
99-
$res = $this->parse($sql);
99+
$res = $this->parseUpdate($sql);
100100

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

104104
public function it_should_parse_apply(
105105
QueryObjectModelFactoryInterface $qomf,
106-
SourceInterface $source,
106+
SelectorInterface $source,
107107
QueryInterface $query
108108
) {
109109
$qomf->selector('a', 'dtl:article')->willReturn($source);
@@ -112,7 +112,7 @@ public function it_should_parse_apply(
112112
$sql = <<<'EOT'
113113
UPDATE [dtl:article] AS a APPLY nodetype_add('nt:barbar')
114114
EOT;
115-
$res = $this->parse($sql);
115+
$res = $this->parseUpdate($sql);
116116

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

Diff for: src/PHPCR/Shell/Console/Application/ShellApplication.php

+14-16
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@
1515
use PHPCR\Shell\Console\Command\Phpcr as CommandPhpcr;
1616
use PHPCR\Shell\Console\Command\Phpcr\BasePhpcrCommand;
1717
use PHPCR\Shell\Console\Command\Shell as CommandShell;
18+
use PHPCR\Shell\DependencyInjection\ContainerAwareInterface;
1819
use PHPCR\Shell\Event;
1920
use PHPCR\Shell\Event\ApplicationInitEvent;
2021
use PHPCR\Shell\Event\PhpcrShellEvents;
2122
use PHPCR\Shell\PhpcrShell;
2223
use Symfony\Component\Console\Application;
2324
use Symfony\Component\Console\Command\Command;
24-
use Symfony\Component\Console\Formatter\OutputFormatter;
25+
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
2526
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
2627
use Symfony\Component\Console\Input\ArrayInput;
2728
use Symfony\Component\Console\Input\InputInterface;
2829
use Symfony\Component\Console\Output\OutputInterface;
29-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
30+
use Symfony\Component\DependencyInjection\ContainerBuilder;
3031
use Symfony\Component\EventDispatcher\EventDispatcher;
3132

3233
/**
@@ -42,7 +43,7 @@ class ShellApplication extends Application
4243
protected $showUnsupported = false;
4344

4445
/**
45-
* @var Symfony\Component\DependencyInjection\ContainerBuilder
46+
* @var ContainerBuilder
4647
*/
4748
protected $container;
4849

@@ -200,7 +201,7 @@ protected function registerShellCommands()
200201
/**
201202
* Configure the output formatter.
202203
*/
203-
private function configureFormatter(OutputFormatter $formatter)
204+
private function configureFormatter(OutputFormatterInterface $formatter)
204205
{
205206
$style = new OutputFormatterStyle('yellow', null, ['bold']);
206207
$formatter->setStyle('pathbold', $style);
@@ -233,10 +234,7 @@ private function configureFormatter(OutputFormatter $formatter)
233234
$formatter->setStyle('exception', $style);
234235
}
235236

236-
/**
237-
* {@inheritdoc}
238-
*/
239-
public function doRun(InputInterface $input, OutputInterface $output)
237+
public function doRun(InputInterface $input, OutputInterface $output): int
240238
{
241239
$this->init();
242240

@@ -278,19 +276,19 @@ protected function getDefaultCommand()
278276
*
279277
* {@inheritdoc}
280278
*/
281-
public function add(Command $command)
279+
public function add(Command $command): ?Command
282280
{
283281
if ($command instanceof ContainerAwareInterface) {
284282
$command->setContainer($this->container);
285283
}
286284

287-
if ($command instanceof BasePhpcrCommand) {
288-
if ($this->showUnsupported || $command->isSupported()) {
289-
parent::add($command);
290-
}
291-
} else {
292-
parent::add($command);
285+
if ($command instanceof BasePhpcrCommand
286+
&& ($this->showUnsupported || $command->isSupported())
287+
) {
288+
return parent::add($command);
293289
}
290+
291+
return parent::add($command);
294292
}
295293

296294
public function dispatchProfileInitEvent(InputInterface $sessionInput, OutputInterface $output)
@@ -306,7 +304,7 @@ public function dispatchProfileInitEvent(InputInterface $sessionInput, OutputInt
306304
*
307305
* {@inheritdoc}
308306
*/
309-
public function all($namespace = null)
307+
public function all($namespace = null): array
310308
{
311309
$this->init();
312310

Diff for: src/PHPCR/Shell/Console/Command/BaseCommand.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@
1212

1313
namespace PHPCR\Shell\Console\Command;
1414

15+
use PHPCR\Shell\DependencyInjection\ContainerAwareInterface;
1516
use Symfony\Component\Console\Command\Command;
16-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
1717
use Symfony\Component\DependencyInjection\ContainerInterface;
1818

1919
class BaseCommand extends Command implements ContainerAwareInterface
2020
{
21+
/**
22+
* @var ContainerInterface
23+
*/
2124
private $container;
2225

23-
public function setContainer(ContainerInterface $container = null)
26+
public function setContainer(ContainerInterface $container = null): void
2427
{
2528
$this->container = $container;
2629
}

Diff for: src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,13 @@ public function execute(InputInterface $input, OutputInterface $output): int
100100
if (!$globHelper->isGlobbed($session->getAbsPath($path))) {
101101
throw $e;
102102
}
103+
$path = $session->getAbsPath($path);
103104

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

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

108-
if ($filter[0] == '/') {
109+
if ('/' === $filter[0]) {
109110
$filter = substr($filter, 1);
110111
}
111112

Diff for: src/PHPCR/Shell/Console/Command/Phpcr/QueryUpdateCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
7575
$qm = $session->getWorkspace()->getQueryManager();
7676

7777
$updateParser = new UpdateParser($qm->getQOMFactory());
78-
$res = $updateParser->parse($sql);
78+
$res = $updateParser->parseUpdate($sql);
7979
$query = $res->offsetGet(0);
8080
$updates = $res->offsetGet(1);
8181
$applies = $res->offsetGet(3);

Diff for: src/PHPCR/Shell/Console/Helper/EditorHelper.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function fromStringWithMessage($string, $message, $messagePrefix = '# ',
8585

8686
$line = current($res);
8787

88-
while (0 === strpos($line, $messagePrefix)) {
88+
while (str_starts_with($line, $messagePrefix)) {
8989
$line = next($res);
9090
}
9191

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

102-
public function getName()
102+
public function getName(): string
103103
{
104104
return 'editor';
105105
}

Diff for: src/PHPCR/Shell/Console/Helper/NodeHelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function assertNodeIsVersionable(NodeInterface $node)
4545
}
4646
}
4747

48-
public function getName()
48+
public function getName(): string
4949
{
5050
return 'node';
5151
}

Diff for: src/PHPCR/Shell/Console/Helper/PathHelper.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ public function getNodeName($path)
3838
return StaticPathHelper::getNodeName($path);
3939
}
4040

41-
/**
42-
* {@inheritdoc}
43-
*/
44-
public function getName()
41+
public function getName(): string
4542
{
4643
return 'path';
4744
}

Diff for: src/PHPCR/Shell/Console/Helper/RepositoryHelper.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace PHPCR\Shell\Console\Helper;
1414

1515
use PHPCR\Shell\Phpcr\SessionManager;
16+
use PHPCR\Util\Console\Helper\PhpcrHelper;
1617
use Symfony\Component\Console\Helper\Helper;
1718

1819
class RepositoryHelper extends Helper
@@ -80,7 +81,7 @@ private function loadDescriptors()
8081
}
8182
}
8283

83-
public function getName()
84+
public function getName(): string
8485
{
8586
return 'repository';
8687
}

Diff for: src/PHPCR/Shell/Console/Helper/ResultFormatterHelper.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ public function __construct(TextHelper $textHelper, Config $config)
3636
$this->config = $config;
3737
}
3838

39-
/**
40-
* {@inheritdoc}
41-
*/
42-
public function getName()
39+
public function getName(): string
4340
{
4441
return 'result_formatter';
4542
}

Diff for: src/PHPCR/Shell/Console/Helper/TextHelper.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TextHelper extends Helper
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function getName()
34+
public function getName(): string
3535
{
3636
return 'text';
3737
}
@@ -43,17 +43,15 @@ public function getName()
4343
* @param int $length Truncate to this length
4444
* @param string $alignment Align to the "left" or the "right"
4545
* @param string $delimString String to use to use to indicate the truncation
46-
*
47-
* @return string
4846
*/
49-
public function truncate($string, $length = null, $alignment = null, $delimString = null)
47+
public function truncate($string, $length = null, $alignment = null, $delimString = null): string
5048
{
5149
if (null === $length) {
5250
$length = $this->truncateLength;
5351
}
5452

55-
$alignment = $alignment === null ? 'left' : $alignment;
56-
$delimString = $delimString === null ? '...' : $delimString;
53+
$alignment = $alignment ?? 'left';
54+
$delimString = $delimString ?? '...';
5755
$delimLen = strlen($delimString);
5856

5957
if (!in_array($alignment, ['left', 'right'])) {

0 commit comments

Comments
 (0)