From f07533e286cadb44a00dafded9f8a9260b642336 Mon Sep 17 00:00:00 2001 From: MGatner Date: Wed, 17 Mar 2021 22:55:00 +0000 Subject: [PATCH 1/3] Standardize default and required --- .../20190319121802_create_table_visits.php | 30 +++++++++---------- src/Models/VisitModel.php | 11 +++---- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/Database/Migrations/20190319121802_create_table_visits.php b/src/Database/Migrations/20190319121802_create_table_visits.php index f7ce5d6..8e820f4 100644 --- a/src/Database/Migrations/20190319121802_create_table_visits.php +++ b/src/Database/Migrations/20190319121802_create_table_visits.php @@ -7,21 +7,21 @@ class Migration_create_table_visits extends Migration public function up() { $fields = [ - 'session_id' => ['type' => 'VARCHAR', 'constraint' => 32], - 'user_id' => ['type' => 'INT', 'null' => true], - 'ip_address' => ['type' => 'BIGINT', 'null' => true], - 'user_agent' => ['type' => 'VARCHAR', 'constraint' => 255], - 'scheme' => ['type' => 'VARCHAR', 'constraint' => 15], - 'host' => ['type' => 'VARCHAR', 'constraint' => 63], - 'port' => ['type' => 'VARCHAR', 'constraint' => 15], - 'user' => ['type' => 'VARCHAR', 'constraint' => 31], - 'pass' => ['type' => 'VARCHAR', 'constraint' => 255], - 'path' => ['type' => 'VARCHAR', 'constraint' => 255], - 'query' => ['type' => 'VARCHAR', 'constraint' => 255], - 'fragment' => ['type' => 'VARCHAR', 'constraint' => 31], - 'views' => ['type' => 'INT', 'default' => 1], - 'created_at' => ['type' => 'DATETIME', 'null' => true], - 'updated_at' => ['type' => 'DATETIME', 'null' => true], + 'session_id' => ['type' => 'varchar', 'constraint' => 32, 'default' => ''], + 'user_id' => ['type' => 'int', 'null' => true], + 'ip_address' => ['type' => 'bigint', 'null' => true], + 'user_agent' => ['type' => 'varchar', 'constraint' => 255, 'default' => ''], + 'scheme' => ['type' => 'varchar', 'constraint' => 15, 'default' => ''], + 'host' => ['type' => 'varchar', 'constraint' => 63], + 'port' => ['type' => 'varchar', 'constraint' => 15, 'default' => ''], + 'user' => ['type' => 'varchar', 'constraint' => 31, 'default' => ''], + 'pass' => ['type' => 'varchar', 'constraint' => 255, 'default' => ''], + 'path' => ['type' => 'varchar', 'constraint' => 255], + 'query' => ['type' => 'varchar', 'constraint' => 255, 'default' => ''], + 'fragment' => ['type' => 'varchar', 'constraint' => 31, 'default' => ''], + 'views' => ['type' => 'int', 'default' => 1], + 'created_at' => ['type' => 'datetime', 'null' => true], + 'updated_at' => ['type' => 'datetime', 'null' => true], ]; $this->forge->addField('id'); diff --git a/src/Models/VisitModel.php b/src/Models/VisitModel.php index d887f46..0090a44 100644 --- a/src/Models/VisitModel.php +++ b/src/Models/VisitModel.php @@ -6,9 +6,11 @@ class VisitModel extends Model { protected $table = 'visits'; protected $primaryKey = 'id'; + protected $returnType = 'Tatter\Visits\Entities\Visit'; - protected $returnType = 'Tatter\Visits\Entities\Visit'; + protected $useTimestamps = true; protected $useSoftDeletes = false; + protected $skipValidation = false; protected $allowedFields = [ 'session_id', @@ -26,13 +28,8 @@ class VisitModel extends Model 'fragment', ]; - protected $useTimestamps = true; - - protected $validationRules = [ + protected $validationRules = [ 'host' => 'required', 'path' => 'required', ]; - protected $validationMessages = []; - protected $skipValidation = false; - } From 924c83bb9a189780ae78a13db94b5bd96b12068e Mon Sep 17 00:00:00 2001 From: MGatner Date: Wed, 17 Mar 2021 22:55:18 +0000 Subject: [PATCH 2/3] Clean up docs --- README.md | 2 +- {bin => examples}/Visits.php | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {bin => examples}/Visits.php (100%) diff --git a/README.md b/README.md index 898ea46..7a2616e 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ to ensure the database is setup correctly: ## Configuration (optional) The library's default behavior can be altered by extending its config file. Copy -**bin/Visits.php** to **app/Config/** and follow the instructions in the +**examples/Visits.php** to **app/Config/** and follow the instructions in the comments. If no config file is found in app/Config the library will use its own. ## Usage diff --git a/bin/Visits.php b/examples/Visits.php similarity index 100% rename from bin/Visits.php rename to examples/Visits.php From e6c7fb19d0ac964b7925af944d9de8ff1ce67228 Mon Sep 17 00:00:00 2001 From: MGatner Date: Wed, 17 Mar 2021 22:56:56 +0000 Subject: [PATCH 3/3] Update toolkit --- .github/workflows/analyze.yml | 2 +- .github/workflows/test.yml | 2 +- composer.json | 2 +- phpstan.neon.dist | 1 - phpunit.xml.dist | 4 ++++ 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index bd93b20..debf364 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -39,7 +39,7 @@ jobs: with: php-version: ${{ matrix.php-versions }} tools: composer, pecl, phpunit - extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3 + extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 - name: Get composer cache directory id: composer-cache diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a1cb9a3..9ded22a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: with: php-version: ${{ matrix.php-versions }} tools: composer, pecl, phpunit - extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3 + extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3 coverage: xdebug - name: Get composer cache directory diff --git a/composer.json b/composer.json index f978713..625635d 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ }, "require-dev": { "codeigniter4/codeigniter4": "dev-develop", - "tatter/tools": "^1.6" + "tatter/tools": "^1.7" }, "autoload": { "psr-4": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index dfa6a85..b1385f6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -13,7 +13,6 @@ parameters: - '#Access to protected property .+\\[A-Za-z]+Model::\$[A-Za-z]+#' - '#Access to an undefined property CodeIgniter\\Session\\Session::\$session_id#' - '#Call to an undefined static method Config\\Services::[A-Za-z]+\(\)#' - - '#Unsafe usage of new static\(\)*#' universalObjectCratesClasses: - CodeIgniter\Entity - Faker\Generator diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 01f689c..745249c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -36,6 +36,10 @@ + + + +