Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: PHPStan stubs for model() #5418

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ parameters:
- CI_DEBUG
- ENVIRONMENT
- SODIUM_LIBRARY_VERSION
stubFiles:
- utils/PHPStan/stubs/Factories.stub
- utils/PHPStan/stubs/Model.stub
- utils/PHPStan/stubs/ConnectionInterface.stub
1 change: 0 additions & 1 deletion system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,6 @@ function log_message(string $level, string $message, array $context = [])
* @param class-string<T> $name
*
* @return T
* @phpstan-return Model
*/
function model(string $name, bool $getShared = true, ?ConnectionInterface &$conn = null)
{
Expand Down
1 change: 0 additions & 1 deletion system/Config/Factories.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* instantiation checks.
*
* @method static BaseConfig config(...$arguments)
* @method static Model models(...$arguments)
*/
class Factories
{
Expand Down
7 changes: 7 additions & 0 deletions utils/PHPStan/stubs/ConnectionInterface.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace CodeIgniter\Database;

interface ConnectionInterface
{
}
19 changes: 19 additions & 0 deletions utils/PHPStan/stubs/Factories.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace CodeIgniter\Config;

use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Model;

class Factories
{
/**
* @template T of Model
*
* @param class-string<T> $name
* @param array<string, mixed> $options
*
* @return T
*/
public static function models(string $name, array $options = [], ?ConnectionInterface &$conn = null);
}
7 changes: 7 additions & 0 deletions utils/PHPStan/stubs/Model.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace CodeIgniter;

class Model
{
}