• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codeigniter4 / CodeIgniter4 / 12526539263

28 Dec 2024 12:21PM UTC coverage: 84.43% (+0.008%) from 84.422%
12526539263

push

github

web-flow
refactor: fix `phpstan` only boolean allowed (#9302)

* refactor: Fix `phpstan` boolean errors

* fix: Check predis response

* refactor: Improve comparison with an empty string

* dev: Update phpstan-baseline

* fix: Revert comparison with null

102 of 108 new or added lines in 35 files covered. (94.44%)

1 existing line in 1 file now uncovered.

20448 of 24219 relevant lines covered (84.43%)

189.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/system/HotReloader/HotReloader.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter 4 framework.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace CodeIgniter\HotReloader;
15

16
/**
17
 * @internal
18
 */
19
final class HotReloader
20
{
21
    public function run(): void
22
    {
23
        if (session_status() === PHP_SESSION_ACTIVE) {
×
24
            session_write_close();
×
25
        }
26

27
        ini_set('zlib.output_compression', 'Off');
×
28

29
        header('Cache-Control: no-store');
×
30
        header('Content-Type: text/event-stream');
×
31
        header('Access-Control-Allow-Methods: GET');
×
32

33
        ob_end_clean();
×
34
        set_time_limit(0);
×
35

36
        $hasher  = new DirectoryHasher();
×
37
        $appHash = $hasher->hash();
×
38

39
        while (true) {
×
NEW
40
            if (connection_status() !== CONNECTION_NORMAL || connection_aborted() === 1) {
×
41
                break;
×
42
            }
43

44
            $currentHash = $hasher->hash();
×
45

46
            // If hash has changed, tell the browser to reload.
47
            if ($currentHash !== $appHash) {
×
48
                $appHash = $currentHash;
×
49

50
                $this->sendEvent('reload', ['time' => date('Y-m-d H:i:s')]);
×
51
                break;
×
52
            }
53

54
            if (mt_rand(1, 10) > 8) {
×
55
                $this->sendEvent('ping', ['time' => date('Y-m-d H:i:s')]);
×
56
            }
57

58
            sleep(1);
×
59
        }
60
    }
61

62
    /**
63
     * Send an event to the browser.
64
     */
65
    private function sendEvent(string $event, array $data): void
66
    {
67
        echo "event: {$event}\n";
×
68
        echo 'data: ' . json_encode($data) . "\n\n";
×
69

70
        ob_flush();
×
71
        flush();
×
72
    }
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc