Skip to content

Commit 7fc7de7

Browse files
authored
Merge branch 'main' into fix/issue-175
2 parents 2fec19a + 6eb011b commit 7fc7de7

File tree

7 files changed

+29
-10
lines changed

7 files changed

+29
-10
lines changed

src/Compactor/Php.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function compactContent(string $contents): string
3636
// Note: $tokens may be updated by reference as well!
3737
$retokenized = $this->retokenizeAttribute($tokens, $index);
3838

39-
if (null !== $retokenized) {
39+
if ($retokenized !== null) {
4040
array_splice($tokens, $index, 1, $retokenized);
4141
$tokenCount = count($tokens);
4242
}
@@ -65,7 +65,7 @@ protected function compactContent(string $contents): string
6565
// Handle whitespace potentially being split into two tokens after attribute retokenization.
6666
$nextToken = $tokens[$index + 1] ?? null;
6767

68-
if (null !== $nextToken
68+
if ($nextToken !== null
6969
&& $nextToken->is(T_WHITESPACE)
7070
) {
7171
$whitespace .= $nextToken->text;
@@ -119,16 +119,16 @@ private static function findAttributeCloser(array $tokens, int $opener): ?int
119119
$tokenText = $tokens[$i]->text;
120120

121121
// Allow for short arrays within attributes.
122-
if ('[' === $tokenText) {
122+
if ($tokenText === '[') {
123123
$brackets[] = $i;
124124

125125
continue;
126126
}
127127

128-
if (']' === $tokenText) {
128+
if ($tokenText === ']') {
129129
array_pop($brackets);
130130

131-
if (0 === count($brackets)) {
131+
if (count($brackets) === 0) {
132132
$closer = $i;
133133
break;
134134
}
@@ -157,7 +157,7 @@ private function retokenizeAttribute(array &$tokens, int $opener): ?array
157157

158158
// Multi-line attribute or attribute containing something which looks like a PHP close tag.
159159
// Retokenize the rest of the file after the attribute opener.
160-
if (null === $closer) {
160+
if ($closer === null) {
161161
foreach (array_slice($tokens, $opener + 1) as $token) {
162162
$attributeBody .= $token->text;
163163
}
@@ -167,7 +167,7 @@ private function retokenizeAttribute(array &$tokens, int $opener): ?array
167167

168168
$closer = self::findAttributeCloser($subTokens, 0);
169169

170-
if (null !== $closer) {
170+
if ($closer !== null) {
171171
array_splice(
172172
$tokens,
173173
$opener + 1,
@@ -179,7 +179,7 @@ private function retokenizeAttribute(array &$tokens, int $opener): ?array
179179
}
180180
}
181181

182-
if (null === $closer) {
182+
if ($closer === null) {
183183
return null;
184184
}
185185

src/Facades/MenuBar.php

+2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
namespace Native\Laravel\Facades;
44

55
use Illuminate\Support\Facades\Facade;
6+
use Native\Laravel\Menu\Menu;
67

78
/**
89
* @method static \Native\Laravel\MenuBar\PendingCreateMenuBar create()
910
* @method static void show()
1011
* @method static void hide()
1112
* @method static void label(string $label)
13+
* @method static void contextMenu(Menu $contextMenu)
1214
*/
1315
class MenuBar extends Facade
1416
{

src/MenuBar/MenuBar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
class MenuBar
1313
{
14-
use HasVibrancy;
1514
use HasDimensions;
1615
use HasPositioner;
1716
use HasUrl;
17+
use HasVibrancy;
1818

1919
protected string $icon = '';
2020

src/MenuBar/MenuBarManager.php

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Native\Laravel\MenuBar;
44

55
use Native\Laravel\Client\Client;
6+
use Native\Laravel\Menu\Menu;
67

78
class MenuBarManager
89
{
@@ -32,4 +33,11 @@ public function label(string $label)
3233
'label' => $label,
3334
]);
3435
}
36+
37+
public function contextMenu(Menu $contextMenu)
38+
{
39+
$this->client->post('menu-bar/context-menu', [
40+
'contextMenu' => $contextMenu->toArray()['submenu'],
41+
]);
42+
}
3543
}

src/NativeServiceProvider.php

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Native\Laravel\Commands\LoadStartupConfigurationCommand;
1010
use Native\Laravel\Commands\MigrateCommand;
1111
use Native\Laravel\Commands\MinifyApplicationCommand;
12+
use Native\Laravel\Commands\SeedDatabaseCommand;
1213
use Native\Laravel\Logging\LogWatcher;
1314
use Spatie\LaravelPackageTools\Package;
1415
use Spatie\LaravelPackageTools\PackageServiceProvider;
@@ -22,6 +23,7 @@ public function configurePackage(Package $package): void
2223
->hasCommands([
2324
MigrateCommand::class,
2425
FreshCommand::class,
26+
SeedDatabaseCommand::class,
2527
MinifyApplicationCommand::class,
2628
])
2729
->hasConfigFile()

src/System.php

+7
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,11 @@ public function print(string $html, Printer $printer = null): void
4949
'printer' => $printer->name ?? '',
5050
]);
5151
}
52+
53+
public function printToPDF(string $html): string
54+
{
55+
return $this->client->post('system/print-to-pdf', [
56+
'html' => $html,
57+
])->json('result');
58+
}
5259
}

src/Windows/Window.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
class Window
1111
{
12-
use HasVibrancy;
1312
use HasDimensions;
1413
use HasUrl;
14+
use HasVibrancy;
1515

1616
protected bool $autoHideMenuBar = false;
1717

0 commit comments

Comments
 (0)