mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 13:51:44 +00:00
- Install phpstan/phpstan, add phpstan.neon at level 5 targeting PHP 8.3 - Add phpstan-bootstrap.php stubs for Laravel helper functions (app, config, config_path, app_path, session) unavailable in standalone packages - Fix CartCondition::setOrder() - removed incorrect @return int (method is void) - Fix CartCondition::getCalculatedValue() - removed incorrect @return mixed PHPDoc - Fix Cart::condition() - remove redundant instanceof check the type system already guarantees - Fix Cart::fireEvent() - remove array_values() on already-list literal array - Fix ItemCollection - add @property annotations for magic __get properties - Fix ItemCollection::getAssociatedModel() - correct @return bool to @return mixed - Fix ItemCollection::getConditions() - remove dead is_array && !instanceof check - Fix Validator - add @method stub so PHPStan resolves make() through __callStatic - Add ignoreErrors for trait.unused (HasCart designed for external Livewire use) - Add ignoreErrors for round() mode mismatch (PHPStan 2.x PHP 8.4 stubs bug) - Add phpstan step to CI (PHP 8.3 only, matches phpVersion config)
57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Wearepixel\Cart\Validators;
|
|
|
|
use Illuminate\Validation\Factory;
|
|
use Illuminate\Filesystem\Filesystem;
|
|
use Illuminate\Translation\FileLoader;
|
|
use Illuminate\Translation\Translator;
|
|
|
|
/**
|
|
* @method static \Illuminate\Validation\Validator make(array $data, array $rules, array $messages = [], array $attributes = [])
|
|
*/
|
|
abstract class Validator
|
|
{
|
|
protected static $factory;
|
|
|
|
public static function instance()
|
|
{
|
|
if (! static::$factory) {
|
|
$loader = new FileLoader(
|
|
new Filesystem,
|
|
'/Translations'
|
|
);
|
|
|
|
$translator = new Translator($loader, 'en');
|
|
static::$factory = new Factory($translator);
|
|
}
|
|
|
|
return static::$factory;
|
|
}
|
|
|
|
public static function __callStatic($method, $args)
|
|
{
|
|
$instance = static::instance();
|
|
|
|
switch (count($args)) {
|
|
case 0:
|
|
return $instance->$method();
|
|
|
|
case 1:
|
|
return $instance->$method($args[0]);
|
|
|
|
case 2:
|
|
return $instance->$method($args[0], $args[1]);
|
|
|
|
case 3:
|
|
return $instance->$method($args[0], $args[1], $args[2]);
|
|
|
|
case 4:
|
|
return $instance->$method($args[0], $args[1], $args[2], $args[3]);
|
|
|
|
default:
|
|
return call_user_func_array([$instance, $method], $args);
|
|
}
|
|
}
|
|
}
|