Skip to content

Commit

Permalink
Fix recent static analysis errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo committed Mar 2, 2023
1 parent 13bffb8 commit 5b2dd60
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 37 deletions.
4 changes: 2 additions & 2 deletions src/Database/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class Model extends EloquentModel implements ModelInterface
use \Winter\Storm\Database\Traits\DeferredBinding;

/**
* @var array Behaviors implemented by this model.
* @var string|array|null Extensions implemented by this class.
*/
public $implement;
public $implement = null;

/**
* @var array Make the model's attributes public so behaviors can modify them.
Expand Down
5 changes: 4 additions & 1 deletion src/Database/Traits/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,13 @@ protected function getRelationValidationValue($relationName)
* Instantiates the validator used by the validation process, depending if the class
* is being used inside or outside of Laravel. Optional connection string to make
* the validator use a different database connection than the default connection.
* @return \Illuminate\Validation\Validator
*
* @return \Illuminate\Contracts\Validation\Validator
* @phpstan-return \Illuminate\Validation\Validator
*/
protected static function makeValidator($data, $rules, $customMessages, $attributeNames, $connection = null)
{
/** @var \Illuminate\Validation\Validator $validator */
$validator = Validator::make($data, $rules, $customMessages, $attributeNames);

if ($connection !== null) {
Expand Down
4 changes: 2 additions & 2 deletions src/Extension/Extendable.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class Extendable
use ExtendableTrait;

/**
* @var array Extensions implemented by this class.
* @var string|array|null Extensions implemented by this class.
*/
public $implement;
public $implement = null;

/**
* Constructor
Expand Down
13 changes: 3 additions & 10 deletions src/Extension/ExtendableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*
* @author Alexey Bobkov, Samuel Georges
*/

trait ExtendableTrait
{
/**
Expand Down Expand Up @@ -72,18 +71,12 @@ public function extendableConstruct()
/*
* Apply extensions
*/
if (!$this->implement) {
return;
}

if (is_string($this->implement)) {
$uses = explode(',', $this->implement);
}
elseif (is_array($this->implement)) {
} elseif (is_array($this->implement)) {
$uses = $this->implement;
}
else {
throw new Exception(sprintf('Class %s contains an invalid $implement value', get_class($this)));
} else {
return;
}

foreach ($uses as $use) {
Expand Down
22 changes: 5 additions & 17 deletions src/Foundation/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
class Kernel extends HttpKernel
{
/**
* The bootstrap classes for the application.
*
* @var string[]
* {@inheritDoc}
*/
protected $bootstrappers = [
\Winter\Storm\Foundation\Bootstrap\RegisterClassLoader::class,
Expand All @@ -22,9 +20,7 @@ class Kernel extends HttpKernel
];

/**
* The application's global HTTP middleware stack.
*
* @var array
* {@inheritDoc}
*/
protected $middleware = [
\Winter\Storm\Foundation\Http\Middleware\CheckForTrustedHost::class,
Expand All @@ -33,9 +29,7 @@ class Kernel extends HttpKernel
];

/**
* The application's route middleware.
*
* @var array
* {@inheritDoc}
*/
protected $routeMiddleware = [
// 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
Expand All @@ -47,9 +41,7 @@ class Kernel extends HttpKernel
];

/**
* The application's route middleware groups.
*
* @var array
* {@inheritDoc}
*/
protected $middlewareGroups = [
'web' => [
Expand All @@ -67,11 +59,7 @@ class Kernel extends HttpKernel
];

/**
* The priority-sorted list of middleware.
*
* Forces the listed middleware to always be in the given order.
*
* @var string[]
* {@inheritDoc}
*/
protected $middlewarePriority = [
\Illuminate\Session\Middleware\StartSession::class,
Expand Down
4 changes: 2 additions & 2 deletions src/Network/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Http
/**
* @var array cURL Options.
*/
public $requestOptions;
public $requestOptions = [];

/**
* @var array Request data.
Expand Down Expand Up @@ -280,7 +280,7 @@ public function send()
curl_setopt($curl, CURLOPT_MAXREDIRS, $this->maxRedirects);
}

if ($this->requestOptions && is_array($this->requestOptions)) {
if (count($this->requestOptions)) {
curl_setopt_array($curl, $this->requestOptions);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Support/Facades/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* @method static \Doctrine\DBAL\Driver\PDOConnection getPdo()
* @method static \Illuminate\Database\ConnectionInterface connection(string $name = null)
* @method static \Illuminate\Database\Connection connection(string $name = null)
* @method static \Winter\Storm\Database\QueryBuilder table(string $table, string $as = null)
* @method static \Illuminate\Database\Query\Expression raw($value)
* @method static array getQueryLog()
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Facades/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* @method static bool exists(string $path)
* @method static string get(string $path, bool $lock)
* @method static string get(string $path, bool $lock = false)
* @method static string sharedGet(string $path)
* @method static mixed getRequire(string $path)
* @method static mixed requireOnce(string $file)
Expand Down
4 changes: 3 additions & 1 deletion src/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ function e($value, $doubleEncode = false)
*/
function trans($id = null, $parameters = [], $locale = null)
{
return app('translator')->trans($id, $parameters, $locale);
/** @var \Winter\Storm\Translation\Translator $translator */
$translator = app('translator');
return $translator->trans($id, $parameters, $locale);
}
}

Expand Down

0 comments on commit 5b2dd60

Please sign in to comment.