Skip to content

Commit 089a384

Browse files
authored
Merge branch 'main' into try-rector-dev-main
2 parents 9a012ea + 6c3cbe2 commit 089a384

File tree

33 files changed

+332
-37
lines changed

33 files changed

+332
-37
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Integration Tests (Windows)
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 8 * * *'
7+
env:
8+
POSTGRES_USER: runner
9+
POSTGRES_PASSWORD: ""
10+
POSTGRES_DB: postgres
11+
12+
jobs:
13+
vitest:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
php:
19+
- 8.4
20+
os:
21+
- windows-latest
22+
env:
23+
POSTGRES_USER: ${{ matrix.os == 'windows-latest' && 'postgres' || 'runner' }}
24+
25+
name: "Run tests: ${{ matrix.os }}"
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Setup PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: ${{ matrix.php }}
35+
extensions: dom, curl, libxml, mbstring, pcntl, fileinfo, pdo, sqlite, pdo_sqlite, pdo_mysql, pdo_pgsql, intl, ftp, zip
36+
coverage: pcov
37+
38+
- name: Setup Bun
39+
uses: oven-sh/setup-bun@v2
40+
41+
- name: Install dependencies
42+
run: bun install --frozen-lockfile
43+
44+
- name: Run build
45+
run: bun run build
46+
47+
- name: Run tests
48+
run: bun run test
49+
50+
phpunit:
51+
runs-on: ${{ matrix.os }}
52+
strategy:
53+
fail-fast: false
54+
matrix:
55+
os:
56+
- windows-latest
57+
php:
58+
- 8.4
59+
database:
60+
- sqlite
61+
- mysql
62+
- postgres
63+
stability:
64+
- prefer-stable
65+
env:
66+
POSTGRES_USER: ${{ matrix.os == 'windows-latest' && 'postgres' || 'runner' }}
67+
68+
name: "Run tests: PHP ${{ matrix.php }} - ${{ matrix.database }} - ${{ matrix.stability }} - ${{ matrix.os }}"
69+
70+
steps:
71+
- name: Checkout code
72+
uses: actions/checkout@v4
73+
74+
- name: Setup PHP
75+
uses: shivammathur/setup-php@v2
76+
with:
77+
php-version: ${{ matrix.php }}
78+
extensions: dom, curl, libxml, mbstring, pcntl, fileinfo, pdo, sqlite, pdo_sqlite, pdo_mysql, pdo_pgsql, intl, ftp, zip
79+
coverage: pcov
80+
81+
- name: Setup problem matchers
82+
run: |
83+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
84+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
85+
86+
- name: Install dependencies
87+
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction
88+
89+
- name: "Setup Redis"
90+
if: ${{ matrix.os != 'windows-latest' }}
91+
uses: supercharge/[email protected]
92+
93+
- name: "Setup MySQL"
94+
if: ${{ matrix.database == 'mysql' }}
95+
uses: ankane/setup-mysql@v1
96+
with:
97+
mysql-version: 8.0
98+
database: "app"
99+
100+
- name: "Setup PostgreSQL"
101+
if: ${{ matrix.database == 'postgres' }}
102+
uses: ankane/setup-postgres@v1
103+
104+
- name: Set database config - ${{ matrix.database }}
105+
run: php -r "copy('tests/Fixtures/Config/database.${{ matrix.database }}.php', 'tests/Fixtures/Config/database.config.php');"
106+
107+
- name: Tempest about
108+
run: php ./tempest about -v
109+
110+
- name: List discovered locations
111+
run: php ./tempest discovery:status
112+
113+
- name: Execute tests
114+
run: php -d"error_reporting = E_ALL & ~E_DEPRECATED" -dmemory_limit=1G vendor/bin/phpunit

.github/workflows/integration-tests.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- 8.4
2424
os:
2525
- ubuntu-latest
26-
- windows-latest
26+
# - windows-latest
2727

2828
name: "Run tests: ${{ matrix.os }}"
2929

@@ -35,7 +35,7 @@ jobs:
3535
uses: shivammathur/setup-php@v2
3636
with:
3737
php-version: ${{ matrix.php }}
38-
extensions: dom, curl, libxml, mbstring, pcntl, fileinfo, pdo, sqlite, pdo_sqlite, pdo_mysql, pdo_pgsql intl, ftp, zip
38+
extensions: dom, curl, libxml, mbstring, pcntl, fileinfo, pdo, sqlite, pdo_sqlite, pdo_mysql, pdo_pgsql, intl, ftp, zip
3939
coverage: pcov
4040

4141
- name: Setup Bun
@@ -57,7 +57,7 @@ jobs:
5757
matrix:
5858
os:
5959
- ubuntu-latest
60-
- windows-latest
60+
# - windows-latest
6161
php:
6262
- 8.4
6363
database:
@@ -67,9 +67,9 @@ jobs:
6767
stability:
6868
- prefer-stable
6969
- prefer-lowest
70-
exclude:
71-
- os: windows-latest
72-
database: postgres
70+
# exclude:
71+
# - os: windows-latest
72+
# database: postgres
7373

7474
name: "Run tests: PHP ${{ matrix.php }} - ${{ matrix.database }} - ${{ matrix.stability }} - ${{ matrix.os }}"
7575

@@ -81,7 +81,7 @@ jobs:
8181
uses: shivammathur/setup-php@v2
8282
with:
8383
php-version: ${{ matrix.php }}
84-
extensions: dom, curl, libxml, mbstring, pcntl, fileinfo, pdo, sqlite, pdo_sqlite, pdo_mysql, intl, ftp, zip
84+
extensions: dom, curl, libxml, mbstring, pcntl, fileinfo, pdo, sqlite, pdo_sqlite, pdo_mysql, pdo_pgsql, intl, ftp, zip
8585
coverage: pcov
8686

8787
- name: Setup problem matchers

docs/1-essentials/02-views.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Apart from HTMLs boolean attributes, the same syntax can be used with any expres
177177

178178
### Control flow directives
179179

180-
#### `:if`, `:elseif` and `:else`
180+
#### `:if`, `:elseif`, and `:else`
181181

182182
The `:if` directive can conditionally render the element it is attached to, depending on the result of its expression. Similarly, the `:elseif` and `:else` directives can be used on direct siblings for additional control.
183183

@@ -186,6 +186,21 @@ The `:if` directive can conditionally render the element it is attached to, depe
186186
<span :else>Import {{ $this->pendingUploads->count() }} file(s)</span>
187187
```
188188

189+
#### `:isset`
190+
191+
The `:isset` directive can be used to conditionally render the element it is attached to, depending on the existence of a variable.
192+
193+
```html
194+
<h1 :isset="$title">{{ $title }}</h1>
195+
```
196+
197+
Since `:isset` is a shorthand for `:if="isset()"`, it can be combined with `:elseif` and `:else`:
198+
199+
```html
200+
<h1 :isset="$title">{{ $title }}</h1>
201+
<h1 :else>Title</h1>
202+
```
203+
189204
#### `:foreach` and `:{:hl-keyword:forelse:}`
190205

191206
The `:foreach` directive may be used to render the associated element multiple times based on the result of its expression. Combined with `:{:hl-keyword:forelse:}`, an empty state can be displayed when the data is empty.
@@ -230,7 +245,7 @@ To create a view component, create a `.view.php` file that starts with `x-`. The
230245
```html app/x-base.view.php
231246
<html lang="en">
232247
<head>
233-
<title :if="$title">{{ $title }} — AirAcme</title>
248+
<title :if="$title ?? null">{{ $title }} — AirAcme</title>
234249
<title :else>AirAcme</title>
235250
</head>
236251
<body>
@@ -265,7 +280,7 @@ Attributes and [expression attributes](#expression-attributes) may be passed int
265280

266281
```html x-base.view.php
267282
// ...
268-
<title :if="$title">{{ $title }}</title>
283+
<title :if="$title ?? null">{{ $title }}</title>
269284
```
270285

271286
Note that the casing of attributes will affect the associated variable name:

docs/4-internals/03-view-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Some frontend frameworks also provide a `{html}:{:hl-property:attribute:}` synta
2727

2828
### Control structures
2929

30-
Control structures like conditionals and loops are modelled with expression attributes. These control structure attributes are available: `{html}:{:hl-property:if:}`, `{html}:{:hl-property:elseif:}`, `{html}:{:hl-property:else:}`, `{html}:{:hl-property:foreach:}`, `{html}:{:hl-property:forelse:}`. Code within these control structures is compiled to valid PHP expressions.
30+
Control structures like conditionals and loops are modelled with expression attributes. These control structure attributes are available: `{html}:{:hl-property:if:}`, `{html}:{:hl-property:elseif:}`, `{html}:{:hl-property:else:}`, {:hl-property:isset:}`, `{html}:{:hl-property:foreach:}`, `{html}:{:hl-property:forelse:}`. Code within these control structures is compiled to valid PHP expressions.
3131

3232
The following conditional:
3333

docs/5-extra-topics/02-standalone-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ $eventBus->dispatch(new MyEvent());
138138

139139
## `tempest/command-bus`
140140

141-
Tempest's event bus can be used as a standalone package, in order for event handlers to be discovered, you'll have to boot Tempest's kernel and resolve the event bus from the container:
141+
Tempest's command bus can be used as a standalone package, in order for command handlers to be discovered, you'll have to boot Tempest's kernel and resolve the command bus from the container:
142142

143143
```
144144
composer require tempest/command-bus

packages/console/src/Highlight/TempestConsoleLanguage/Injections/FileInjection.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Tempest\Highlight\Injection;
99
use Tempest\Highlight\ParsedInjection;
1010
use Tempest\Highlight\Themes\TerminalStyle;
11+
use Tempest\Support\Filesystem;
1112

1213
use function Tempest\root_path;
1314
use function Tempest\Support\str;
@@ -21,9 +22,9 @@ public function parse(string $content, Highlighter $highlighter): ParsedInjectio
2122
pattern: '/(?<match>\<file=(?<quote>[\"\'])(?<file>.+)\k<quote>\s*\/?>)/',
2223
callback: function (array $matches) {
2324
$href = $matches['file'];
24-
$exists = realpath($href) !== false;
25+
$exists = Filesystem\normalize_path($href) !== null;
2526
$file = $exists
26-
? str(realpath($href))->replace('\\', '/')->stripStart(root_path())->stripStart('/')
27+
? str(Filesystem\normalize_path($href))->replace('\\', '/')->stripStart(root_path())->stripStart('/')
2728
: $href;
2829

2930
return TerminalStyle::UNDERLINE((string) $file);

packages/core/src/Commands/DiscoveryStatusCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Tempest\Core\DiscoveryCache;
1111
use Tempest\Core\DiscoveryCacheStrategy;
1212
use Tempest\Core\Kernel;
13+
use Tempest\Support\Filesystem;
1314

1415
use function Tempest\root_path;
1516
use function Tempest\Support\str;
@@ -62,7 +63,7 @@ public function __invoke(
6263
$this->console->writeln();
6364

6465
foreach ($this->kernel->discoveryLocations as $discoveryLocation) {
65-
$path = str(realpath($discoveryLocation->path))
66+
$path = str(Filesystem\normalize_path($discoveryLocation->path))
6667
->replaceStart(root_path(), '.')
6768
->toString();
6869

packages/core/src/DiscoveryConfig.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Tempest\Core;
44

5+
use Tempest\Support\Filesystem;
6+
57
final class DiscoveryConfig
68
{
79
private array $skipDiscovery = [];
@@ -25,9 +27,9 @@ public function skipPaths(string ...$paths): self
2527
foreach ($paths as $path) {
2628
$path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path);
2729

28-
$realpath = realpath($path);
30+
$realpath = Filesystem\normalize_path($path);
2931

30-
if ($realpath === false) {
32+
if ($realpath === null) {
3133
continue;
3234
}
3335

packages/core/src/FrameworkKernel.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Tempest\EventBus\EventBus;
1919
use Tempest\Process\GenericProcessExecutor;
2020
use Tempest\Router\Exceptions\HttpExceptionHandler;
21+
use Tempest\Support\Filesystem;
2122

2223
final class FrameworkKernel implements Kernel
2324
{
@@ -34,14 +35,20 @@ public function __construct(
3435
/** @var \Tempest\Discovery\DiscoveryLocation[] $discoveryLocations */
3536
public array $discoveryLocations = [],
3637
?Container $container = null,
38+
?string $internalStorage = null,
3739
) {
3840
$this->container = $container ?? $this->createContainer();
41+
42+
if ($internalStorage !== null) {
43+
$this->internalStorage = $internalStorage;
44+
}
3945
}
4046

4147
public static function boot(
4248
string $root,
4349
array $discoveryLocations = [],
4450
?Container $container = null,
51+
?string $internalStorage = null,
4552
): self {
4653
if (! defined('TEMPEST_START')) {
4754
define('TEMPEST_START', value: hrtime(true));
@@ -51,6 +58,7 @@ public static function boot(
5158
root: $root,
5259
discoveryLocations: $discoveryLocations,
5360
container: $container,
61+
internalStorage: $internalStorage,
5462
)
5563
->validateRoot()
5664
->loadEnv()
@@ -68,7 +76,7 @@ public static function boot(
6876

6977
public function validateRoot(): self
7078
{
71-
$root = realpath($this->root);
79+
$root = Filesystem\normalize_path($this->root);
7280

7381
if (! is_dir($root)) {
7482
throw new RuntimeException('The specified root directory is not valid.');
@@ -175,7 +183,7 @@ public function loadConfig(): self
175183

176184
public function registerInternalStorage(): self
177185
{
178-
$path = $this->root . '/.tempest';
186+
$path = isset($this->internalStorage) ? $this->internalStorage : $this->root . '/.tempest';
179187

180188
if (! is_dir($path)) {
181189
if (file_exists($path)) {
@@ -189,7 +197,7 @@ public function registerInternalStorage(): self
189197
throw CouldNotRegisterInternalStorage::noPermission($path);
190198
}
191199

192-
$this->internalStorage = realpath($path);
200+
$this->internalStorage = Filesystem\normalize_path($path);
193201

194202
return $this;
195203
}

packages/core/src/Kernel/LoadConfig.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Tempest\Core\ConfigCache;
99
use Tempest\Core\Kernel;
1010
use Tempest\Support\Arr\MutableArray;
11+
use Tempest\Support\Filesystem;
1112
use Tempest\Support\Str;
1213

1314
/** @internal */
@@ -85,10 +86,10 @@ public function find(): array
8586
*/
8687
private function scan(string $path, MutableArray $configPaths): void
8788
{
88-
$input = realpath($path);
89+
$input = Filesystem\normalize_path($path);
8990

9091
// Make sure the path is valid
91-
if ($input === false) {
92+
if ($input === null) {
9293
return;
9394
}
9495

0 commit comments

Comments
 (0)