Skip to content

Commit d4d24a0

Browse files
committed
Fix static analysis
1 parent fb69e01 commit d4d24a0

File tree

4 files changed

+10
-34
lines changed

4 files changed

+10
-34
lines changed

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ parameters:
1313
universalObjectCratesClasses:
1414
- CodeIgniter\Entity
1515
- CodeIgniter\Entity\Entity
16+
- CodeIgniter\Session\Session
1617
- Faker\Generator
1718
scanDirectories:
1819
- vendor/codeigniter4/framework/system/Helpers

src/Config/Events.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
Events::on('post_controller_constructor', function () {
77
// Ignore CLI requests
8-
return is_cli() ?: Services::visits()->record();
8+
return is_cli() ?: service('visits')->record();
99
});

src/Entities/Visit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php namespace Tatter\Visits\Entities;
22

3-
use CodeIgniter\Entity;
3+
use CodeIgniter\Entity\Entity;
44
use Tatter\Visits\Models\VisitModel;
55

66
class Visit extends Entity

src/Visits.php

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
11
<?php namespace Tatter\Visits;
22

3-
/***
4-
* Name: Visits
5-
* Author: Matthew Gatner
6-
* Contact: mgatner@tattersoftware.com
7-
* Created: 2019-02-12
8-
*
9-
* Description: Lightweight traffic tracking for CodeIgniter 4
10-
*
11-
* Requirements:
12-
* >= PHP 7.1
13-
* >= CodeIgniter 4.0
14-
* Preconfigured, autoloaded Database
15-
* CodeIgniter's URL helper (loaded automatically)
16-
* Visits table (run migrations)
17-
*
18-
* Configuration:
19-
* Use app/Config/Visits.php to override default behavior
20-
* Run migrations to update database tables:
21-
* > php spark migrate:latest -n "Tatter\Visits"
22-
*
23-
* @package CodeIgniter4-Visits
24-
* @author Matthew Gatner
25-
* @link https://github.com/tattersoftware/codeigniter4-visits
26-
***/
27-
283
use CodeIgniter\Config\BaseConfig;
294
use CodeIgniter\Config\Services;
305
use CodeIgniter\Database\ConnectionInterface;
@@ -33,9 +8,6 @@
338
use Tatter\Visits\Models\VisitModel;
349
use Tatter\Visits\Exceptions\VisitsException;
3510

36-
/***
37-
* CLASS
38-
***/
3911
class Visits
4012
{
4113
/**
@@ -77,11 +49,14 @@ public function __construct(VisitsConfig $config, $db = null)
7749
// If no db connection passed in, use the default database group.
7850
$this->db = db_connect($db);
7951

80-
// validations
81-
$visits = new VisitModel();
82-
if (! $this->db->tableExists($visits->table))
52+
/**
53+
* @phpstan-ignore-next-line
54+
* @psalm-suppress InaccessibleProperty
55+
*/
56+
$table = model(VisitModel::class)->table;
57+
if (! $this->db->tableExists($table))
8358
{
84-
throw VisitsException::forMissingDatabaseTable($visits->table);
59+
throw VisitsException::forMissingDatabaseTable($table);
8560
}
8661

8762
if (empty($this->config->trackingMethod))

0 commit comments

Comments
 (0)