Skip to content

Commit 937ae82

Browse files
committed
private constants are PascalCase
1 parent 944560b commit 937ae82

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

src/CodeCoverage/Generators/HtmlGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
class HtmlGenerator extends AbstractGenerator
1919
{
20-
private const CLASSES = [
20+
private const Classes = [
2121
self::CODE_TESTED => 't', // tested
2222
self::CODE_UNTESTED => 'u', // untested
2323
self::CODE_DEAD => 'dead', // dead code
@@ -47,7 +47,7 @@ protected function renderSelf(): void
4747
$this->parse();
4848

4949
$title = $this->title;
50-
$classes = self::CLASSES;
50+
$classes = self::Classes;
5151
$files = $this->files;
5252
$coveredPercent = $this->getCoveredPercent();
5353

src/Framework/Assert.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class Assert
1717
{
1818
/** used by equal() for comparing floats */
19-
private const EPSILON = 1e-10;
19+
private const Epsilon = 1e-10;
2020

2121
/** used by match(); in values, each $ followed by number is backreference */
2222
public static $patterns = [
@@ -652,7 +652,7 @@ private static function isEqual($expected, $actual, int $level = 0, $objects = n
652652

653653
case is_float($expected) && is_float($actual) && is_finite($expected) && is_finite($actual):
654654
$diff = abs($expected - $actual);
655-
return ($diff < self::EPSILON) || ($diff / max(abs($expected), abs($actual)) < self::EPSILON);
655+
return ($diff < self::Epsilon) || ($diff / max(abs($expected), abs($actual)) < self::Epsilon);
656656

657657
case is_object($expected) && is_object($actual) && get_class($expected) === get_class($actual):
658658
$objects = $objects ? clone $objects : new \SplObjectStorage;

src/Framework/FileMock.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
class FileMock
1717
{
18-
private const PROTOCOL = 'mock';
18+
private const Protocol = 'mock';
1919

2020
/** @var string[] */
2121
public static $files = [];
@@ -47,16 +47,16 @@ public static function create(string $content = '', ?string $extension = null):
4747
self::register();
4848

4949
static $id;
50-
$name = self::PROTOCOL . '://' . (++$id) . '.' . $extension;
50+
$name = self::Protocol . '://' . (++$id) . '.' . $extension;
5151
self::$files[$name] = $content;
5252
return $name;
5353
}
5454

5555

5656
public static function register(): void
5757
{
58-
if (!in_array(self::PROTOCOL, stream_get_wrappers(), true)) {
59-
stream_wrapper_register(self::PROTOCOL, self::class);
58+
if (!in_array(self::Protocol, stream_get_wrappers(), true)) {
59+
stream_wrapper_register(self::Protocol, self::class);
6060
}
6161
}
6262

src/Framework/FileMutator.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
class FileMutator
1818
{
19-
private const PROTOCOL = 'file';
19+
private const Protocol = 'file';
2020

2121
/** @var resource|null */
2222
public $context;
@@ -31,8 +31,8 @@ class FileMutator
3131
public static function addMutator(callable $mutator): void
3232
{
3333
self::$mutators[] = $mutator;
34-
stream_wrapper_unregister(self::PROTOCOL);
35-
stream_wrapper_register(self::PROTOCOL, self::class);
34+
stream_wrapper_unregister(self::Protocol);
35+
stream_wrapper_register(self::Protocol, self::class);
3636
}
3737

3838

@@ -224,12 +224,12 @@ public function url_stat(string $path, int $flags)
224224

225225
private function native(string $func)
226226
{
227-
stream_wrapper_restore(self::PROTOCOL);
227+
stream_wrapper_restore(self::Protocol);
228228
try {
229229
return $func(...array_slice(func_get_args(), 1));
230230
} finally {
231-
stream_wrapper_unregister(self::PROTOCOL);
232-
stream_wrapper_register(self::PROTOCOL, self::class);
231+
stream_wrapper_unregister(self::Protocol);
232+
stream_wrapper_register(self::Protocol, self::class);
233233
}
234234
}
235235
}

src/Framework/TestCase.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class TestCase
1717
{
1818
/** @internal */
1919
public const
20-
LIST_METHODS = 'nette-tester-list-methods',
21-
METHOD_PATTERN = '#^test[A-Z0-9_]#';
20+
ListMethods = 'nette-tester-list-methods',
21+
MethodPattern = '#^test[A-Z0-9_]#';
2222

2323
/** @var bool */
2424
private $handleErrors = false;
@@ -36,13 +36,13 @@ public function run(): void
3636
throw new \LogicException('Calling TestCase::run($method) is deprecated. Use TestCase::runTest($method) instead.');
3737
}
3838

39-
$methods = array_values(preg_grep(self::METHOD_PATTERN, array_map(function (\ReflectionMethod $rm): string {
39+
$methods = array_values(preg_grep(self::MethodPattern, array_map(function (\ReflectionMethod $rm): string {
4040
return $rm->getName();
4141
}, (new \ReflectionObject($this))->getMethods())));
4242

4343
if (isset($_SERVER['argv']) && ($tmp = preg_filter('#--method=([\w-]+)$#Ai', '$1', $_SERVER['argv']))) {
4444
$method = reset($tmp);
45-
if ($method === self::LIST_METHODS) {
45+
if ($method === self::ListMethods) {
4646
$this->sendMethodList($methods);
4747
return;
4848
}
@@ -72,7 +72,7 @@ public function runTest(string $method, ?array $args = null): void
7272
{
7373
if (!method_exists($this, $method)) {
7474
throw new TestCaseException("Method '$method' does not exist.");
75-
} elseif (!preg_match(self::METHOD_PATTERN, $method)) {
75+
} elseif (!preg_match(self::MethodPattern, $method)) {
7676
throw new TestCaseException("Method '$method' is not a testing method.");
7777
}
7878

src/Runner/TestHandler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class TestHandler
2222
{
23-
private const HTTP_OK = 200;
23+
private const HttpOk = 200;
2424

2525
/** @var Runner */
2626
private $runner;
@@ -88,7 +88,7 @@ public function assess(Job $job): void
8888
$test = $job->getTest();
8989
$annotations = $this->getAnnotations($test->getFile())[0] += [
9090
'exitcode' => Job::CODE_OK,
91-
'httpcode' => self::HTTP_OK,
91+
'httpcode' => self::HttpOk,
9292
];
9393

9494
foreach (get_class_methods($this) as $method) {
@@ -195,7 +195,7 @@ private function initiateTestCase(Test $test, $foo, PhpInterpreter $interpreter)
195195
}
196196

197197
if ($methods === null) {
198-
$job = new Job($test->withArguments(['method' => TestCase::LIST_METHODS]), $interpreter, $this->runner->getEnvironmentVariables());
198+
$job = new Job($test->withArguments(['method' => TestCase::ListMethods]), $interpreter, $this->runner->getEnvironmentVariables());
199199
$job->run();
200200

201201
if (in_array($job->getExitCode(), [Job::CODE_ERROR, Job::CODE_FAIL, Job::CODE_SKIP], true)) {
@@ -259,7 +259,7 @@ private function assessHttpCode(Job $job, $code): ?Test
259259
}
260260

261261
$headers = $job->getHeaders();
262-
$actual = (int) ($headers['Status'] ?? self::HTTP_OK);
262+
$actual = (int) ($headers['Status'] ?? self::HttpOk);
263263
$code = (int) $code;
264264
return $code && $code !== $actual
265265
? $job->getTest()->withResult(Test::FAILED, "Exited with HTTP code $actual (expected $code)")

0 commit comments

Comments
 (0)