soyhuce/phpstan-extension 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

soyhuce/phpstan-extension

Composer 安装命令:

composer require soyhuce/phpstan-extension

包简介

Extra rules for phpstan analysis

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status GitHub PHPStan Action Status Total Downloads

Strict rules for PHPStan and helpers for Laravel

Installation

You can install the package via composer:

composer require --dev soyhuce/phpstan-extension

If you use phpstan/extension-installer, the extension is automatically installed and you're all set.

Otherwise, you need to add the extension in your phpstan.neon file:

includes:
  - ./vendor/soyhuce/phpstan-extension/extension.neon

If you want only a subset of the rules, check the /vendor/soyhuce/phpstan-extension/extension.neon file and copy the rules you want to use.

Rules

CarbonCopyRule

Forbids usage of \Carbon\CarbonInterface::copy() because it is probably linked to usage of a mutable DateTime.

<?php

$datetime->copy()->addDay(); // ko
$datetime->addDay(); // ok

NoAliasUseRule

Forbids usage of Laravel aliases and suggests to use the real class name instead.

<?php

use Auth; // ko
use Illuminate\Support\Facades\Auth; // ok

NoMutableDateTimeStaticCallRule

Forbids usage of static methods on \DateTime and its child classes.

<?php

\Illuminate\Support\Carbon::create($year, $month, $day); // ko
\Illuminate\Support\Facade\Date::create($year, $month, $day); // ok
\Carbon\CarbonImmutable::create($year, $month, $day); // ok

NoMutableDateTimeUseRule

Forbids import of \DateTime and its child classes.

<?php

use Illuminate\Support\Carbon; // ko
use Carbon\Carbon; // ko
use Carbon\CarbonInterface; // ok
use Carbon\ImmutableCarbon; // ok

NoNewMutableDateTimeRule

Forbids usage of new \DateTime() and its child classes.

<?php

$dateTime = new Illuminate\Support\Carbon($date); // ko
$dateTime = new Carbon\Carbon($date); // ko
$dateTime = new Carbon\ImmutableCarbon($date); // ok

Extensions

RequestDateExtension

Provides return type for \Illuminate\Support\Request::date() method.

use Carbon\FactoryImmutable;
use Illuminate\Support\Facades\Date;

Date::use(FactoryImmutable::class);
$request->date('published_at'); // CarbonImmutable|null

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 22.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固