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

Improve types #228

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion database/factories/AddressFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AddressFactory extends Factory
/**
* The name of the factory's corresponding model.
*
* @var string
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = Address::class;

Expand Down
5 changes: 4 additions & 1 deletion database/factories/CartFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
use Cone\Bazar\Models\Cart;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
class CartFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = Cart::class;

Expand Down
2 changes: 1 addition & 1 deletion database/factories/CategoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CategoryFactory extends Factory
/**
* The name of the factory's corresponding model.
*
* @var string
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = Category::class;

Expand Down
5 changes: 4 additions & 1 deletion database/factories/ItemFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
use Cone\Bazar\Models\Item;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
class ItemFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = Item::class;

Expand Down
5 changes: 4 additions & 1 deletion database/factories/OrderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
use Cone\Bazar\Models\Transaction;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
class OrderFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = Order::class;

Expand Down
5 changes: 4 additions & 1 deletion database/factories/ProductFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
class ProductFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = Product::class;

Expand Down
5 changes: 4 additions & 1 deletion database/factories/PropertyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
class PropertyFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = Property::class;

Expand Down
5 changes: 4 additions & 1 deletion database/factories/PropertyValueFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
use Cone\Bazar\Models\PropertyValue;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
class PropertyValueFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = PropertyValue::class;

Expand Down
5 changes: 4 additions & 1 deletion database/factories/ShippingFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
use Cone\Bazar\Support\Facades\Shipping as Manager;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
class ShippingFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = Shipping::class;

Expand Down
5 changes: 4 additions & 1 deletion database/factories/TransactionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Date;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
class TransactionFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = Transaction::class;

Expand Down
5 changes: 4 additions & 1 deletion database/factories/VariantFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
use Cone\Root\Models\Meta;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
class VariantFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
* @var class-string<\Illuminate\Database\Eloquent\Model>
*/
protected $model = Variant::class;

Expand Down
10 changes: 10 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ parameters:
checkMissingIterableValueType: false
ignoreErrors:
- '#^Access to an undefined property Illuminate\\Database\\Eloquent\\Model::#'
# Incorrect framework types
-
path: 'src/Traits/HasPrices.php'
message: '#^Parameter \#2 \$type of method Illuminate\\Database\\Eloquent\\Model::getMorphs\(\) expects string, null given\.$#'
count: 2
-
path: 'src/Traits/HasPrices.php'
message: '#^Parameter \#3 \$id of method Illuminate\\Database\\Eloquent\\Model::getMorphs\(\) expects string, null given\.$#'
count: 2

4 changes: 2 additions & 2 deletions src/Models/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Address extends Model implements Contract
/**
* The accessors to append to the model's array form.
*
* @var array
* @var list<string>
*/
protected $appends = [
'name',
Expand Down Expand Up @@ -62,7 +62,7 @@ class Address extends Model implements Contract
/**
* The attributes that are mass assignable.
*
* @var array<string>
* @var list<string>
*/
protected $fillable = [
'address_secondary',
Expand Down
4 changes: 3 additions & 1 deletion src/Models/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Cart extends Model implements Contract
/**
* The attributes that are mass assignable.
*
* @var array<string>
* @var list<string>
*/
protected $fillable = [
'currency',
Expand Down Expand Up @@ -101,6 +101,8 @@ public function getMorphClass(): string

/**
* Get the order for the cart.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Cone\Bazar\Models\Order, \Cone\Bazar\Models\Cart>
*/
public function order(): BelongsTo
{
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Category extends Model implements Contract
/**
* The attributes that are mass assignable.
*
* @var array<string>
* @var list<string>
*/
protected $fillable = [
'description',
Expand Down
6 changes: 3 additions & 3 deletions src/Models/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Item extends Model implements Contract
/**
* The accessors to append to the model's array form.
*
* @var array<string>
* @var list<string>
*/
protected $appends = [
'subtotal',
Expand Down Expand Up @@ -60,7 +60,7 @@ class Item extends Model implements Contract
/**
* The attributes that are mass assignable.
*
* @var array<string>
* @var list<string>
*/
protected $fillable = [
'buyable_id',
Expand All @@ -75,7 +75,7 @@ class Item extends Model implements Contract
/**
* The attributes that should be hidden for arrays.
*
* @var array
* @var list<string>
*/
protected $hidden = [
'itemable',
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Order extends Model implements Contract
/**
* The accessors to append to the model's array form.
*
* @var array<string>
* @var list<string>
*/
protected $appends = [
'formatted_discount',
Expand Down Expand Up @@ -87,7 +87,7 @@ class Order extends Model implements Contract
/**
* The attributes that are mass assignable.
*
* @var array<string>
* @var list<string>
*/
protected $fillable = [
'currency',
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Product extends Model implements Contract
/**
* The attributes that are mass assignable.
*
* @var array<string>
* @var list<string>
*/
protected $fillable = [
'description',
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Property extends Model implements Contract
/**
* The attributes that are mass assignable.
*
* @var array<string>
* @var list<string>
*/
protected $fillable = [
'name',
Expand Down
2 changes: 1 addition & 1 deletion src/Models/PropertyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PropertyValue extends Model implements Contract
/**
* The attributes that are mass assignable.
*
* @var array<string>
* @var list<string>
*/
protected $fillable = [
'name',
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Shipping extends Model implements Contract
/**
* The attributes that are mass assignable.
*
* @var array<string>
* @var list<string>
*/
protected $fillable = [
'cost',
Expand Down
6 changes: 4 additions & 2 deletions src/Models/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Transaction extends Model implements Contract
/**
* The accessors to append to the model's array form.
*
* @var array<string>
* @var list<string>
*/
protected $appends = [
'driver_name',
Expand All @@ -47,7 +47,7 @@ class Transaction extends Model implements Contract
/**
* The attributes that are mass assignable.
*
* @var array<string>
* @var list<string>
*/
protected $fillable = [
'amount',
Expand Down Expand Up @@ -90,6 +90,8 @@ public function getMorphClass(): string

/**
* Get the order for the transaction.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\Cone\Bazar\Models\Order, \Cone\Bazar\Models\Transaction>
*/
public function order(): BelongsTo
{
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Variant.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Variant extends Model implements Contract
/**
* The attributes that are mass assignable.
*
* @var array<string>
* @var list<string>
*/
protected $fillable = [
'alias',
Expand Down
4 changes: 4 additions & 0 deletions src/Traits/InteractsWithItemables.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public function items(): MorphMany

/**
* Get the products for the model.
*
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough<\Cone\Bazar\Models\Order>
*/
public function orders(): HasManyThrough
{
Expand All @@ -30,6 +32,8 @@ public function orders(): HasManyThrough

/**
* Get the carts for the product.
*
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough<\Cone\Bazar\Models\Cart>
*/
public function carts(): HasManyThrough
{
Expand Down