@@ -59,38 +59,38 @@ |
||
59 | 59 | $property = new Property('foo'); |
60 | 60 | self::assertNull($property->getVisibility()); |
61 | 61 | |
62 | - $property->setVisibility(Visibility::PUBLIC); |
|
63 | - self::assertSame(Visibility::PUBLIC, $property->getVisibility()); |
|
62 | + $property->setVisibility(Visibility::public); |
|
63 | + self::assertSame(Visibility::public, $property->getVisibility()); |
|
64 | 64 | self::assertTrue($property->isPublic()); |
65 | 65 | self::assertFalse($property->isProtected()); |
66 | 66 | self::assertFalse($property->isPrivate()); |
67 | 67 | |
68 | - $property->setVisibility(Visibility::PROTECTED); |
|
69 | - self::assertSame(Visibility::PROTECTED, $property->getVisibility()); |
|
68 | + $property->setVisibility(Visibility::protected); |
|
69 | + self::assertSame(Visibility::protected, $property->getVisibility()); |
|
70 | 70 | self::assertFalse($property->isPublic()); |
71 | 71 | self::assertTrue($property->isProtected()); |
72 | 72 | self::assertFalse($property->isPrivate()); |
73 | 73 | |
74 | - $property->setVisibility(Visibility::PRIVATE); |
|
75 | - self::assertSame(Visibility::PRIVATE, $property->getVisibility()); |
|
74 | + $property->setVisibility(Visibility::private); |
|
75 | + self::assertSame(Visibility::private, $property->getVisibility()); |
|
76 | 76 | self::assertFalse($property->isPublic()); |
77 | 77 | self::assertFalse($property->isProtected()); |
78 | 78 | self::assertTrue($property->isPrivate()); |
79 | 79 | |
80 | 80 | $property->setPublic(); |
81 | - self::assertSame(Visibility::PUBLIC, $property->getVisibility()); |
|
81 | + self::assertSame(Visibility::public, $property->getVisibility()); |
|
82 | 82 | self::assertTrue($property->isPublic()); |
83 | 83 | self::assertFalse($property->isProtected()); |
84 | 84 | self::assertFalse($property->isPrivate()); |
85 | 85 | |
86 | 86 | $property->setProtected(); |
87 | - self::assertSame(Visibility::PROTECTED, $property->getVisibility()); |
|
87 | + self::assertSame(Visibility::protected, $property->getVisibility()); |
|
88 | 88 | self::assertFalse($property->isPublic()); |
89 | 89 | self::assertTrue($property->isProtected()); |
90 | 90 | self::assertFalse($property->isPrivate()); |
91 | 91 | |
92 | 92 | $property->setPrivate(); |
93 | - self::assertSame(Visibility::PRIVATE, $property->getVisibility()); |
|
93 | + self::assertSame(Visibility::private, $property->getVisibility()); |
|
94 | 94 | self::assertFalse($property->isPublic()); |
95 | 95 | self::assertFalse($property->isProtected()); |
96 | 96 | self::assertTrue($property->isPrivate()); |
@@ -22,22 +22,22 @@ |
||
22 | 22 | |
23 | 23 | public function loadEnvVariables(DirectoriesInterface $dirs, EnvironmentInterface $env): void |
24 | 24 | { |
25 | - if ($this->init) { |
|
25 | + if ($this->init){ |
|
26 | 26 | return; |
27 | 27 | } |
28 | 28 | |
29 | 29 | $this->init = true; |
30 | 30 | |
31 | - $dotenvPath = $env->get('DOTENV_PATH', $dirs->get('root') . '.env'); |
|
31 | + $dotenvPath = $env->get('DOTENV_PATH', $dirs->get('root').'.env'); |
|
32 | 32 | |
33 | - if (!\file_exists($dotenvPath)) { |
|
33 | + if (!\file_exists($dotenvPath)){ |
|
34 | 34 | return; |
35 | 35 | } |
36 | 36 | |
37 | - $path = \dirname((string) $dotenvPath); |
|
38 | - $file = \basename((string) $dotenvPath); |
|
37 | + $path = \dirname((string)$dotenvPath); |
|
38 | + $file = \basename((string)$dotenvPath); |
|
39 | 39 | |
40 | - foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value) { |
|
40 | + foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value){ |
|
41 | 41 | $env->set($key, $value); |
42 | 42 | } |
43 | 43 | } |
@@ -22,7 +22,8 @@ discard block |
||
22 | 22 | |
23 | 23 | public function loadEnvVariables(DirectoriesInterface $dirs, EnvironmentInterface $env): void |
24 | 24 | { |
25 | - if ($this->init) { |
|
25 | + if ($this->init) |
|
26 | + { |
|
26 | 27 | return; |
27 | 28 | } |
28 | 29 | |
@@ -30,14 +31,16 @@ discard block |
||
30 | 31 | |
31 | 32 | $dotenvPath = $env->get('DOTENV_PATH', $dirs->get('root') . '.env'); |
32 | 33 | |
33 | - if (!\file_exists($dotenvPath)) { |
|
34 | + if (!\file_exists($dotenvPath)) |
|
35 | + { |
|
34 | 36 | return; |
35 | 37 | } |
36 | 38 | |
37 | 39 | $path = \dirname((string) $dotenvPath); |
38 | 40 | $file = \basename((string) $dotenvPath); |
39 | 41 | |
40 | - foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value) { |
|
42 | + foreach (Dotenv::createImmutable($path, $file)->load() as $key => $value) |
|
43 | + { |
|
41 | 44 | $env->set($key, $value); |
42 | 45 | } |
43 | 46 | } |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | { |
44 | 44 | $s = $this->getStempler(); |
45 | 45 | |
46 | - try { |
|
46 | + try{ |
|
47 | 47 | $s->get('echo', new ViewContext())->render(); |
48 | 48 | $this->fail('Exception expected'); |
49 | - } catch (RenderException $e) { |
|
49 | + }catch (RenderException $e){ |
|
50 | 50 | $t = $e->getUserTrace()[0]; |
51 | 51 | |
52 | 52 | self::assertSame(2, $t['line']); |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | { |
59 | 59 | $s = $this->getStempler(); |
60 | 60 | |
61 | - try { |
|
61 | + try{ |
|
62 | 62 | $s->get('other:echo-in', new ViewContext())->render(); |
63 | 63 | $this->fail('Exception expected'); |
64 | - } catch (RenderException $e) { |
|
64 | + }catch (RenderException $e){ |
|
65 | 65 | $t = $e->getUserTrace(); |
66 | 66 | self::assertCount(2, $t); |
67 | 67 | |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | { |
78 | 78 | $twig = $this->getStempler(); |
79 | 79 | |
80 | - try { |
|
80 | + try{ |
|
81 | 81 | $twig->get('other:bad', new ViewContext()); |
82 | - } catch (CompileException $e) { |
|
82 | + }catch (CompileException $e){ |
|
83 | 83 | self::assertStringContainsString('bad.dark.php', $e->getFile()); |
84 | 84 | } |
85 | 85 | } |
@@ -43,10 +43,13 @@ discard block |
||
43 | 43 | { |
44 | 44 | $s = $this->getStempler(); |
45 | 45 | |
46 | - try { |
|
46 | + try |
|
47 | + { |
|
47 | 48 | $s->get('echo', new ViewContext())->render(); |
48 | 49 | $this->fail('Exception expected'); |
49 | - } catch (RenderException $e) { |
|
50 | + } |
|
51 | + catch (RenderException $e) |
|
52 | + { |
|
50 | 53 | $t = $e->getUserTrace()[0]; |
51 | 54 | |
52 | 55 | self::assertSame(2, $t['line']); |
@@ -58,10 +61,13 @@ discard block |
||
58 | 61 | { |
59 | 62 | $s = $this->getStempler(); |
60 | 63 | |
61 | - try { |
|
64 | + try |
|
65 | + { |
|
62 | 66 | $s->get('other:echo-in', new ViewContext())->render(); |
63 | 67 | $this->fail('Exception expected'); |
64 | - } catch (RenderException $e) { |
|
68 | + } |
|
69 | + catch (RenderException $e) |
|
70 | + { |
|
65 | 71 | $t = $e->getUserTrace(); |
66 | 72 | self::assertCount(2, $t); |
67 | 73 | |
@@ -77,9 +83,12 @@ discard block |
||
77 | 83 | { |
78 | 84 | $twig = $this->getStempler(); |
79 | 85 | |
80 | - try { |
|
86 | + try |
|
87 | + { |
|
81 | 88 | $twig->get('other:bad', new ViewContext()); |
82 | - } catch (CompileException $e) { |
|
89 | + } |
|
90 | + catch (CompileException $e) |
|
91 | + { |
|
83 | 92 | self::assertStringContainsString('bad.dark.php', $e->getFile()); |
84 | 93 | } |
85 | 94 | } |
@@ -13,5 +13,5 @@ |
||
13 | 13 | public array $allowEnv = [], |
14 | 14 | public array $denyEnv = [], |
15 | 15 | public bool $override = true, |
16 | - ) {} |
|
16 | + ){} |
|
17 | 17 | } |
@@ -13,5 +13,6 @@ |
||
13 | 13 | public array $allowEnv = [], |
14 | 14 | public array $denyEnv = [], |
15 | 15 | public bool $override = true, |
16 | - ) {} |
|
16 | + ) { |
|
17 | +} |
|
17 | 18 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | */ |
25 | 25 | public function __construct( |
26 | 26 | public array $nodes = [], |
27 | - ) {} |
|
27 | + ){} |
|
28 | 28 | |
29 | 29 | public function setContext(?Context $context = null): void |
30 | 30 | { |
@@ -24,7 +24,8 @@ |
||
24 | 24 | */ |
25 | 25 | public function __construct( |
26 | 26 | public array $nodes = [], |
27 | - ) {} |
|
27 | + ) { |
|
28 | +} |
|
28 | 29 | |
29 | 30 | public function setContext(?Context $context = null): void |
30 | 31 | { |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | $builder = new Builder($loader); |
46 | 46 | |
47 | 47 | $builder->addVisitor( |
48 | - new class implements VisitorInterface { |
|
48 | + new class implements VisitorInterface{ |
|
49 | 49 | |
50 | 50 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
51 | 51 | { |
52 | 52 | $n = $ctx->getCurrentNode(); |
53 | - if ($n instanceof Template) { |
|
53 | + if ($n instanceof Template){ |
|
54 | 54 | $import = m::mock(ImportInterface::class); |
55 | 55 | $import->shouldNotReceive('resolve'); |
56 | 56 | $n->setAttribute(ImportContext::class, [$import]); |
@@ -94,16 +94,16 @@ discard block |
||
94 | 94 | $template = new Template(); |
95 | 95 | |
96 | 96 | $builder->addVisitor( |
97 | - new class($builder, $template) implements VisitorInterface { |
|
97 | + new class($builder, $template) implements VisitorInterface{ |
|
98 | 98 | public function __construct( |
99 | 99 | private readonly Builder $builder, |
100 | 100 | private readonly Template $template, |
101 | - ) {} |
|
101 | + ){} |
|
102 | 102 | |
103 | 103 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
104 | 104 | { |
105 | 105 | $n = $ctx->getCurrentNode(); |
106 | - if ($n instanceof Template) { |
|
106 | + if ($n instanceof Template){ |
|
107 | 107 | $import = m::mock(ImportInterface::class); |
108 | 108 | $import |
109 | 109 | ->shouldReceive('resolve') |
@@ -45,12 +45,14 @@ discard block |
||
45 | 45 | $builder = new Builder($loader); |
46 | 46 | |
47 | 47 | $builder->addVisitor( |
48 | - new class implements VisitorInterface { |
|
48 | + new class implements VisitorInterface |
|
49 | + { |
|
49 | 50 | |
50 | 51 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
51 | 52 | { |
52 | 53 | $n = $ctx->getCurrentNode(); |
53 | - if ($n instanceof Template) { |
|
54 | + if ($n instanceof Template) |
|
55 | + { |
|
54 | 56 | $import = m::mock(ImportInterface::class); |
55 | 57 | $import->shouldNotReceive('resolve'); |
56 | 58 | $n->setAttribute(ImportContext::class, [$import]); |
@@ -94,16 +96,19 @@ discard block |
||
94 | 96 | $template = new Template(); |
95 | 97 | |
96 | 98 | $builder->addVisitor( |
97 | - new class($builder, $template) implements VisitorInterface { |
|
99 | + new class($builder, $template) implements VisitorInterface |
|
100 | + { |
|
98 | 101 | public function __construct( |
99 | 102 | private readonly Builder $builder, |
100 | 103 | private readonly Template $template, |
101 | - ) {} |
|
104 | + ) { |
|
105 | +} |
|
102 | 106 | |
103 | 107 | public function enterNode(mixed $node, VisitorContext $ctx): mixed |
104 | 108 | { |
105 | 109 | $n = $ctx->getCurrentNode(); |
106 | - if ($n instanceof Template) { |
|
110 | + if ($n instanceof Template) |
|
111 | + { |
|
107 | 112 | $import = m::mock(ImportInterface::class); |
108 | 113 | $import |
109 | 114 | ->shouldReceive('resolve') |
@@ -23,19 +23,19 @@ discard block |
||
23 | 23 | private string $path, |
24 | 24 | private ?string $prefix = null, |
25 | 25 | ?Context $context = null, |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | $this->context = $context; |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function resolve(Builder $builder, string $name): ?Template |
31 | 31 | { |
32 | - if ($this->template === null) { |
|
32 | + if ($this->template === null){ |
|
33 | 33 | $this->template = $builder->load($this->path); |
34 | 34 | } |
35 | 35 | |
36 | 36 | $path = $name; |
37 | - if ($this->prefix !== null) { |
|
38 | - if (!TagHelper::hasPrefix($name, $this->prefix)) { |
|
37 | + if ($this->prefix !== null){ |
|
38 | + if (!TagHelper::hasPrefix($name, $this->prefix)){ |
|
39 | 39 | return null; |
40 | 40 | } |
41 | 41 | |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | /** @var ImportInterface $import */ |
46 | - foreach ($this->template->getAttribute(ImportContext::class, []) as $import) { |
|
46 | + foreach ($this->template->getAttribute(ImportContext::class, []) as $import){ |
|
47 | 47 | $tpl = $import->resolve($builder, $path); |
48 | - if ($tpl !== null) { |
|
48 | + if ($tpl !== null){ |
|
49 | 49 | return $tpl; |
50 | 50 | } |
51 | 51 | } |
@@ -29,13 +29,16 @@ discard block |
||
29 | 29 | |
30 | 30 | public function resolve(Builder $builder, string $name): ?Template |
31 | 31 | { |
32 | - if ($this->template === null) { |
|
32 | + if ($this->template === null) |
|
33 | + { |
|
33 | 34 | $this->template = $builder->load($this->path); |
34 | 35 | } |
35 | 36 | |
36 | 37 | $path = $name; |
37 | - if ($this->prefix !== null) { |
|
38 | - if (!TagHelper::hasPrefix($name, $this->prefix)) { |
|
38 | + if ($this->prefix !== null) |
|
39 | + { |
|
40 | + if (!TagHelper::hasPrefix($name, $this->prefix)) |
|
41 | + { |
|
39 | 42 | return null; |
40 | 43 | } |
41 | 44 | |
@@ -43,9 +46,11 @@ discard block |
||
43 | 46 | } |
44 | 47 | |
45 | 48 | /** @var ImportInterface $import */ |
46 | - foreach ($this->template->getAttribute(ImportContext::class, []) as $import) { |
|
49 | + foreach ($this->template->getAttribute(ImportContext::class, []) as $import) |
|
50 | + { |
|
47 | 51 | $tpl = $import->resolve($builder, $path); |
48 | - if ($tpl !== null) { |
|
52 | + if ($tpl !== null) |
|
53 | + { |
|
49 | 54 | return $tpl; |
50 | 55 | } |
51 | 56 | } |
@@ -29,7 +29,8 @@ |
||
29 | 29 | |
30 | 30 | public function resolve(Builder $builder, string $name): ?Template |
31 | 31 | { |
32 | - if (!TagHelper::hasPrefix($name, $this->prefix)) { |
|
32 | + if (!TagHelper::hasPrefix($name, $this->prefix)) |
|
33 | + { |
|
33 | 34 | return null; |
34 | 35 | } |
35 | 36 |
@@ -22,14 +22,14 @@ |
||
22 | 22 | public string $path, |
23 | 23 | ?string $prefix, |
24 | 24 | ?Context $context = null, |
25 | - ) { |
|
25 | + ){ |
|
26 | 26 | $this->prefix = $prefix ?? \substr($path, \strrpos($path, '/') + 1); |
27 | 27 | $this->context = $context; |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function resolve(Builder $builder, string $name): ?Template |
31 | 31 | { |
32 | - if (!TagHelper::hasPrefix($name, $this->prefix)) { |
|
32 | + if (!TagHelper::hasPrefix($name, $this->prefix)){ |
|
33 | 33 | return null; |
34 | 34 | } |
35 | 35 |
@@ -19,7 +19,8 @@ discard block |
||
19 | 19 | public static function hasPrefix(string $tag, ?string $prefix): bool |
20 | 20 | { |
21 | 21 | // If no prefix is specified, allow everything |
22 | - if ($prefix === null || $prefix === '') { |
|
22 | + if ($prefix === null || $prefix === '') |
|
23 | + { |
|
23 | 24 | return true; |
24 | 25 | } |
25 | 26 | |
@@ -27,11 +28,13 @@ discard block |
||
27 | 28 | // 1) The prefix itself |
28 | 29 | // 2) The separator |
29 | 30 | // 3) At least one more char after the separator |
30 | - if (\strlen($tag) < \strlen($prefix) + 2) { |
|
31 | + if (\strlen($tag) < \strlen($prefix) + 2) |
|
32 | + { |
|
31 | 33 | return false; |
32 | 34 | } |
33 | 35 | |
34 | - if (!\str_starts_with($tag, $prefix)) { |
|
36 | + if (!\str_starts_with($tag, $prefix)) |
|
37 | + { |
|
35 | 38 | return false; |
36 | 39 | } |
37 | 40 | |
@@ -40,7 +43,8 @@ discard block |
||
40 | 43 | |
41 | 44 | public static function stripPrefix(string $tag, ?string $prefix): string |
42 | 45 | { |
43 | - if (!self::hasPrefix($tag, $prefix)) { |
|
46 | + if (!self::hasPrefix($tag, $prefix)) |
|
47 | + { |
|
44 | 48 | return $tag; |
45 | 49 | } |
46 | 50 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public static function hasPrefix(string $tag, ?string $prefix): bool |
20 | 20 | { |
21 | 21 | // If no prefix is specified, allow everything |
22 | - if ($prefix === null || $prefix === '') { |
|
22 | + if ($prefix === null || $prefix === ''){ |
|
23 | 23 | return true; |
24 | 24 | } |
25 | 25 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | // 1) The prefix itself |
28 | 28 | // 2) The separator |
29 | 29 | // 3) At least one more char after the separator |
30 | - if (\strlen($tag) < \strlen($prefix) + 2) { |
|
30 | + if (\strlen($tag) < \strlen($prefix) + 2){ |
|
31 | 31 | return false; |
32 | 32 | } |
33 | 33 | |
34 | - if (!\str_starts_with($tag, $prefix)) { |
|
34 | + if (!\str_starts_with($tag, $prefix)){ |
|
35 | 35 | return false; |
36 | 36 | } |
37 | 37 | |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | |
41 | 41 | public static function stripPrefix(string $tag, ?string $prefix): string |
42 | 42 | { |
43 | - if (!self::hasPrefix($tag, $prefix)) { |
|
43 | + if (!self::hasPrefix($tag, $prefix)){ |
|
44 | 44 | return $tag; |
45 | 45 | } |
46 | 46 | |
47 | - return \substr($tag, \strlen((string) $prefix) + 1); |
|
47 | + return \substr($tag, \strlen((string)$prefix) + 1); |
|
48 | 48 | } |
49 | 49 | } |