Skip to content

Commit ee65b66

Browse files
⬆️ remove unused coduo/php-matcher dependency - issue #3551 (#3558)
* ⬆️ remove unused coduo/php-matcher dependency - issue #3551 * remove about * add artifact on failure * load fixture * Fix PHP Stan error * Fix API Test * revert change in api test workflow * review change, change with query * add MySQL for API test * add doctrine/lexer dependency * create db only for sqlite
1 parent 34708ee commit ee65b66

File tree

7 files changed

+49
-23
lines changed

7 files changed

+49
-23
lines changed

.github/workflows/api_tests.yaml

+25-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,25 @@ jobs:
88
strategy:
99
matrix:
1010
php-version: [ '8.1', '8.2', '8.3', '8.4' ]
11+
database:
12+
- 'sqlite:///%kernel.project_dir%/var/data/bolt.sqlite'
13+
- 'mysql://bolt:[email protected]/bolt?serverVersion=5.7&charset=utf8mb4'
1114
name: curl tests
15+
services:
16+
mysql:
17+
image: mysql:5.7
18+
ports:
19+
- "3306:3306"
20+
env:
21+
MYSQL_DATABASE: bolt
22+
MYSQL_USER: bolt
23+
MYSQL_PASSWORD: bolt
24+
MYSQL_ROOT_PASSWORD: bolt
25+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
26+
1227
runs-on: ubuntu-latest
28+
env:
29+
DATABASE_URL: ${{matrix.database}}
1330
steps:
1431
- uses: actions/checkout@v4
1532
- uses: shivammathur/setup-php@v2
@@ -23,12 +40,15 @@ jobs:
2340
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2441
- name: Install composer dependencies
2542
run: composer install --prefer-dist --no-progress
43+
- name: Initialise folders
44+
run: sudo chmod -R 777 config/ public/files/ public/theme/ public/thumbs/ var/
45+
- name: create the database
46+
run: ./bin/console doctrine:database:create
47+
if: ${{ startsWith('sqlite', matrix.database) }}
2648
- name: Initialise the database
27-
run: |
28-
sudo chmod -R 777 config/ public/files/ public/theme/ public/thumbs/ var/
29-
./bin/console doctrine:database:create
30-
./bin/console doctrine:schema:create
31-
symfony server:start --no-tls --port=8088 -d
49+
run: ./bin/console doctrine:schema:create
50+
- name: Starting server
51+
run: symfony server:start --no-tls --port=8088 -d
3252
- name: create api user
3353
run: php bin/console bolt:add-user apiuser apiuser%1 [email protected] API --roles=ROLE_WEBSERVICE
3454
- name: check API user gets content

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"doctrine/doctrine-bundle": "^2.4",
2121
"doctrine/doctrine-fixtures-bundle": "^3.4",
2222
"doctrine/doctrine-migrations-bundle": "^3.2",
23+
"doctrine/lexer": "^2 || ^3",
2324
"doctrine/orm": "^2.10",
2425
"drupol/composer-packages": "^2.0",
2526
"embed/embed": "^3.4",
@@ -97,7 +98,6 @@
9798
"bobdenotter/configuration-notices": "^1.2",
9899
"bobdenotter/weatherwidget": "^1.1",
99100
"bolt/newswidget": "^1.3",
100-
"coduo/php-matcher": "^5.0",
101101
"dama/doctrine-test-bundle": "^6.6.0",
102102
"nyholm/psr7": "^1.4",
103103
"ondram/ci-detector": "^4.1",

src/Api/Extensions/ContentExtension.php

+18-5
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ public function __construct(Config $config)
3434
})->values();
3535
}
3636

37-
public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?string $operationName = null): void
38-
{
37+
public function applyToCollection(
38+
QueryBuilder $queryBuilder,
39+
QueryNameGeneratorInterface $queryNameGenerator,
40+
string $resourceClass,
41+
?string $operationName = null
42+
): void {
3943
/*
4044
* Note: We're not distinguishing between `viewless` and `viewless_listing` here. In the
4145
* context of the API it makes no sense to say "You can get a list, but not the details"
@@ -51,8 +55,14 @@ public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGenerator
5155
}
5256
}
5357

54-
public function applyToItem(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, array $identifiers, ?string $operationName = null, array $context = []): void
55-
{
58+
public function applyToItem(
59+
QueryBuilder $queryBuilder,
60+
QueryNameGeneratorInterface $queryNameGenerator,
61+
string $resourceClass,
62+
array $identifiers,
63+
?string $operationName = null,
64+
array $context = []
65+
): void {
5666
if ($resourceClass === Content::class) {
5767
$this->filterUnpublishedViewlessContent($queryBuilder);
5868
}
@@ -78,7 +88,10 @@ private function filterUnpublishedViewlessContent(QueryBuilder $queryBuilder): v
7888
private function filterUnpublishedViewlessFields(QueryBuilder $queryBuilder): void
7989
{
8090
$rootAlias = $queryBuilder->getRootAliases()[0];
81-
$queryBuilder->join($rootAlias . '.content', 'c', Join::WITH, 'c.status = :status');
91+
92+
$queryBuilder->join($rootAlias . '.content', 'c');
93+
$queryBuilder->andWhere('c.status = :status');
94+
8295
$queryBuilder->setParameter('status', Statuses::PUBLISHED);
8396

8497
//todo: Fix this when https://github.com/doctrine/orm/issues/3835 closed.

src/Doctrine/Functions/Rand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function parse(\Doctrine\ORM\Query\Parser $parser): void
3333
$parser->match(Lexer::T_IDENTIFIER);
3434
$parser->match(Lexer::T_OPEN_PARENTHESIS);
3535

36-
if ($lexer->lookahead['type'] !== Lexer::T_CLOSE_PARENTHESIS) {
36+
if ($lexer->lookahead->type !== Lexer::T_CLOSE_PARENTHESIS) {
3737
$this->expression = $parser->SimpleArithmeticExpression();
3838
}
3939

src/Doctrine/Query/Cast.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ public function getSql(SqlWalker $sqlWalker): string
3030
// alternatively, test if true: $this->first->dispatch($sqlWalker)==='b2_.value',
3131
// b4_.value for /bolt/new/showcases
3232
if ($this->first->dispatch($sqlWalker) === 'b2_.value' ||
33-
$this->first->dispatch($sqlWalker) === 'b4_.value') {
33+
$this->first->dispatch($sqlWalker) === 'b4_.value') {
3434
return $this->first->dispatch($sqlWalker);
3535
}
3636
}
3737

38-
if (! mb_strpos($backend_driver, 'sqlite') && $this->second === 'TEXT') {
38+
if (!mb_strpos($backend_driver, 'sqlite') && $this->second === 'TEXT') {
3939
$this->second = 'CHAR';
4040
}
4141

4242
return sprintf('CAST(%s AS %s)',
4343
$this->first->dispatch($sqlWalker),
4444
$this->second
45-
);
45+
);
4646
}
4747

4848
public function parse(Parser $parser): void
@@ -52,7 +52,7 @@ public function parse(Parser $parser): void
5252
$this->first = $parser->ArithmeticPrimary();
5353
$parser->match(Lexer::T_AS);
5454
$parser->match(Lexer::T_IDENTIFIER);
55-
$this->second = $parser->getLexer()->token['value'];
55+
$this->second = $parser->getLexer()->token->value;
5656
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
5757
}
5858
}

symfony.lock

-6
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@
4646
"cocur/slugify": {
4747
"version": "v4.0.0"
4848
},
49-
"coduo/php-matcher": {
50-
"version": "4.0.0"
51-
},
52-
"coduo/php-to-string": {
53-
"version": "3.0.0"
54-
},
5549
"composer/ca-bundle": {
5650
"version": "1.2.6"
5751
},

templates/pages/about.html.twig

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
<li><a href="https://phpunit.de/" target="_blank">PHPUnit</a>.</li>
8181
<li><a href="http://www.phpspec.net/en/stable/" target="_blank">phpspec</a>.</li>
8282
<li><a href="https://www.cypress.io/" target="_blank">Cypress</a>.</li>
83-
<li><a href="https://github.com/coduo/php-matcher" target="_blank">PHP Matcher</a>.</li>
8483
<li><a href="https://github.com/phpstan/phpstan" target="_blank">PHP Stan</a>.</li>
8584
<li><a href="https://github.com/Symplify/EasyCodingStandard" target="_blank">Easy Coding Standard</a>.</li>
8685
<li><a href="https://blackfire.io/" target="_blank">Blackfire</a>.</li>

0 commit comments

Comments
 (0)