roslov/psr12ext 问题修复 & 功能扩展

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

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

roslov/psr12ext

Composer 安装命令:

composer require --dev roslov/psr12ext

包简介

PSR-12 Extended Coding Standard

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

This repository extends the PSR-12 coding style.

In addition to PSR-12 this coding style also contains some rules from the Slevomat Coding Standard and PHP_CodeSniffer.

Using This Code Style

After CodeSniffer is installed, you can launch it with a custom code style using the following syntax:

composer require --dev roslov/psr12ext
./vendor/bin/phpcs --extensions=php --standard=PSR12Ext /app

If you are planning to integrate the code quality check with your IDE or CI, create the file ruleset.xml in the project’s root folder.

This file can include the list of rules you want to disable, as well as your custom settings. For example:

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="project-code-styling">
    <description>Local Project Coding Standard</description>

    <!-- Excludes vendor and temporary folders -->
    <exclude-pattern>vendor/*</exclude-pattern>
    <exclude-pattern>var/*</exclude-pattern>

    <!-- Base standards (if not detected) -->
    <config name="installed_paths" value="vendor/roslov/psr12ext" />

    <!-- Sets the target PHP version: 8.3.0 -->
    <config name="php_version" value="80300" />

    <!-- Base rules -->
    <rule ref="PSR12Ext">
        <!-- Ignores line endings -->
        <exclude name="Generic.Files.LineEndings" />
        <!-- Disables strict type requirement -->
        <exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes" />
        <!-- Ignores missing parentheses in class instantiation -->
        <exclude name="PSR12.Classes.ClassInstantiation.MissingParentheses" />
    </rule>

    <!-- Rules for tests -->
    <rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
        <exclude-pattern>tests/*</exclude-pattern>
    </rule>
    <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
        <exclude-pattern>tests/*</exclude-pattern>
    </rule>
</ruleset>

Instead of <config name="php_version" value="80300" />, you can run phpcs --runtime-set php_version 80300

The List Of Rules Used In This Coding Standard

All used rules with their options are described in PSR12Ext/ruleset.xml.

Below you can find only names of the rules:

  • All rules of PSR12:
    • All rules of PSR1:
      • Generic.Files.ByteOrderMark
      • Generic.NamingConventions.UpperCaseConstantName
      • Generic.PHP.DisallowAlternativePHPTags
      • Generic.PHP.DisallowShortOpenTag
      • Generic.PHP.DisallowShortOpenTag.EchoFound
      • Squiz.Classes.ValidClassName
    • Generic.ControlStructures.InlineControlStructure
    • Generic.Files.LineEndings
    • Generic.Files.LineLength
    • Generic.Formatting.DisallowMultipleStatements
    • Generic.Functions.FunctionCallArgumentSpacing
    • Generic.PHP.LowerCaseConstant
    • Generic.PHP.LowerCaseKeyword
    • Generic.PHP.LowerCaseType
    • Generic.WhiteSpace.DisallowTabIndent
    • Generic.WhiteSpace.GotoTargetSpacing
    • Generic.WhiteSpace.IncrementDecrementSpacing
    • Generic.WhiteSpace.ScopeIndent
    • PEAR.Functions.ValidDefaultValue
    • PSR2.Classes.ClassDeclaration
    • PSR2.Classes.PropertyDeclaration
    • PSR2.ControlStructures.ElseIfDeclaration
    • PSR2.ControlStructures.SwitchDeclaration
    • PSR2.Files.ClosingTag
    • PSR2.Files.EndFileNewline
    • PSR2.Methods.FunctionCallSignature
    • PSR2.Methods.FunctionCallSignature.OpeningIndent
    • PSR2.Methods.FunctionCallSignature.SpaceAfterCloseBracket
    • PSR2.Methods.FunctionClosingBrace
    • PSR2.Methods.MethodDeclaration
    • PSR2.Methods.MethodDeclaration.Underscore
    • Squiz.ControlStructures.ControlSignature
    • Squiz.ControlStructures.ForEachLoopDeclaration
    • Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower
    • Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen
    • Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose
    • Squiz.ControlStructures.ForLoopDeclaration
    • Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterOpen
    • Squiz.ControlStructures.ForLoopDeclaration.SpacingBeforeClose
    • Squiz.ControlStructures.LowercaseDeclaration
    • Squiz.Functions.FunctionDeclaration
    • Squiz.Functions.FunctionDeclarationArgumentSpacing
    • Squiz.Functions.LowercaseFunctionKeywords
    • Squiz.Functions.MultiLineFunctionDeclaration
    • Squiz.Scope.MethodScope
    • Squiz.WhiteSpace.CastSpacing
    • Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen
    • Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose
    • Squiz.WhiteSpace.ScopeClosingBrace
    • Squiz.WhiteSpace.ScopeKeywordSpacing
    • Squiz.WhiteSpace.SuperfluousWhitespace
    • Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines
    • Squiz.WhiteSpace.SuperfluousWhitespace.EndFile
    • Squiz.WhiteSpace.SuperfluousWhitespace.StartFile
  • Custom rules:
    • Generic.Arrays.DisallowLongArraySyntax
    • Generic.CodeAnalysis.EmptyPHPStatement
    • Generic.CodeAnalysis.EmptyStatement
    • Generic.CodeAnalysis.JumbledIncrementer
    • Generic.CodeAnalysis.UnnecessaryFinalModifier
    • Generic.CodeAnalysis.UnusedFunctionParameter
    • Generic.CodeAnalysis.UselessOverridingMethod
    • Generic.ControlStructures.DisallowYodaConditions
    • Generic.Files.EndFileNewline
    • Generic.Files.ExecutableFile
    • Generic.Formatting.SpaceAfterCast
    • Generic.NamingConventions.InterfaceNameSuffix
    • Generic.NamingConventions.TraitNameSuffix
    • Generic.PHP.DisallowRequestSuperglobal
    • Generic.PHP.Syntax
    • Generic.Strings.UnnecessaryHeredoc
    • Generic.VersionControl.GitMergeConflict
    • Generic.WhiteSpace.HereNowdocIdentifierSpacing
    • Generic.WhiteSpace.SpreadOperatorSpacingAfter
    • PEAR.ControlStructures.ControlSignature
    • PSR1.Files.SideEffects
    • PSR1.Files.SideEffects.FoundWithSymbols
    • PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket
    • PSR12.Classes.AnonClassDeclaration
    • PSR12.Classes.ClosingBrace
    • PSR12.ControlStructures.BooleanOperatorPlacement
    • PSR12.ControlStructures.ControlStructureSpacing
    • PSR12.Files.DeclareStatement
    • PSR12.Files.FileHeader
    • PSR12.Files.ImportStatement
    • PSR12.Files.OpenTag
    • PSR12.Functions.ReturnTypeDeclaration
    • PSR12.Properties.ConstantVisibility
    • PSR12.Traits.UseDeclaration
    • SlevomatCodingStandard.Arrays.ArrayAccess
    • SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation
    • SlevomatCodingStandard.Arrays.DisallowPartiallyKeyed
    • SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace
    • SlevomatCodingStandard.Arrays.TrailingArrayComma
    • SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing
    • SlevomatCodingStandard.Attributes.AttributesOrder
    • SlevomatCodingStandard.Attributes.DisallowAttributesJoining
    • SlevomatCodingStandard.Attributes.DisallowMultipleAttributesPerLine
    • SlevomatCodingStandard.Attributes.RequireAttributeAfterDocComment
    • SlevomatCodingStandard.Classes.BackedEnumTypeSpacing
    • SlevomatCodingStandard.Classes.ClassConstantVisibility
    • SlevomatCodingStandard.Classes.ClassKeywordOrder
    • SlevomatCodingStandard.Classes.ClassLength
    • SlevomatCodingStandard.Classes.ClassMemberSpacing
    • SlevomatCodingStandard.Classes.ClassStructure
    • SlevomatCodingStandard.Classes.ConstantSpacing
    • SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants
    • SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition
    • SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition
    • SlevomatCodingStandard.Classes.DisallowStringExpressionPropertyFetch
    • SlevomatCodingStandard.Classes.EnumCaseSpacing
    • SlevomatCodingStandard.Classes.MethodSpacing
    • SlevomatCodingStandard.Classes.ModernClassNameReference
    • SlevomatCodingStandard.Classes.ParentCallSpacing
    • SlevomatCodingStandard.Classes.PropertyDeclaration
    • SlevomatCodingStandard.Classes.PropertySpacing
    • SlevomatCodingStandard.Classes.RequireAbstractOrFinal
    • SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature
    • SlevomatCodingStandard.Classes.RequireSelfReference
    • SlevomatCodingStandard.Classes.TraitUseOrder
    • SlevomatCodingStandard.Classes.TraitUseSpacing
    • SlevomatCodingStandard.Classes.UselessLateStaticBinding
    • SlevomatCodingStandard.Commenting.AnnotationName
    • SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration
    • SlevomatCodingStandard.Commenting.DisallowCommentAfterCode
    • SlevomatCodingStandard.Commenting.DocCommentSpacing
    • SlevomatCodingStandard.Commenting.EmptyComment
    • SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration
    • SlevomatCodingStandard.Commenting.RequireOneDocComment
    • SlevomatCodingStandard.Commenting.ThrowsAnnotationsOrder
    • SlevomatCodingStandard.Commenting.UselessFunctionDocComment
    • SlevomatCodingStandard.Complexity.Cognitive
    • SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch
    • SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing
    • SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses
    • SlevomatCodingStandard.ControlStructures.NewWithParentheses
    • SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator
    • SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator
    • SlevomatCodingStandard.ControlStructures.RequireNullSafeObjectOperator
    • SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn
    • SlevomatCodingStandard.ControlStructures.UselessTernaryOperator
    • SlevomatCodingStandard.Exceptions.CatchExceptionsOrder
    • SlevomatCodingStandard.Exceptions.DeadCatch
    • SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly
    • SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch
    • SlevomatCodingStandard.Files.FileLength
    • SlevomatCodingStandard.Functions.ArrowFunctionDeclaration
    • SlevomatCodingStandard.Functions.DisallowEmptyFunction
    • SlevomatCodingStandard.Functions.NamedArgumentSpacing
    • SlevomatCodingStandard.Functions.RequireMultiLineCall
    • SlevomatCodingStandard.Functions.RequireTrailingCommaInCall
    • SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse
    • SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration
    • SlevomatCodingStandard.Functions.StaticClosure
    • SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure
    • SlevomatCodingStandard.Functions.UselessParameterDefaultValue
    • SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses
    • SlevomatCodingStandard.Namespaces.DisallowGroupUse
    • SlevomatCodingStandard.Namespaces.MultipleUsesPerLine
    • SlevomatCodingStandard.Namespaces.NamespaceDeclaration
    • SlevomatCodingStandard.Namespaces.NamespaceSpacing
    • SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly
    • SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile
    • SlevomatCodingStandard.Namespaces.UnusedUses
    • SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash
    • SlevomatCodingStandard.Namespaces.UselessAlias
    • SlevomatCodingStandard.Namespaces.UseSpacing
    • SlevomatCodingStandard.Operators.NegationOperatorSpacing
    • SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator
    • SlevomatCodingStandard.Operators.SpreadOperatorSpacing
    • SlevomatCodingStandard.PHP.ForbiddenClasses
    • SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking
    • SlevomatCodingStandard.PHP.RequireExplicitAssertion
    • SlevomatCodingStandard.PHP.ShortList
    • SlevomatCodingStandard.PHP.UselessParentheses
    • SlevomatCodingStandard.PHP.UselessSemicolon
    • SlevomatCodingStandard.Strings.DisallowVariableParsing
    • SlevomatCodingStandard.TypeHints.ClassConstantTypeHint
    • SlevomatCodingStandard.TypeHints.DeclareStrictTypes
    • SlevomatCodingStandard.TypeHints.DNFTypeHintFormat
    • SlevomatCodingStandard.TypeHints.LongTypeHints
    • SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue
    • SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition
    • SlevomatCodingStandard.TypeHints.ParameterTypeHint
    • SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing
    • SlevomatCodingStandard.TypeHints.PropertyTypeHint
    • SlevomatCodingStandard.TypeHints.ReturnTypeHint
    • SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing
    • SlevomatCodingStandard.TypeHints.UselessConstantTypeHint
    • SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable
    • SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable
    • SlevomatCodingStandard.Variables.UnusedVariable
    • SlevomatCodingStandard.Variables.UselessVariable
    • SlevomatCodingStandard.Whitespaces.DuplicateSpaces
    • Squiz.Classes.ClassDeclaration
    • Squiz.Classes.LowercaseClassKeywords
    • Squiz.Commenting.DocCommentAlignment
    • Squiz.Commenting.PostStatementComment
    • Squiz.PHP.NonExecutableCode
    • Squiz.Scope.StaticThisUsage
    • Squiz.Strings.ConcatenationSpacing
    • Squiz.Strings.DoubleQuoteUsage.NotRequired
    • Squiz.WhiteSpace.ControlStructureSpacing
    • Squiz.WhiteSpace.OperatorSpacing

Versioning

PSR-12 Extended Coding Standard uses a MAJOR.MINOR.PATCH version number format.

The MAJOR version is incremented when:

  • the major version of Slevomat Coding Standard is changed, or
  • the major version of PHP_CodeSniffer is changed, or
  • the major version of PHP is added, or
  • the minor version of PHP is removed, or
  • backward-incompatible changes are made to the ruleset.xml format, or
  • existing sniffs are removed from this standard (removed from the list).

The MINOR version is incremented when:

  • the minor version of Slevomat Coding Standard is changed, or
  • the minor version of PHP_CodeSniffer is changed, or
  • the minor version of PHP is added, or
  • new sniffs are enabled in this standard (added to the list), or
  • backward-compatible changes are made to the ruleset.xml format.

The PATCH version is incremented when:

  • backward-compatible bug fixes are made.

roslov/psr12ext 适用场景与选型建议

roslov/psr12ext 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27.39k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 06 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「codesniffer」 「dev」 「slevomat」 「psr12」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 roslov/psr12ext 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 roslov/psr12ext 我们能提供哪些服务?
定制开发 / 二次开发

基于 roslov/psr12ext 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 27.39k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 26
  • 依赖项目数: 8
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-05