Skip to content

Commit dbddfc3

Browse files
authored
[BUGFIX] Use safe file_get_contents in LenientParsingTest (#1373)
Part of #1168
1 parent a72e71e commit dbddfc3

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

tests/RuleSet/LenientParsingTest.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Sabberworm\CSS\Parsing\UnexpectedTokenException;
1111
use Sabberworm\CSS\Settings;
1212

13+
use function Safe\file_get_contents;
14+
1315
/**
1416
* @coversNothing
1517
*/
@@ -23,7 +25,7 @@ public function faultToleranceOff(): void
2325
$this->expectException(UnexpectedTokenException::class);
2426

2527
$pathToFile = __DIR__ . '/../fixtures/-fault-tolerance.css';
26-
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->beStrict());
28+
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->beStrict());
2729
$parser->parse();
2830
}
2931

@@ -33,7 +35,7 @@ public function faultToleranceOff(): void
3335
public function faultToleranceOn(): void
3436
{
3537
$pathToFile = __DIR__ . '/../fixtures/-fault-tolerance.css';
36-
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
38+
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
3739
$result = $parser->parse();
3840
self::assertSame(
3941
'.test1 {}' . "\n" . '.test2 {hello: 2.2;hello: 2000000000000.2;}' . "\n" . '#test {}' . "\n"
@@ -50,7 +52,7 @@ public function endToken(): void
5052
$this->expectException(UnexpectedTokenException::class);
5153

5254
$pathToFile = __DIR__ . '/../fixtures/-end-token.css';
53-
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->beStrict());
55+
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->beStrict());
5456
$parser->parse();
5557
}
5658

@@ -62,7 +64,7 @@ public function endToken2(): void
6264
$this->expectException(UnexpectedTokenException::class);
6365

6466
$pathToFile = __DIR__ . '/../fixtures/-end-token-2.css';
65-
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->beStrict());
67+
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->beStrict());
6668
$parser->parse();
6769
}
6870

@@ -72,7 +74,7 @@ public function endToken2(): void
7274
public function endTokenPositive(): void
7375
{
7476
$pathToFile = __DIR__ . '/../fixtures/-end-token.css';
75-
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
77+
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
7678
$result = $parser->parse();
7779
self::assertSame('', $result->render());
7880
}
@@ -83,7 +85,7 @@ public function endTokenPositive(): void
8385
public function endToken2Positive(): void
8486
{
8587
$pathToFile = __DIR__ . '/../fixtures/-end-token-2.css';
86-
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
88+
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
8789
$result = $parser->parse();
8890
self::assertSame(
8991
'#home .bg-layout {background-image: url("/bundles/main/img/bg1.png?5");}',
@@ -98,7 +100,7 @@ public function localeTrap(): void
98100
{
99101
\setlocale(LC_ALL, 'pt_PT', 'no');
100102
$pathToFile = __DIR__ . '/../fixtures/-fault-tolerance.css';
101-
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
103+
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
102104
$result = $parser->parse();
103105
self::assertSame(
104106
'.test1 {}' . "\n" . '.test2 {hello: 2.2;hello: 2000000000000.2;}' . "\n" . '#test {}' . "\n"
@@ -113,7 +115,7 @@ public function localeTrap(): void
113115
public function caseInsensitivity(): void
114116
{
115117
$pathToFile = __DIR__ . '/../fixtures/case-insensitivity.css';
116-
$parser = new Parser(\file_get_contents($pathToFile));
118+
$parser = new Parser(file_get_contents($pathToFile));
117119
$result = $parser->parse();
118120

119121
self::assertSame(
@@ -132,7 +134,7 @@ public function caseInsensitivity(): void
132134
public function cssWithInvalidColorStillGetsParsedAsDocument(): void
133135
{
134136
$pathToFile = __DIR__ . '/../fixtures/invalid-color.css';
135-
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
137+
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->withLenientParsing(true));
136138
$result = $parser->parse();
137139

138140
self::assertInstanceOf(Document::class, $result);
@@ -146,7 +148,7 @@ public function invalidColorStrict(): void
146148
$this->expectException(UnexpectedTokenException::class);
147149

148150
$pathToFile = __DIR__ . '/../fixtures/invalid-color.css';
149-
$parser = new Parser(\file_get_contents($pathToFile), Settings::create()->beStrict());
151+
$parser = new Parser(file_get_contents($pathToFile), Settings::create()->beStrict());
150152
$parser->parse();
151153
}
152154
}

0 commit comments

Comments
 (0)