allysonsilva/php-coding-standard
Composer 安装命令:
composer require allysonsilva/php-coding-standard
包简介
Coding Standard for PHP_CodeSniffer.
README 文档
README
Install
Requires PHP 7.2+
To get started with php-coding-standard, use Composer to add the package to your project's dependencies:
composer require allysonsilva/php-coding-standard --dev
Sniffs
Use the command to check the amount of sniffs in Coding Standard applied:
./vendor/bin/phpcs --standard=PSR12 -e // or ./vendor/bin/phpcs --standard=Generic -e
Use the command to view documentation for any specific sniffs:
./vendor/bin/phpcs --standard=PSR12 --sniffs=PSR12.Namespaces.CompoundNamespaceDepth --generator=text // or ./vendor/bin/phpcs --standard=Squiz --sniffs=Squiz.Classes.SelfMemberReference --generator=text
The AppStandard standard contains 168 sniffs:
Generic (39 sniffs)
-------------------
Generic.Arrays.ArrayIndent
Generic.Arrays.DisallowLongArraySyntax
Generic.Classes.DuplicateClassName
Generic.CodeAnalysis.EmptyPHPStatement
Generic.CodeAnalysis.EmptyStatement
Generic.CodeAnalysis.UnconditionalIfStatement
Generic.CodeAnalysis.UnnecessaryFinalModifier
Generic.CodeAnalysis.UnusedFunctionParameter
Generic.CodeAnalysis.UselessOverridingMethod
Generic.ControlStructures.InlineControlStructure
Generic.Files.ByteOrderMark
Generic.Files.InlineHTML
Generic.Files.LineEndings
Generic.Files.LineLength
Generic.Files.OneClassPerFile
Generic.Files.OneInterfacePerFile
Generic.Files.OneObjectStructurePerFile
Generic.Files.OneTraitPerFile
Generic.Formatting.DisallowMultipleStatements
Generic.Formatting.SpaceAfterCast
Generic.Formatting.SpaceAfterNot
Generic.Functions.CallTimePassByReference
Generic.Functions.FunctionCallArgumentSpacing
Generic.NamingConventions.UpperCaseConstantName
Generic.PHP.CharacterBeforePHPOpeningTag
Generic.PHP.DeprecatedFunctions
Generic.PHP.DisallowAlternativePHPTags
Generic.PHP.DisallowShortOpenTag
Generic.PHP.ForbiddenFunctions
Generic.PHP.LowerCaseConstant
Generic.PHP.LowerCaseKeyword
Generic.PHP.LowerCaseType
Generic.Strings.UnnecessaryStringConcat
Generic.WhiteSpace.ArbitraryParenthesesSpacing
Generic.WhiteSpace.DisallowTabIndent
Generic.WhiteSpace.IncrementDecrementSpacing
Generic.WhiteSpace.LanguageConstructSpacing
Generic.WhiteSpace.ScopeIndent
Generic.WhiteSpace.SpreadOperatorSpacingAfter
ObjectCalisthenics (9 sniffs)
-----------------------------
ObjectCalisthenics.Classes.ForbiddenPublicProperty
ObjectCalisthenics.CodeAnalysis.OneObjectOperatorPerLine
ObjectCalisthenics.Files.ClassTraitAndInterfaceLength
ObjectCalisthenics.Files.FunctionLength
ObjectCalisthenics.Metrics.MaxNestingLevel
ObjectCalisthenics.Metrics.MethodPerClassLimit
ObjectCalisthenics.Metrics.PropertyPerClassLimit
ObjectCalisthenics.NamingConventions.ElementNameMinimalLength
ObjectCalisthenics.NamingConventions.NoSetter
PEAR (4 sniffs)
---------------
PEAR.Commenting.InlineComment
PEAR.Functions.ValidDefaultValue
PEAR.WhiteSpace.ObjectOperatorIndent
PEAR.WhiteSpace.ScopeClosingBrace
PSR1 (3 sniffs)
---------------
PSR1.Classes.ClassDeclaration
PSR1.Files.SideEffects
PSR1.Methods.CamelCapsMethodName
PSR12 (16 sniffs)
-----------------
PSR12.Classes.AnonClassDeclaration
PSR12.Classes.ClassInstantiation
PSR12.Classes.ClosingBrace
PSR12.ControlStructures.BooleanOperatorPlacement
PSR12.ControlStructures.ControlStructureSpacing
PSR12.Files.DeclareStatement
PSR12.Files.FileHeader
PSR12.Files.ImportStatement
PSR12.Files.OpenTag
PSR12.Functions.NullableTypeDeclaration
PSR12.Functions.ReturnTypeDeclaration
PSR12.Keywords.ShortFormTypeKeywords
PSR12.Namespaces.CompoundNamespaceDepth
PSR12.Operators.OperatorSpacing
PSR12.Properties.ConstantVisibility
PSR12.Traits.UseDeclaration
PSR2 (9 sniffs)
---------------
PSR2.Classes.ClassDeclaration
PSR2.Classes.PropertyDeclaration
PSR2.ControlStructures.ElseIfDeclaration
PSR2.ControlStructures.SwitchDeclaration
PSR2.Files.ClosingTag
PSR2.Files.EndFileNewline
PSR2.Methods.FunctionCallSignature
PSR2.Methods.FunctionClosingBrace
PSR2.Methods.MethodDeclaration
SlevomatCodingStandard (48 sniffs)
----------------------------------
SlevomatCodingStandard.Arrays.TrailingArrayComma
SlevomatCodingStandard.Classes.ClassConstantVisibility
SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants
SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces
SlevomatCodingStandard.Classes.ModernClassNameReference
SlevomatCodingStandard.Classes.TraitUseSpacing
SlevomatCodingStandard.Classes.UnusedPrivateElements
SlevomatCodingStandard.Classes.UselessLateStaticBinding
SlevomatCodingStandard.Commenting.DocCommentSpacing
SlevomatCodingStandard.Commenting.ForbiddenAnnotations
SlevomatCodingStandard.Commenting.ForbiddenComments
SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration
SlevomatCodingStandard.ControlStructures.ControlStructureSpacing
SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses
SlevomatCodingStandard.ControlStructures.NewWithParentheses
SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator
SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator
SlevomatCodingStandard.Exceptions.DeadCatch
SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure
SlevomatCodingStandard.Functions.UnusedParameter
SlevomatCodingStandard.Functions.UselessParameterDefaultValue
SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses
SlevomatCodingStandard.Namespaces.NamespaceDeclaration
SlevomatCodingStandard.Namespaces.NamespaceSpacing
SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly
SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile
SlevomatCodingStandard.Namespaces.UnusedUses
SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash
SlevomatCodingStandard.Namespaces.UseFromSameNamespace
SlevomatCodingStandard.Namespaces.UseSpacing
SlevomatCodingStandard.Namespaces.UselessAlias
SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator
SlevomatCodingStandard.Operators.SpreadOperatorSpacing
SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking
SlevomatCodingStandard.PHP.ShortList
SlevomatCodingStandard.PHP.TypeCast
SlevomatCodingStandard.PHP.UselessSemicolon
SlevomatCodingStandard.TypeHints.DeclareStrictTypes
SlevomatCodingStandard.TypeHints.LongTypeHints
SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition
SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue
SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing
SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing
SlevomatCodingStandard.TypeHints.TypeHintDeclaration
SlevomatCodingStandard.TypeHints.UselessConstantTypeHint
SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable
SlevomatCodingStandard.Variables.UnusedVariable
SlevomatCodingStandard.Variables.UselessVariable
Squiz (40 sniffs)
-----------------
Squiz.Arrays.ArrayBracketSpacing
Squiz.Arrays.ArrayDeclaration
Squiz.Classes.ClassFileName
Squiz.Classes.LowercaseClassKeywords
Squiz.Classes.SelfMemberReference
Squiz.Classes.ValidClassName
Squiz.Commenting.DocCommentAlignment
Squiz.Commenting.FunctionComment
Squiz.Commenting.FunctionCommentThrowTag
Squiz.ControlStructures.ControlSignature
Squiz.ControlStructures.ForEachLoopDeclaration
Squiz.ControlStructures.ForLoopDeclaration
Squiz.ControlStructures.LowercaseDeclaration
Squiz.Functions.FunctionDeclaration
Squiz.Functions.FunctionDeclarationArgumentSpacing
Squiz.Functions.GlobalFunction
Squiz.Functions.LowercaseFunctionKeywords
Squiz.Functions.MultiLineFunctionDeclaration
Squiz.NamingConventions.ValidVariableName
Squiz.Operators.ValidLogicalOperators
Squiz.PHP.GlobalKeyword
Squiz.PHP.InnerFunctions
Squiz.PHP.LowercasePHPFunctions
Squiz.PHP.NonExecutableCode
Squiz.Scope.MethodScope
Squiz.Scope.StaticThisUsage
Squiz.Strings.ConcatenationSpacing
Squiz.Strings.DoubleQuoteUsage
Squiz.Strings.EchoedStrings
Squiz.WhiteSpace.CastSpacing
Squiz.WhiteSpace.ControlStructureSpacing
Squiz.WhiteSpace.FunctionOpeningBraceSpace
Squiz.WhiteSpace.FunctionSpacing
Squiz.WhiteSpace.LanguageConstructSpacing
Squiz.WhiteSpace.LogicalOperatorSpacing
Squiz.WhiteSpace.ObjectOperatorSpacing
Squiz.WhiteSpace.ScopeClosingBrace
Squiz.WhiteSpace.ScopeKeywordSpacing
Squiz.WhiteSpace.SemicolonSpacing
Squiz.WhiteSpace.SuperfluousWhitespace
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
Happy coding!
allysonsilva/php-coding-standard 适用场景与选型建议
allysonsilva/php-coding-standard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 10 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「style」 「standard」 「phpcs」 「sniffer」 「coding」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 allysonsilva/php-coding-standard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 allysonsilva/php-coding-standard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 allysonsilva/php-coding-standard 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Symfony bundle for using the CssToInlineStyles translator by tijsverkoyen
Fixing php code style
Adds the EDTF data type to Wikibase
The coding standard applying to all Youdot PHP projects, based on Doctrine set of PHPCS rules, with additional checks.
CodeSniffer ruleset for the ZettaCMS coding standard
Run all code formatting tools with one command: pretty
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-06