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

mpyw / laravel-database-advisory-lock / 20213075082

14 Dec 2025 07:33PM UTC coverage: 95.732% (-4.3%) from 100.0%
20213075082

Pull #14

github

mpyw
Exclude bootstrap files from PHPStan analysis

Bootstrap files contain trait stubs for testing that PHPStan
incorrectly reports as unused.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Pull Request #14: [Claude] Add PHP 8.5 to CI test matrix

157 of 164 relevant lines covered (95.73%)

126.84 hits per line

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

33.33
/src/AdvisoryLocks.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Mpyw\LaravelDatabaseAdvisoryLock;
6

7
use Closure;
8
use Illuminate\Database\Connection;
9
use Illuminate\Database\QueryException;
10
use Mpyw\LaravelDatabaseAdvisoryLock\Contracts\LockerFactory as FactoryContract;
11

12
/**
13
 * trait AdvisoryLocks
14
 *
15
 * Designed to be mixed in with the Connection classes.
16
 */
17
trait AdvisoryLocks
18
{
19
    public ?FactoryContract $advisoryLocker = null;
20

21
    /**
22
     * Create LockerFactory or return existing one.
23
     */
24
    public function advisoryLocker(): FactoryContract
25
    {
26
        assert($this instanceof Connection);
27

28
        return $this->advisoryLocker ??= new LockerFactory($this);
506✔
29
    }
30

31
    /**
32
     * Overrides the original implementation.
33
     *
34
     * @param  string         $query
35
     * @param  array          $bindings
36
     * @throws QueryException
37
     */
38
    protected function handleQueryException(QueryException $e, $query, $bindings, Closure $callback)
39
    {
40
        assert($this instanceof Connection);
41

42
        // Don't try again if there are session-level locks.
43
        if ($this->transactionLevel() > 0 || $this->advisoryLocker()->forSession()->hasAny()) {
66✔
44
            throw $e;
66✔
45
        }
46

47
        return $this->tryAgainIfCausedByLostConnection(
×
48
            $e,
×
49
            $query,
×
50
            $bindings,
×
51
            $callback,
×
52
        );
×
53
    }
54
}
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

© 2026 Coveralls, Inc