Skip to content

Commit

Permalink
Cover all BaseObject::__construct() overrides with stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
erickskrauch committed Nov 28, 2023
1 parent 3a544ce commit d68e167
Show file tree
Hide file tree
Showing 17 changed files with 221 additions and 1 deletion.
12 changes: 12 additions & 0 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ parameters:
config_path: null
stubFiles:
- src/Stubs/base/Action.stub
- src/Stubs/base/ActionEvent.stub
- src/Stubs/base/BaseObject.stub
- src/Stubs/base/Behavior.stub
- src/Stubs/base/Component.stub
- src/Stubs/base/Controller.stub
- src/Stubs/base/DynamicModel.stub
- src/Stubs/base/Event.stub
- src/Stubs/base/InlineAction.stub
- src/Stubs/base/Model.stub
- src/Stubs/base/Module.stub
- src/Stubs/base/Request.stub
- src/Stubs/base/Response.stub

Expand All @@ -22,16 +26,24 @@ parameters:
- src/Stubs/db/ActiveRecord.stub
- src/Stubs/db/BatchQueryResult.stub
- src/Stubs/db/ColumnSchemaBuilder.stub
- src/Stubs/db/Command.stub
- src/Stubs/db/Connection.stub
- src/Stubs/db/DataReader.stub
- src/Stubs/db/Expression.stub
- src/Stubs/db/Migration.stub
- src/Stubs/db/QueryBuilder.stub
- src/Stubs/db/SqlTokenizer.stub

- src/Stubs/test/BaseActiveFixture.stub
- src/Stubs/test/Fixture.stub

- src/Stubs/validators/InlineValidator.stub
- src/Stubs/validators/Validator.stub

- src/Stubs/web/Cookie.stub
- src/Stubs/web/CookieCollection.stub
- src/Stubs/web/HeaderCollection.stub
- src/Stubs/web/JsExpression.stub

- src/Stubs/BaseYii.stub
dynamicConstantNames:
Expand Down
9 changes: 9 additions & 0 deletions src/Stubs/base/Action.stub
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ namespace yii\base;

class Action {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param string $id
* @param \yii\base\Controller $controller
* @param array<string, mixed> $config
*/
public function __construct($id, $controller, $config = []) {}

}
16 changes: 16 additions & 0 deletions src/Stubs/base/ActionEvent.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);

namespace yii\base;

class ActionEvent {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param \yii\base\Action $action
* @param array<string, mixed> $config
*/
public function __construct($action, $config = []) {}

}
9 changes: 9 additions & 0 deletions src/Stubs/base/Controller.stub
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ namespace yii\base;
*/
class Controller {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param string $id
* @param \yii\base\Module $module
* @param array<string, mixed> $config
*/
public function __construct($id, $module, $config = []) {}

/**
* @return array<string, class-string<Action>|array{class: class-string<Action>}|array{__class: class-string<Action>}|callable(): Action>
*/
Expand Down
16 changes: 16 additions & 0 deletions src/Stubs/base/DynamicModel.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);

namespace yii\base;

class DynamicModel {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param array<string, mixed> $attributes
* @param array<string, mixed> $config
*/
public function __construct(array $attributes = [], $config = []) {}

}
18 changes: 18 additions & 0 deletions src/Stubs/base/InlineAction.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);

namespace yii\base;

class InlineAction {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param string $id
* @param \yii\base\Controller $controller
* @param string $actionMethod
* @param array<string, mixed> $config
*/
public function __construct($id, $controller, $actionMethod, $config = []) {}

}
17 changes: 17 additions & 0 deletions src/Stubs/base/Module.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);

namespace yii\base;

class Module {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param string $id
* @param \yii\base\Module|null $parent
* @param array<string, mixed> $config
*/
public function __construct($id, $parent = null, $config = []) {}

}
2 changes: 1 addition & 1 deletion src/Stubs/db/ActiveQuery.stub
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ActiveQuery {

/**
* @param class-string<T> $modelClass
* @param array<mixed> $config
* @param array<string, mixed> $config
*/
public function __construct($modelClass, $config = []) {}

Expand Down
10 changes: 10 additions & 0 deletions src/Stubs/db/ColumnSchemaBuilder.stub
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,14 @@ namespace yii\db;

class ColumnSchemaBuilder {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param string $type
* @param int|string|list<string|int>|null $length
* @param \yii\db\Connection|null $db
* @param array<string, mixed> $config
*/
public function __construct($type, $length = null, $db = null, $config = []) {}

}
8 changes: 8 additions & 0 deletions src/Stubs/db/Command.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
declare(strict_types=1);

namespace yii\db;

class Command {

}
16 changes: 16 additions & 0 deletions src/Stubs/db/DataReader.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);

namespace yii\db;

class DataReader {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param \yii\db\Command $command
* @param array<string, mixed> $config
*/
public function __construct(Command $command, $config = []) {}

}
17 changes: 17 additions & 0 deletions src/Stubs/db/Expression.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);

namespace yii\db;

class Expression {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param string $expression
* @param array<mixed> $params
* @param array<string, mixed> $config
*/
public function __construct($expression, $params = [], $config = []) {}

}
16 changes: 16 additions & 0 deletions src/Stubs/db/QueryBuilder.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);

namespace yii\db;

class QueryBuilder {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param \yii\db\Connection $connection
* @param array<string, mixed> $config
*/
public function __construct($connection, $config = []) {}

}
16 changes: 16 additions & 0 deletions src/Stubs/db/SqlTokenizer.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);

namespace yii\db;

abstract class SqlTokenizer {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param string $sql
* @param array<string, mixed> $config
*/
public function __construct($sql, $config = []) {}

}
8 changes: 8 additions & 0 deletions src/Stubs/web/Cookie.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
declare(strict_types=1);

namespace yii\web;

class Cookie {

}
16 changes: 16 additions & 0 deletions src/Stubs/web/CookieCollection.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);

namespace yii\web;

class CookieCollection {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param array<string, \yii\web\Cookie> $cookies
* @param array<string, mixed> $config
*/
public function __construct($cookies = [], $config = []) {}

}
16 changes: 16 additions & 0 deletions src/Stubs/web/JsExpression.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);

namespace yii\web;

class JsExpression {

/**
* TODO: remove when https://github.com/phpstan/phpstan/issues/10198 will be fixed
*
* @param string $expression
* @param array<string, mixed> $config
*/
public function __construct($expression, $config = []) {}

}

0 comments on commit d68e167

Please sign in to comment.