diff --git a/CHANGELOG.md b/CHANGELOG.md index cf408e83..71975684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ Earlier releases are listed on the [releases page](https://github.com/Pollora/co ## [Unreleased] +### Changed + +- PHPDoc only, no change of signature or behaviour: array value types and the missing `@return` / `@param` tags that PHPStan level 6 asks for. Array types are written `array`, so a subclass that redeclares one of these properties or methods is not held to a narrower type. The analysed level stays at 5. + ## [11.1.0] - 2026-11-19 ### Changed diff --git a/src/Concerns/Aliases.php b/src/Concerns/Aliases.php index e00f5e0e..b38c4c6a 100644 --- a/src/Concerns/Aliases.php +++ b/src/Concerns/Aliases.php @@ -14,7 +14,7 @@ trait Aliases { /** - * @return array + * @return array */ public static function getAliases() { @@ -28,6 +28,7 @@ public static function getAliases() /** * @param string $new * @param string $old + * @return void */ public static function addAlias($new, $old) { diff --git a/src/Concerns/MetaFields.php b/src/Concerns/MetaFields.php index ca3b6835..6766ecd0 100644 --- a/src/Concerns/MetaFields.php +++ b/src/Concerns/MetaFields.php @@ -52,7 +52,7 @@ public function meta() } /** - * @param string|array $meta + * @param string|array $meta * @param mixed $value */ public function scopeHasMeta(Builder $query, $meta, $value = null, string $operator = '='): Builder @@ -98,7 +98,7 @@ public function saveField($key, $value) } /** - * @param string|array $key + * @param string|array $key * @param mixed $value * @return bool */ @@ -128,7 +128,7 @@ public function createField($key, $value) } /** - * @param string|array $key + * @param string|array $key * @param mixed $value * @return Model|Collection */ diff --git a/src/Concerns/Shortcodes.php b/src/Concerns/Shortcodes.php index a875bc37..d20fb716 100644 --- a/src/Concerns/Shortcodes.php +++ b/src/Concerns/Shortcodes.php @@ -18,7 +18,7 @@ trait Shortcodes { /** - * @var array + * @var array */ protected static $shortcodes = []; @@ -28,6 +28,7 @@ trait Shortcodes /** * @param string $tag the shortcode tag * @param \Closure $function the shortcode handling function + * @return void */ public static function addShortcode($tag, $function) { @@ -38,6 +39,7 @@ public static function addShortcode($tag, $function) * Removes a shortcode handler. * * @param string $tag the shortcode tag + * @return void */ public static function removeShortcode($tag) { @@ -84,6 +86,9 @@ private function getShortcodeHandlerInstance(): ShortcodeFacade }); } + /** + * @return void + */ private function parseClassShortcodes(ShortcodeFacade $facade) { foreach (self::$shortcodes as $tag => $func) { @@ -91,6 +96,9 @@ private function parseClassShortcodes(ShortcodeFacade $facade) } } + /** + * @return void + */ private function parseConfigShortcodes(ShortcodeFacade $facade) { if (Colt::isLaravel()) { diff --git a/src/Database.php b/src/Database.php index 72d925b6..1fff1bb5 100644 --- a/src/Database.php +++ b/src/Database.php @@ -15,7 +15,7 @@ class Database { /** - * @var array + * @var array */ protected static $baseParams = [ 'driver' => 'mysql', @@ -25,6 +25,9 @@ class Database 'prefix' => 'wp_', ]; + /** + * @param array $params connection settings, merged over the defaults + */ public static function connect(array $params): Manager { $capsule = new Capsule; diff --git a/src/Laravel/Auth/AuthUserProvider.php b/src/Laravel/Auth/AuthUserProvider.php index 64bec0cc..93d54c01 100644 --- a/src/Laravel/Auth/AuthUserProvider.php +++ b/src/Laravel/Auth/AuthUserProvider.php @@ -20,10 +20,13 @@ class AuthUserProvider implements UserProvider { /** - * @var array + * @var array */ protected $config = []; + /** + * @param array $config + */ public function __construct(array $config = []) { $this->config = $config; @@ -74,6 +77,7 @@ public function updateRememberToken(Authenticatable $user, $token) /** * Retrieve a user by the given credentials. * + * @param array $credentials * @return Authenticatable|null */ public function retrieveByCredentials(array $credentials) @@ -95,6 +99,8 @@ public function retrieveByCredentials(array $credentials) /** * Validate a user against the given credentials. + * + * @param array $credentials */ public function validateCredentials(Authenticatable $user, array $credentials): bool { @@ -106,6 +112,9 @@ public function validateCredentials(Authenticatable $user, array $credentials): ->check($credentials['password'], $user->user_pass); } + /** + * @param array $credentials + */ public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false) { // diff --git a/src/Model.php b/src/Model.php index 5c131993..8f8ed6b5 100644 --- a/src/Model.php +++ b/src/Model.php @@ -222,6 +222,9 @@ public function getConnectionName() /** * Set the connection name to model. + * + * @param mixed $model anything; only Eloquent models are touched + * @return void */ protected function setRelationConnection($model) { @@ -230,6 +233,10 @@ protected function setRelationConnection($model) } } + /** + * @param mixed $instance the related model + * @return mixed + */ protected function setInstanceConnection($instance) { return $instance->setConnection( diff --git a/src/Model/Attachment.php b/src/Model/Attachment.php index bc9dfdd1..188ee712 100644 --- a/src/Model/Attachment.php +++ b/src/Model/Attachment.php @@ -25,7 +25,7 @@ class Attachment extends Post protected $postType = 'attachment'; /** - * @var array + * @var array */ protected $appends = [ 'title', @@ -37,7 +37,7 @@ class Attachment extends Post ]; /** - * @var array + * @var array */ protected static $aliases = [ 'title' => 'post_title', diff --git a/src/Model/Builder/PostBuilder.php b/src/Model/Builder/PostBuilder.php index bfd6ccfb..8b8a7514 100644 --- a/src/Model/Builder/PostBuilder.php +++ b/src/Model/Builder/PostBuilder.php @@ -5,6 +5,7 @@ namespace Pollora\Colt\Model\Builder; use Carbon\Carbon; +use Illuminate\Contracts\Support\Arrayable; use Illuminate\Database\Eloquent\Builder; /** @@ -47,6 +48,7 @@ public function type($type) } /** + * @param array $types * @return PostBuilder */ public function typeIn(array $types) @@ -88,7 +90,7 @@ public function taxonomy($taxonomy, $terms) } /** - * @param mixed $term + * @param string|Arrayable|iterable|false|null $term words, or a list of them * @return PostBuilder */ public function search($term = false) diff --git a/src/Model/Builder/TaxonomyBuilder.php b/src/Model/Builder/TaxonomyBuilder.php index aa50e6fa..512cfb52 100644 --- a/src/Model/Builder/TaxonomyBuilder.php +++ b/src/Model/Builder/TaxonomyBuilder.php @@ -55,6 +55,7 @@ public function slug($slug = null) } /** + * @param string|null $slug * @return TaxonomyBuilder */ public function term($slug = null) diff --git a/src/Model/Comment.php b/src/Model/Comment.php index e0385b32..2d691e18 100644 --- a/src/Model/Comment.php +++ b/src/Model/Comment.php @@ -43,7 +43,7 @@ class Comment extends Model protected $primaryKey = 'comment_ID'; /** - * @var array + * @var array */ protected $dates = ['comment_date']; diff --git a/src/Model/Menu.php b/src/Model/Menu.php index fb625919..8e132c62 100644 --- a/src/Model/Menu.php +++ b/src/Model/Menu.php @@ -20,7 +20,7 @@ class Menu extends Taxonomy protected $taxonomy = 'nav_menu'; /** - * @var array + * @var array */ protected $with = ['term', 'items']; diff --git a/src/Model/MenuItem.php b/src/Model/MenuItem.php index 48850d7c..33235227 100644 --- a/src/Model/MenuItem.php +++ b/src/Model/MenuItem.php @@ -20,7 +20,7 @@ class MenuItem extends Post protected $postType = 'nav_menu_item'; /** - * @var array + * @var array */ protected $instanceRelations = [ 'post' => Post::class, diff --git a/src/Model/Meta/Meta.php b/src/Model/Meta/Meta.php index 57287add..7667a7a7 100644 --- a/src/Model/Meta/Meta.php +++ b/src/Model/Meta/Meta.php @@ -31,7 +31,7 @@ abstract class Meta extends Model protected $primaryKey = 'meta_id'; /** - * @var array + * @var array */ protected $appends = ['value']; diff --git a/src/Model/Meta/ThumbnailMeta.php b/src/Model/Meta/ThumbnailMeta.php index f5048ec6..df34e2d9 100644 --- a/src/Model/Meta/ThumbnailMeta.php +++ b/src/Model/Meta/ThumbnailMeta.php @@ -26,7 +26,7 @@ class ThumbnailMeta extends PostMeta const SIZE_FULL = 'full'; /** - * @var array + * @var array */ protected $with = ['attachment']; diff --git a/src/Model/Option.php b/src/Model/Option.php index 17937fb1..c8403c3e 100644 --- a/src/Model/Option.php +++ b/src/Model/Option.php @@ -46,7 +46,7 @@ class Option extends Model ]; /** - * @var array + * @var array */ protected $appends = ['value']; @@ -85,7 +85,7 @@ public static function get($name) } /** - * @return array + * @return array * * @deprecated */ @@ -95,8 +95,8 @@ public static function getAll() } /** - * @param array $keys - * @return array + * @param array $keys + * @return array */ public static function asArray($keys = []) { @@ -112,7 +112,7 @@ public static function asArray($keys = []) } /** - * @return array + * @return array */ public function toArray() { diff --git a/src/Model/Post.php b/src/Model/Post.php index 3a7b22be..5691ad3a 100644 --- a/src/Model/Post.php +++ b/src/Model/Post.php @@ -60,17 +60,17 @@ class Post extends Model protected $primaryKey = 'ID'; /** - * @var array + * @var array */ protected $dates = ['post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt']; /** - * @var array + * @var array */ protected $with = ['meta']; /** - * @var array + * @var array */ protected static $postTypes = []; @@ -88,7 +88,7 @@ class Post extends Model ]; /** - * @var array + * @var array */ protected $appends = [ 'title', @@ -111,7 +111,7 @@ class Post extends Model ]; /** - * @var array + * @var array */ protected static $aliases = [ 'title' => 'post_title', @@ -136,7 +136,7 @@ class Post extends Model protected ?PostCollection $siblings = null; /** - * @param array $attributes + * @param array $attributes * @return static */ public function newFromBuilder($attributes = [], $connection = null) @@ -324,7 +324,7 @@ public function getImageAttribute() /** * Gets all the terms arranged taxonomy => terms[]. * - * @return array + * @return array */ public function getTermsAttribute() { @@ -358,7 +358,7 @@ public function getMainCategoryAttribute() /** * Gets the keywords as array. * - * @return array + * @return array */ public function getKeywordsAttribute() { @@ -376,6 +376,7 @@ public function getKeywordsStrAttribute(): string /** * @param string $name The post type slug * @param string $class The class to be instantiated + * @return void */ public static function registerPostType($name, $class) { @@ -384,6 +385,8 @@ public static function registerPostType($name, $class) /** * Clears any registered post types. + * + * @return void */ public static function clearRegisteredPostTypes() { @@ -428,6 +431,7 @@ public function __get($key) } /** + * @param array $attributes * @return static */ protected function getPostInstance(array $attributes) diff --git a/src/Model/Taxonomy.php b/src/Model/Taxonomy.php index 714aab9e..4e1b5d1a 100644 --- a/src/Model/Taxonomy.php +++ b/src/Model/Taxonomy.php @@ -38,7 +38,7 @@ class Taxonomy extends Model protected $primaryKey = 'term_taxonomy_id'; /** - * @var array + * @var array */ protected $with = ['term']; diff --git a/src/Model/User.php b/src/Model/User.php index 910f902e..1ec9a7e5 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -50,17 +50,17 @@ class User extends Model implements Authenticatable, CanResetPassword protected $hidden = ['user_pass']; /** - * @var array + * @var array */ protected $dates = ['user_registered']; /** - * @var array + * @var array */ protected $with = ['meta']; /** - * @var array + * @var array */ protected static $aliases = [ 'login' => 'user_login', @@ -77,7 +77,7 @@ class User extends Model implements Authenticatable, CanResetPassword /** * The accessors to append to the model's array form. * - * @var array + * @var array */ protected $appends = [ 'login', @@ -93,6 +93,7 @@ class User extends Model implements Authenticatable, CanResetPassword /** * @param mixed $value + * @return void */ public function setUpdatedAtAttribute($value) {}