update PHP Coding Standards Fixer

update PHP Coding Standards Fixer
This commit is contained in:
KHOUBZA Younes
2021-05-09 13:05:54 +00:00
parent 64bac380d0
commit 0ad24a7655
181 changed files with 771 additions and 13286 deletions
-625
View File
@@ -1,625 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>
<!-- Import PSR-12 coding standard (base) -->
<rule ref="PSR12"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `[...]` -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<!-- But allow empty catch -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>
<!-- Force whitespace after `!` -->
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Require presence of constant visibility -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
<property name="fixable" value="true"/>
</properties>
</rule> -->
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
<!-- Forbid uses of multiple traits separated by comma -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
<property name="linesCountBeforeFirstUse" value="0"/>
<property name="linesCountBetweenUses" value="0"/>
</properties>
</rule>
<!-- Forbid dead code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
<element value="~^Created by .+\.\z~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.\z~i"/>
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
</property>
</properties>
</rule>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@var"/>
<element value="@ORM\"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Require comments with single line written as one-liners -->
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Forbid fancy yoda conditions -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require usage of null coalesce operator equal operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
<!-- Require usage of null coalesce operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
<!-- Forbid usage of conditions when a simple return can be used -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Require using Throwable instead of Exception -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Ensure Arrow Functions declaration format -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="1"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
</properties>
</rule>
<!-- Require closures not referencing $this be static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused variables passed to closures via `use` -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Require presence of declare(strict_types=1) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
</properties>
</rule> -->
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require newlines around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Forbid using absolute class name references -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Forbid spacing before the negative operator `-` -->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Require no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Forbid `list(...)` syntax -->
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
<!-- Forbid use of longhand cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Forbid useless parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require the `null` type hint to be in the last position of annotations -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require ? when default value is null -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid useless inherit doc comment -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid duplicated variables assignments -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Forbid class being in a file with different name -->
<rule ref="Squiz.Classes.ClassFileName"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Disable arrow alignment -->
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
</rule>
<!-- Force rules for function phpDoc -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Allow `@throws` without description -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- Does not work properly with PHP 7 / short-named types -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- Does not support collections, i.e. `string[]` -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<!-- Forces incorrect types -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- Breaks with compound return types, i.e. `string|null` -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Doc comment is not required for every method -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<!-- Do not require comments for `@param` -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Do not require `@param` for all parameters -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<!-- Do not require `@return` for void methods -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<!-- Doesn't respect inheritance -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- `@throws` lines can often be read as a sentence,
i.e. `@throws RuntimeException if the file could not be written.` -->
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
<!-- Doesn't work with self as typehint -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule> -->
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Require there be no space between increment/decrement operator and its operand -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR2 -> turning back on -->
<severity>5</severity>
</rule>
<!-- Checks that class/trait/interface members are in the correct order. -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks that there is a certain number of blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Requires new with parentheses. -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
</ruleset>
+39
View File
@@ -0,0 +1,39 @@
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
use Symplify\EasyCodingStandard\ValueObject\Option;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [
__DIR__ . '/src'
]);
$parameters->set(Option::SKIP, [
PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer::class,
PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer::class,
PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer::class,
PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer::class,
Symplify\CodingStandard\Fixer\Spacing\MethodChainingNewlineFixer::class,
]);
$containerConfigurator->import(SetList::ARRAY);
$containerConfigurator->import(SetList::CLEAN_CODE);
$containerConfigurator->import(SetList::COMMENTS);
$containerConfigurator->import(SetList::COMMON);
$containerConfigurator->import(SetList::CONTROL_STRUCTURES);
$containerConfigurator->import(SetList::DOCBLOCK);
$containerConfigurator->import(SetList::NAMESPACES);
$containerConfigurator->import(SetList::PSR_12);
$containerConfigurator->import(SetList::SPACES);
$containerConfigurator->import(SetList::STRICT);
$containerConfigurator->import(SetList::SYMPLIFY);
$services = $containerConfigurator->services();
$services->set(PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer::class)
->call('configure', [[
'syntax' => 'long',
]]);
};
-625
View File
@@ -1,625 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>
<!-- Import PSR-12 coding standard (base) -->
<rule ref="PSR12"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `[...]` -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<!-- But allow empty catch -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>
<!-- Force whitespace after `!` -->
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Require presence of constant visibility -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
<property name="fixable" value="true"/>
</properties>
</rule> -->
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
<!-- Forbid uses of multiple traits separated by comma -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
<property name="linesCountBeforeFirstUse" value="0"/>
<property name="linesCountBetweenUses" value="0"/>
</properties>
</rule>
<!-- Forbid dead code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
<element value="~^Created by .+\.\z~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.\z~i"/>
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
</property>
</properties>
</rule>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@var"/>
<element value="@ORM\"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Require comments with single line written as one-liners -->
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Forbid fancy yoda conditions -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require usage of null coalesce operator equal operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
<!-- Require usage of null coalesce operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
<!-- Forbid usage of conditions when a simple return can be used -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Require using Throwable instead of Exception -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Ensure Arrow Functions declaration format -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="1"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
</properties>
</rule>
<!-- Require closures not referencing $this be static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused variables passed to closures via `use` -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Require presence of declare(strict_types=1) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
</properties>
</rule> -->
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require newlines around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Forbid using absolute class name references -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Forbid spacing before the negative operator `-` -->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Require no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Forbid `list(...)` syntax -->
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
<!-- Forbid use of longhand cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Forbid useless parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require the `null` type hint to be in the last position of annotations -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require ? when default value is null -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid useless inherit doc comment -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid duplicated variables assignments -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Forbid class being in a file with different name -->
<rule ref="Squiz.Classes.ClassFileName"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Disable arrow alignment -->
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
</rule>
<!-- Force rules for function phpDoc -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Allow `@throws` without description -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- Does not work properly with PHP 7 / short-named types -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- Does not support collections, i.e. `string[]` -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<!-- Forces incorrect types -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- Breaks with compound return types, i.e. `string|null` -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Doc comment is not required for every method -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<!-- Do not require comments for `@param` -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Do not require `@param` for all parameters -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<!-- Do not require `@return` for void methods -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<!-- Doesn't respect inheritance -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- `@throws` lines can often be read as a sentence,
i.e. `@throws RuntimeException if the file could not be written.` -->
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
<!-- Doesn't work with self as typehint -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule> -->
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Require there be no space between increment/decrement operator and its operand -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR2 -> turning back on -->
<severity>5</severity>
</rule>
<!-- Checks that class/trait/interface members are in the correct order. -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks that there is a certain number of blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Requires new with parentheses. -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
</ruleset>
+2 -2
View File
@@ -2,8 +2,8 @@
namespace Flasher\Laravel\Config;
use Illuminate\Config\Repository;
use Flasher\Prime\Config\ConfigInterface;
use Illuminate\Config\Repository;
final class Config implements ConfigInterface
{
@@ -19,6 +19,6 @@ final class Config implements ConfigInterface
public function get($key, $default = null)
{
return $this->config->get('flasher'.$this->separator.$key, $default);
return $this->config->get('flasher' . $this->separator . $key, $default);
}
}
+1 -4
View File
@@ -6,11 +6,8 @@ use Illuminate\Support\Facades\Facade;
class Flasher extends Facade
{
/**
* @inheritdoc
*/
protected static function getFacadeAccessor()
{
return 'flasher';
}
}
}
+1 -13
View File
@@ -2,8 +2,8 @@
namespace Flasher\Laravel;
use Illuminate\Support\ServiceProvider;
use Flasher\Laravel\ServiceProvider\ServiceProviderManager;
use Illuminate\Support\ServiceProvider;
final class FlasherServiceProvider extends ServiceProvider
{
@@ -45,33 +45,21 @@ final class FlasherServiceProvider extends ServiceProvider
return $this->app;
}
/**
* {@inheritdoc}
*/
public function mergeConfigFrom($path, $key)
{
parent::mergeConfigFrom($path, $key);
}
/**
* {@inheritdoc}
*/
public function publishes(array $paths, $groups = null)
{
parent::publishes($paths, $groups);
}
/**
* {@inheritdoc}
*/
public function loadTranslationsFrom($path, $namespace)
{
parent::loadTranslationsFrom($path, $namespace);
}
/**
* {@inheritdoc}
*/
public function loadViewsFrom($path, $namespace)
{
parent::loadViewsFrom($path, $namespace);
+4 -14
View File
@@ -26,11 +26,6 @@ final class SessionMiddleware
*/
private $renderer;
/**
* @param ConfigInterface $config
* @param FlasherInterface $flasher
* @param ResponseManagerInterface $renderer
*/
public function __construct(ConfigInterface $config, FlasherInterface $flasher, ResponseManagerInterface $renderer)
{
$this->config = $config;
@@ -41,16 +36,11 @@ final class SessionMiddleware
/**
* Run the request filter.
*
* @param Request $request
* @param Closure $next
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
/**
* @var Response $response
*/
/** @var Response $response */
$response = $next($request);
if ($request->isXmlHttpRequest() || true !== $this->config->get('auto_create_from_session')) {
@@ -76,7 +66,7 @@ final class SessionMiddleware
$content = $response->getContent();
$htmlResponse = $this->renderer->render(array(), array(
'format' => 'html',
'format' => 'html',
'content' => $content,
));
@@ -85,7 +75,7 @@ final class SessionMiddleware
}
$pos = strripos($content, '</body>');
$content = substr($content, 0, $pos).$htmlResponse.substr($content, $pos);
$content = substr($content, 0, $pos) . $htmlResponse . substr($content, $pos);
$response->setContent($content);
return $response;
@@ -103,7 +93,7 @@ final class SessionMiddleware
$type = $aliases;
}
foreach ((array)$aliases as $alias) {
foreach ((array) $aliases as $alias) {
$mapping[$alias] = $type;
}
}
+3 -29
View File
@@ -24,11 +24,6 @@ final class FlasherModelObserver
*/
private $translator;
/**
* @param ConfigInterface $config
* @param FlasherInterface $flasher
* @param Translator $translator
*/
public function __construct(ConfigInterface $config, FlasherInterface $flasher, Translator $translator)
{
$this->config = $config;
@@ -38,10 +33,6 @@ final class FlasherModelObserver
/**
* Handle the Model "created" event.
*
* @param Model $model
*
* @return void
*/
public function created(Model $model)
{
@@ -50,10 +41,6 @@ final class FlasherModelObserver
/**
* Handle the Model "updated" event.
*
* @param Model $model
*
* @return void
*/
public function updated(Model $model)
{
@@ -62,10 +49,6 @@ final class FlasherModelObserver
/**
* Handle the Model "deleted" event.
*
* @param Model $model
*
* @return void
*/
public function deleted(Model $model)
{
@@ -74,10 +57,6 @@ final class FlasherModelObserver
/**
* Handle the Model "restored" event.
*
* @param Model $model
*
* @return void
*/
public function restored(Model $model)
{
@@ -86,10 +65,6 @@ final class FlasherModelObserver
/**
* Handle the Model "force deleted" event.
*
* @param Model $model
*
* @return void
*/
public function forceDeleted(Model $model)
{
@@ -98,16 +73,15 @@ final class FlasherModelObserver
/**
* @param string $method
* @param Model $model
*/
private function addFlash($method, Model $model)
{
$exludes = $this->config->get('observer_events.exclude', array());
if (in_array($method, $exludes)) {
if (in_array($method, $exludes, true)) {
return;
}
if (isset($exludes[$method]) && in_array(get_class($model), $exludes[$method])) {
if (isset($exludes[$method]) && in_array(get_class($model), $exludes[$method], true)) {
return;
}
@@ -115,7 +89,7 @@ final class FlasherModelObserver
$message = $this->translator->get(sprintf('flasher::messages.flashable.%s.%s', get_class($model), $method));
} else {
$message = $this->translator->get(sprintf('flasher::messages.flashable.default.%s', $method));
$message = str_replace('{{ model }}', substr(strrchr(get_class($model), "\\"), 1), $message);
$message = str_replace('{{ model }}', substr(strrchr(get_class($model), '\\'), 1), $message);
}
$this->flasher->addSuccess($message);
+6 -6
View File
@@ -4,7 +4,7 @@ return array(
'default' => 'template',
'root_scripts' => array(
'https://cdn.jsdelivr.net/npm/@flasher/flasher@0.1.3/dist/flasher.min.js'
'https://cdn.jsdelivr.net/npm/@flasher/flasher@0.1.3/dist/flasher.min.js',
),
'template_factory' => array(
@@ -14,12 +14,12 @@ return array(
'view' => 'flasher::tailwindcss',
'styles' => array(
'https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.1.1/base.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.1.1/utilities.css'
'https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.1.1/utilities.css',
),
),
'tailwindcss_bg' => array(
'view' => 'flasher::tailwindcss_bg',
"styles" => array(
'styles' => array(
'https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.1.1/base.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.1.1/utilities.css',
),
@@ -27,7 +27,7 @@ return array(
'bootstrap' => array(
'view' => 'flasher::bootstrap',
'styles' => array(
"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css",
'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css',
),
),
),
@@ -37,9 +37,9 @@ return array(
'types_mapping' => array(
'success' => array('success'),
'error' => array('error', 'danger'),
'error' => array('error', 'danger'),
'warning' => array('warning', 'alarm'),
'info' => array('info', 'notice', 'alert'),
'info' => array('info', 'notice', 'alert'),
),
'observer_events' => array(
+4 -4
View File
@@ -3,10 +3,10 @@
return array(
'flashable' => array(
'default' => array(
'created' => '{{ model }} has been created.',
'updated' => '{{ model }} has been updated.',
'deleted' => '{{ model }} has been deleted.',
'restored' => '{{ model }} has been restored.',
'created' => '{{ model }} has been created.',
'updated' => '{{ model }} has been updated.',
'deleted' => '{{ model }} has been deleted.',
'restored' => '{{ model }} has been restored.',
'forceDeleted' => '{{ model }} has been deleted.',
),
),
@@ -29,43 +29,37 @@ class Laravel implements ServiceProviderInterface
*/
protected $app;
/**
* @param Container $app
*/
public function __construct(Container $app)
{
$this->app = $app;
}
/**
* @inheritDoc
*/
public function shouldBeUsed()
{
return $this->app instanceof Application;
}
/**
* @inheritDoc
*/
public function boot(FlasherServiceProvider $provider)
{
$provider->loadTranslationsFrom(flasher_path(__DIR__.'/../../Resources/lang'), 'flasher');
$provider->loadViewsFrom(flasher_path(__DIR__.'/../../Resources/views'), 'flasher');
$provider->loadTranslationsFrom(flasher_path(__DIR__ . '/../../Resources/lang'), 'flasher');
$provider->loadViewsFrom(flasher_path(__DIR__ . '/../../Resources/views'), 'flasher');
$provider->publishes(array(flasher_path(__DIR__.'/../../Resources/config/config.php') => config_path('flasher.php')), 'flasher-config');
$provider->publishes(array(flasher_path(__DIR__.'/../../Resources/lang') => resource_path(flasher_path('lang/vendor/flasher'))), 'flasher-lang');
$provider->publishes(array(flasher_path(__DIR__.'/../../Resources/views') => resource_path(flasher_path('views/vendor/flasher'))), 'flasher-views');
$provider->publishes(array(
flasher_path(__DIR__ . '/../../Resources/config/config.php') => config_path('flasher.php'),
), 'flasher-config');
$provider->publishes(array(
flasher_path(__DIR__ . '/../../Resources/lang') => resource_path(flasher_path('lang/vendor/flasher')),
), 'flasher-lang');
$provider->publishes(array(
flasher_path(__DIR__ . '/../../Resources/views') => resource_path(flasher_path('views/vendor/flasher')),
), 'flasher-views');
$this->registerBladeDirectives();
}
/**
* @inheritDoc
*/
public function register(FlasherServiceProvider $provider)
{
$provider->mergeConfigFrom(flasher_path(__DIR__.'/../../Resources/config/config.php'), 'flasher');
$provider->mergeConfigFrom(flasher_path(__DIR__ . '/../../Resources/config/config.php'), 'flasher');
$this->app->singleton('flasher.config', function (Application $app) {
return new Config($app['config'], '.');
@@ -89,13 +83,13 @@ class Laravel implements ServiceProviderInterface
$templates = $app['flasher.config']->get('template_factory.templates', array());
foreach ($templates as $template => $factory) {
if (isset($factory['scripts'])) {
$resourceManager->addScripts('template_'.$template, $factory['scripts']);
$resourceManager->addScripts('template_' . $template, $factory['scripts']);
}
if (isset($factory['styles'])) {
$resourceManager->addStyles('template_'.$template, $factory['styles']);
$resourceManager->addStyles('template_' . $template, $factory['styles']);
}
if (isset($factory['options'])) {
$resourceManager->addOptions('template_'.$template, $factory['options']);
$resourceManager->addOptions('template_' . $template, $factory['options']);
}
}
@@ -103,7 +97,11 @@ class Laravel implements ServiceProviderInterface
});
$this->app->singleton('flasher.response_manager', function (Application $app) {
$responseManager = new ResponseManager($app['flasher.storage_manager'], $app['flasher.event_dispatcher'], $app['flasher.resource_manager']);
$responseManager = new ResponseManager(
$app['flasher.storage_manager'],
$app['flasher.event_dispatcher'],
$app['flasher.resource_manager']
);
$responseManager->addPresenter('html', new HtmlPresenter());
$responseManager->addPresenter('array', new ArrayPresenter());
@@ -152,7 +150,6 @@ class Laravel implements ServiceProviderInterface
$this->app->alias('flasher.notification_factory', 'Flasher\Prime\Factory\NotificationFactory');
$this->app->alias('Flasher\Prime\Factory\NotificationFactory', 'flasher.template');
$this->app->bind('Flasher\Prime\Config\ConfigInterface', 'flasher.config');
$this->app->bind('Flasher\Prime\FlasherInterface', 'flasher');
$this->app->bind('Flasher\Prime\Storage\StorageManagerInterface', 'flasher.storage_manager');
@@ -166,24 +163,24 @@ class Laravel implements ServiceProviderInterface
protected function registerBladeDirectives()
{
$startsWith = function($haystack, $needle) {
$startsWith = function ($haystack, $needle) {
return substr_compare($haystack, $needle, 0, strlen($needle)) === 0;
};
$endsWith = function($haystack, $needle) {
$endsWith = function ($haystack, $needle) {
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
};
Blade::directive('flasher_render', function ($criteria = array()) use($startsWith, $endsWith) {
if (!empty($criteria) && $startsWith($criteria, "(") && $endsWith($criteria, ")")) {
Blade::directive('flasher_render', function ($criteria = array()) use ($startsWith, $endsWith) {
if (!empty($criteria) && $startsWith($criteria, '(') && $endsWith($criteria, ')')) {
$criteria = substr($criteria, 1, -1);
}
if (empty($criteria)) {
$criteria = "array()";
$criteria = 'array()';
}
return "<?php echo app('flasher.response_manager')->render($criteria, 'html'); ?>";
return "<?php echo app('flasher.response_manager')->render(${criteria}, 'html'); ?>";
});
}
}
@@ -10,27 +10,18 @@ use Illuminate\View\Compilers\BladeCompiler;
final class Laravel4 extends Laravel
{
/**
* @inheritDoc
*/
public function shouldBeUsed()
{
return $this->app instanceof Application && 0 === strpos(Application::VERSION, '4.');
}
/**
* @inheritDoc
*/
public function boot(FlasherServiceProvider $provider)
{
$provider->package('php-flasher/flasher-laravel', 'flasher', flasher_path(__DIR__.'/../../Resources'));
$provider->package('php-flasher/flasher-laravel', 'flasher', flasher_path(__DIR__ . '/../../Resources'));
$this->registerBladeDirectives();
}
/**
* @inheritDoc
*/
public function register(FlasherServiceProvider $provider)
{
$this->app->singleton('flasher.config', function (Application $app) {
@@ -9,31 +9,27 @@ use Illuminate\View\Compilers\BladeCompiler;
final class Laravel50 extends Laravel
{
/**
* @inheritDoc
*/
public function shouldBeUsed()
{
return $this->app instanceof Application && 0 === strpos(Application::VERSION, '5.0');
}
/**
* @inheritDoc
*/
public function boot(FlasherServiceProvider $provider)
{
$provider->publishes(array(flasher_path(__DIR__.'/../../Resources/lang') => base_path(flasher_path('resources/lang/vendor/flasher'))));
$provider->publishes(array(
flasher_path(__DIR__ . '/../../Resources/lang') => base_path(flasher_path('resources/lang/vendor/flasher')),
));
$this->registerBladeDirectives();
}
protected function registerBladeDirectives()
{
$startsWith = function($haystack, $needle) {
$startsWith = function ($haystack, $needle) {
return substr_compare($haystack, $needle, 0, strlen($needle)) === 0;
};
$endsWith = function($haystack, $needle) {
$endsWith = function ($haystack, $needle) {
return substr_compare($haystack, $needle, -strlen($needle)) === 0;
};
@@ -45,15 +41,19 @@ final class Laravel50 extends Laravel
$value = $matches[2];
if (!empty($value) && $startsWith($value, "(") && $endsWith($value, ")")) {
if (!empty($value) && $startsWith($value, '(') && $endsWith($value, ')')) {
$value = substr($value, 1, -1);
}
if (empty($value)) {
$value = "array()";
$value = 'array()';
}
return str_replace("%criteria%", $value, $matches[1] . "<?php echo app('flasher.response_manager')->render(%criteria%, 'html'); ?>");
return str_replace(
'%criteria%',
$value,
$matches[1] . "<?php echo app('flasher.response_manager')->render(%criteria%, 'html'); ?>"
);
});
}
}
@@ -7,20 +7,16 @@ use Illuminate\Foundation\Application;
final class Laravel51 extends Laravel
{
/**
* @inheritDoc
*/
public function shouldBeUsed()
{
return $this->app instanceof Application && 0 === strpos(Application::VERSION, '5.1');
}
/**
* @inheritDoc
*/
public function boot(FlasherServiceProvider $provider)
{
$provider->publishes(array(flasher_path(__DIR__.'/../../Resources/lang') => base_path(flasher_path('resources/lang/vendor/flasher'))));
$provider->publishes(array(
flasher_path(__DIR__ . '/../../Resources/lang') => base_path(flasher_path('resources/lang/vendor/flasher')),
));
$this->registerBladeDirectives();
}
@@ -11,13 +11,7 @@ interface ServiceProviderInterface
*/
public function shouldBeUsed();
/**
* @param FlasherServiceProvider $provider
*/
public function boot(FlasherServiceProvider $provider);
/**
* @param FlasherServiceProvider $provider
*/
public function register(FlasherServiceProvider $provider);
}
@@ -9,7 +9,6 @@ final class ResourceManagerHelper
/**
* @param string $alias
* @param array $config
* @param ResourceManager $responseManager
*/
public static function process(ResourceManager $responseManager, $alias, $config = null)
{
@@ -51,4 +50,4 @@ final class ResourceManagerHelper
{
return isset($config['options']) ? $config['options'] : array();
}
}
}
-15
View File
@@ -25,17 +25,11 @@ final class Storage implements StorageInterface
$this->session = $session;
}
/**
* @inheritDoc
*/
public function all()
{
return $this->session->get(self::ENVELOPES_NAMESPACE, array());
}
/**
* @inheritDoc
*/
public function add($envelopes)
{
$envelopes = is_array($envelopes) ? $envelopes : func_get_args();
@@ -43,9 +37,6 @@ final class Storage implements StorageInterface
$this->session->put(self::ENVELOPES_NAMESPACE, array_merge($this->all(), $envelopes));
}
/**
* @inheritDoc
*/
public function update($envelopes)
{
$envelopes = is_array($envelopes) ? $envelopes : func_get_args();
@@ -65,9 +56,6 @@ final class Storage implements StorageInterface
$this->session->put(self::ENVELOPES_NAMESPACE, $store);
}
/**
* @inheritDoc
*/
public function remove($envelopes)
{
$envelopes = is_array($envelopes) ? $envelopes : func_get_args();
@@ -83,9 +71,6 @@ final class Storage implements StorageInterface
$this->session->put(self::ENVELOPES_NAMESPACE, $store);
}
/**
* @inheritDoc
*/
public function clear()
{
$this->session->put(self::ENVELOPES_NAMESPACE, array());
-3
View File
@@ -19,9 +19,6 @@ final class BladeEngine implements EngineInterface
$this->engine = $engine;
}
/**
* @inheritDoc
*/
public function render($name, array $context = array())
{
return (string) $this->engine->make($name, $context);
+1 -1
View File
@@ -13,7 +13,7 @@ final class ConfigTest extends TestCase
$separator = $this->isLaravel4() ? '::' : '.';
$config = new Config($this->app->make('config'), $separator);
$this->assertEquals('template', $config->get('default'));
$this->assertSame('template', $config->get('default'));
}
private function isLaravel4()
@@ -11,10 +11,16 @@ final class FlasherServiceProviderTest extends TestCase
$this->assertInstanceOf('Flasher\Laravel\Config\Config', $this->app->make('flasher.config'));
$this->assertInstanceOf('Flasher\Prime\Flasher', $this->app->make('flasher'));
$this->assertInstanceOf('Flasher\Prime\Response\ResponseManager', $this->app->make('flasher.response_manager'));
$this->assertInstanceOf('Flasher\Prime\Response\Resource\ResourceManager', $this->app->make('flasher.resource_manager'));
$this->assertInstanceOf(
'Flasher\Prime\Response\Resource\ResourceManager',
$this->app->make('flasher.resource_manager')
);
$this->assertInstanceOf('Flasher\Laravel\Storage\Storage', $this->app->make('flasher.storage'));
$this->assertInstanceOf('Flasher\Prime\Storage\StorageManager', $this->app->make('flasher.storage_manager'));
$this->assertInstanceOf('Flasher\Prime\EventDispatcher\EventDispatcher', $this->app->make('flasher.event_dispatcher'));
$this->assertInstanceOf(
'Flasher\Prime\EventDispatcher\EventDispatcher',
$this->app->make('flasher.event_dispatcher')
);
$this->assertInstanceOf('Flasher\Prime\Filter\Filter', $this->app->make('flasher.filter'));
}
@@ -23,9 +29,21 @@ final class FlasherServiceProviderTest extends TestCase
/** @var BladeCompiler $blade */
$blade = $this->app->make('view')->getEngineResolver()->resolve('blade')->getCompiler();
$this->assertEquals("<?php echo app('flasher.response_manager')->render(array(), 'html'); ?>", $blade->compileString('@flasher_render'));
$this->assertEquals("<?php echo app('flasher.response_manager')->render(array(), 'html'); ?>", $blade->compileString('@flasher_render()'));
$this->assertEquals("<?php echo app('flasher.response_manager')->render(array(), 'html'); ?>", $blade->compileString('@flasher_render(array())'));
$this->assertEquals("<?php echo app('flasher.response_manager')->render(array(\"priority\" => array(\"min\" => 4, \"max\" => 5)), 'html'); ?>", $blade->compileString('@flasher_render(array("priority" => array("min" => 4, "max" => 5)))'));
$this->assertSame(
"<?php echo app('flasher.response_manager')->render(array(), 'html'); ?>",
$blade->compileString('@flasher_render')
);
$this->assertSame(
"<?php echo app('flasher.response_manager')->render(array(), 'html'); ?>",
$blade->compileString('@flasher_render()')
);
$this->assertSame(
"<?php echo app('flasher.response_manager')->render(array(), 'html'); ?>",
$blade->compileString('@flasher_render(array())')
);
$this->assertSame(
"<?php echo app('flasher.response_manager')->render(array(\"priority\" => array(\"min\" => 4, \"max\" => 5)), 'html'); ?>",
$blade->compileString('@flasher_render(array("priority" => array("min" => 4, "max" => 5)))')
);
}
}
+4 -2
View File
@@ -57,8 +57,10 @@ final class StorageTest extends TestCase
$storage->update($envelopes[1]);
$this->assertSame($envelopes, $storage->all());
$this->assertInstanceOf('Flasher\Prime\Stamp\PriorityStamp',
$envelopes[1]->get('Flasher\Prime\Stamp\PriorityStamp'));
$this->assertInstanceOf(
'Flasher\Prime\Stamp\PriorityStamp',
$envelopes[1]->get('Flasher\Prime\Stamp\PriorityStamp')
);
}
public function testRemoveEnvelopes()
+1 -3
View File
@@ -5,14 +5,12 @@ if (!function_exists('flasher')) {
* @param string $message
* @param string $type
* @param string $title
* @param array $options
* @param array $stamps
*
* @return \Flasher\Prime\Flasher
*/
function flasher($message = null, $type = 'success', $title = '', array $options = array(), array $stamps = array())
{
if (is_null($message) && 0 === func_num_args()) {
if (null === $message && 0 === func_num_args()) {
return app('flasher.factory');
}
-625
View File
@@ -1,625 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>
<!-- Import PSR-12 coding standard (base) -->
<rule ref="PSR12"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `[...]` -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<!-- But allow empty catch -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>
<!-- Force whitespace after `!` -->
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Require presence of constant visibility -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
<property name="fixable" value="true"/>
</properties>
</rule> -->
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
<!-- Forbid uses of multiple traits separated by comma -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
<property name="linesCountBeforeFirstUse" value="0"/>
<property name="linesCountBetweenUses" value="0"/>
</properties>
</rule>
<!-- Forbid dead code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
<element value="~^Created by .+\.\z~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.\z~i"/>
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
</property>
</properties>
</rule>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@var"/>
<element value="@ORM\"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Require comments with single line written as one-liners -->
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Forbid fancy yoda conditions -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require usage of null coalesce operator equal operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
<!-- Require usage of null coalesce operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
<!-- Forbid usage of conditions when a simple return can be used -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Require using Throwable instead of Exception -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Ensure Arrow Functions declaration format -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="1"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
</properties>
</rule>
<!-- Require closures not referencing $this be static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused variables passed to closures via `use` -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Require presence of declare(strict_types=1) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
</properties>
</rule> -->
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require newlines around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Forbid using absolute class name references -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Forbid spacing before the negative operator `-` -->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Require no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Forbid `list(...)` syntax -->
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
<!-- Forbid use of longhand cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Forbid useless parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require the `null` type hint to be in the last position of annotations -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require ? when default value is null -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid useless inherit doc comment -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid duplicated variables assignments -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Forbid class being in a file with different name -->
<rule ref="Squiz.Classes.ClassFileName"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Disable arrow alignment -->
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
</rule>
<!-- Force rules for function phpDoc -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Allow `@throws` without description -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- Does not work properly with PHP 7 / short-named types -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- Does not support collections, i.e. `string[]` -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<!-- Forces incorrect types -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- Breaks with compound return types, i.e. `string|null` -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Doc comment is not required for every method -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<!-- Do not require comments for `@param` -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Do not require `@param` for all parameters -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<!-- Do not require `@return` for void methods -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<!-- Doesn't respect inheritance -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- `@throws` lines can often be read as a sentence,
i.e. `@throws RuntimeException if the file could not be written.` -->
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
<!-- Doesn't work with self as typehint -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule> -->
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Require there be no space between increment/decrement operator and its operand -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR2 -> turning back on -->
<severity>5</severity>
</rule>
<!-- Checks that class/trait/interface members are in the correct order. -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks that there is a certain number of blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Requires new with parentheses. -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
</ruleset>
+1 -4
View File
@@ -6,11 +6,8 @@ use Illuminate\Support\Facades\Facade;
class Noty extends Facade
{
/**
* @inheritdoc
*/
protected static function getFacadeAccessor()
{
return 'flasher.noty';
}
}
}
@@ -2,9 +2,9 @@
namespace Flasher\Noty\Laravel;
use Flasher\Noty\Laravel\ServiceProvider\ServiceProviderManager;
use Illuminate\Container\Container;
use Illuminate\Support\ServiceProvider;
use Flasher\Noty\Laravel\ServiceProvider\ServiceProviderManager;
final class FlasherNotyServiceProvider extends ServiceProvider
{
@@ -43,17 +43,11 @@ final class FlasherNotyServiceProvider extends ServiceProvider
return $this->app;
}
/**
* {@inheritdoc}
*/
public function mergeConfigFrom($path, $key)
{
parent::mergeConfigFrom($path, $key);
}
/**
* {@inheritdoc}
*/
public function publishes(array $paths, $groups = null)
{
parent::publishes($paths, $groups);
+1 -1
View File
@@ -4,7 +4,7 @@ return array(
'scripts' => array(
'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@0.1.3/dist/flasher-noty.min.js',
),
'styles' => array(),
'styles' => array(),
'options' => array(
'timeout' => 5000,
),
@@ -3,11 +3,10 @@
use Flasher\Prime\Notification\NotificationInterface;
use Illuminate\Support\Facades\App;
if (! function_exists('noty')) {
if (!function_exists('noty')) {
/**
* @param string $message
* @param string $type
* @param array $options
*
* @return \Flasher\Noty\Prime\NotyFactory
*/
@@ -19,4 +18,4 @@ if (! function_exists('noty')) {
return App::make('flasher.noty')->addFlash($type, $message, $options);
}
}
}
@@ -3,9 +3,9 @@
namespace Flasher\Noty\Laravel\ServiceProvider\Providers;
use Flasher\Laravel\ServiceProvider\ResourceManagerHelper;
use Flasher\Prime\Flasher;
use Flasher\Noty\Laravel\FlasherNotyServiceProvider;
use Flasher\Noty\Prime\NotyFactory;
use Flasher\Prime\Flasher;
use Flasher\Prime\Response\Resource\ResourceManager;
use Illuminate\Container\Container;
use Illuminate\Foundation\Application;
@@ -17,36 +17,26 @@ class Laravel implements ServiceProviderInterface
*/
protected $app;
/**
* @param Container $app
*/
public function __construct(Container $app)
{
$this->app = $app;
}
/**
* @inheritDoc
*/
public function shouldBeUsed()
{
return $this->app instanceof Application;
}
/**
* @inheritDoc
*/
public function boot(FlasherNotyServiceProvider $provider)
{
$provider->publishes(array(flasher_path(__DIR__.'/../../Resources/config/config.php') => config_path('flasher_noty.php')), 'flasher-config');
$provider->publishes(array(
flasher_path(__DIR__ . '/../../Resources/config/config.php') => config_path('flasher_noty.php'),
), 'flasher-config');
}
/**
* @inheritDoc
*/
public function register(FlasherNotyServiceProvider $provider)
{
$provider->mergeConfigFrom(flasher_path(__DIR__.'/../../Resources/config/config.php'), 'flasher_noty');
$provider->mergeConfigFrom(flasher_path(__DIR__ . '/../../Resources/config/config.php'), 'flasher_noty');
$this->appendToFlasherConfig();
$this->registerServices();
@@ -7,26 +7,21 @@ use Illuminate\Foundation\Application;
final class Laravel4 extends Laravel
{
/**
* @inheritDoc
*/
public function shouldBeUsed()
{
return $this->app instanceof Application && 0 === strpos(Application::VERSION, '4.');
}
/**
* @inheritDoc
*/
public function boot(FlasherNotyServiceProvider $provider)
{
$provider->package('php-flasher/flasher-noty-laravel', 'flasher_noty', flasher_path(__DIR__.'/../../Resources'));
$provider->package(
'php-flasher/flasher-noty-laravel',
'flasher_noty',
flasher_path(__DIR__ . '/../../Resources')
);
$this->appendToFlasherConfig();
}
/**
* @inheritDoc
*/
public function register(FlasherNotyServiceProvider $provider)
{
$this->registerServices();
@@ -11,13 +11,7 @@ interface ServiceProviderInterface
*/
public function shouldBeUsed();
/**
* @param FlasherNotyServiceProvider $provider
*/
public function boot(FlasherNotyServiceProvider $provider);
/**
* @param FlasherNotyServiceProvider $provider
*/
public function register(FlasherNotyServiceProvider $provider);
}
+47 -51
View File
@@ -11,6 +11,52 @@ use Orchestra\Testbench\TestCase as Orchestra;
class TestCase extends Orchestra
{
public function createApplication()
{
if (0 !== strpos(Application::VERSION, '4.0')) {
return parent::createApplication();
}
$app = new Application();
$app->detectEnvironment(array(
'local' => array('your-machine-name'),
));
$app->bindInstallPaths($this->getApplicationPaths());
$app['env'] = 'testing';
$app->instance('app', $app);
Facade::clearResolvedInstances();
Facade::setFacadeApplication($app);
$config = new Config($app->getConfigLoader(), $app['env']);
$app->instance('config', $config);
$app->startExceptionHandling();
if ($app->runningInConsole()) {
$app->setRequestForConsoleEnvironment();
}
date_default_timezone_set($this->getApplicationTimezone());
$aliases = array_merge($this->getApplicationAliases(), $this->getPackageAliases());
AliasLoader::getInstance($aliases)->register();
Request::enableHttpMethodParameterOverride();
$providers = array_merge($this->getApplicationProviders(), $this->getPackageProviders());
$app->getProviderRepository()->load($app, $providers);
$this->getEnvironmentSetUp($app);
$app->boot();
return $app;
}
/**
* @param Application $app
*
@@ -31,61 +77,11 @@ class TestCase extends Orchestra
{
$separator = $this->isLaravel4() ? '::config' : '';
$app['config']->set('session'.$separator.'.driver', 'array');
$app['config']->set('session' . $separator . '.driver', 'array');
}
private function isLaravel4()
{
return 0 === strpos(Application::VERSION, '4.');
}
/**
* {@inheritdoc}
*/
public function createApplication()
{
if (0 !== strpos(Application::VERSION, '4.0')) {
return parent::createApplication();
}
$app = new Application;
$app->detectEnvironment(array(
'local' => array('your-machine-name'),
));
$app->bindInstallPaths($this->getApplicationPaths());
$app['env'] = 'testing';
$app->instance('app', $app);
Facade::clearResolvedInstances();
Facade::setFacadeApplication($app);
$config = new Config($app->getConfigLoader(), $app['env']);
$app->instance('config', $config);
$app->startExceptionHandling();
if ($app->runningInConsole())
{
$app->setRequestForConsoleEnvironment();
}
date_default_timezone_set($this->getApplicationTimezone());
$aliases = array_merge($this->getApplicationAliases(), $this->getPackageAliases());
AliasLoader::getInstance($aliases)->register();
Request::enableHttpMethodParameterOverride();
$providers = array_merge($this->getApplicationProviders(), $this->getPackageProviders());
$app->getProviderRepository()->load($app, $providers);
$this->getEnvironmentSetUp($app);
$app->boot();
return $app;
}
}
-625
View File
@@ -1,625 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>
<!-- Import PSR-12 coding standard (base) -->
<rule ref="PSR12"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `[...]` -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<!-- But allow empty catch -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>
<!-- Force whitespace after `!` -->
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Require presence of constant visibility -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
<property name="fixable" value="true"/>
</properties>
</rule> -->
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
<!-- Forbid uses of multiple traits separated by comma -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
<property name="linesCountBeforeFirstUse" value="0"/>
<property name="linesCountBetweenUses" value="0"/>
</properties>
</rule>
<!-- Forbid dead code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
<element value="~^Created by .+\.\z~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.\z~i"/>
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
</property>
</properties>
</rule>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@var"/>
<element value="@ORM\"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Require comments with single line written as one-liners -->
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Forbid fancy yoda conditions -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require usage of null coalesce operator equal operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
<!-- Require usage of null coalesce operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
<!-- Forbid usage of conditions when a simple return can be used -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Require using Throwable instead of Exception -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Ensure Arrow Functions declaration format -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="1"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
</properties>
</rule>
<!-- Require closures not referencing $this be static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused variables passed to closures via `use` -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Require presence of declare(strict_types=1) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
</properties>
</rule> -->
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require newlines around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Forbid using absolute class name references -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Forbid spacing before the negative operator `-` -->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Require no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Forbid `list(...)` syntax -->
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
<!-- Forbid use of longhand cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Forbid useless parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require the `null` type hint to be in the last position of annotations -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require ? when default value is null -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid useless inherit doc comment -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid duplicated variables assignments -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Forbid class being in a file with different name -->
<rule ref="Squiz.Classes.ClassFileName"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Disable arrow alignment -->
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
</rule>
<!-- Force rules for function phpDoc -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Allow `@throws` without description -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- Does not work properly with PHP 7 / short-named types -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- Does not support collections, i.e. `string[]` -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<!-- Forces incorrect types -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- Breaks with compound return types, i.e. `string|null` -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Doc comment is not required for every method -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<!-- Do not require comments for `@param` -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Do not require `@param` for all parameters -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<!-- Do not require `@return` for void methods -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<!-- Doesn't respect inheritance -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- `@throws` lines can often be read as a sentence,
i.e. `@throws RuntimeException if the file could not be written.` -->
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
<!-- Doesn't work with self as typehint -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule> -->
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Require there be no space between increment/decrement operator and its operand -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR2 -> turning back on -->
<severity>5</severity>
</rule>
<!-- Checks that class/trait/interface members are in the correct order. -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks that there is a certain number of blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Requires new with parentheses. -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
</ruleset>
+7 -7
View File
@@ -20,7 +20,6 @@ final class NotyBuilder extends NotificationBuilder
/**
* @param string $message
* @param array $options
*
* @return NotyBuilder
*/
@@ -30,8 +29,8 @@ final class NotyBuilder extends NotificationBuilder
}
/**
* top, topLeft, topCenter, topRight, center, centerLeft, centerRight, bottom, bottomLeft, bottomCenter,
* bottomRight - ClassName generator uses this value → noty_layout__${layout}
* top, topLeft, topCenter, topRight, center, centerLeft, centerRight, bottom, bottomLeft, bottomCenter, bottomRight
* - ClassName generator uses this value → noty_layout__${layout}
*
* @param string $layout
*
@@ -111,7 +110,7 @@ final class NotyBuilder extends NotificationBuilder
*/
public function animation($animation, $effect)
{
$this->option('animation.'.$animation, $effect);
$this->option('animation.' . $animation, $effect);
return $this;
}
@@ -124,7 +123,7 @@ final class NotyBuilder extends NotificationBuilder
*/
public function sounds($option, $value)
{
$this->option('sounds.'.$option, $value);
$this->option('sounds.' . $option, $value);
return $this;
}
@@ -137,7 +136,7 @@ final class NotyBuilder extends NotificationBuilder
*/
public function docTitle($option, $docTitle)
{
$this->option('docTitle'.$option, $docTitle);
$this->option('docTitle' . $option, $docTitle);
return $this;
}
@@ -195,7 +194,8 @@ final class NotyBuilder extends NotificationBuilder
}
/**
* If true closes all visible notifications and shows itself. If string(queueName) closes all visible notification on this queue and shows itself.
* If true closes all visible notifications and shows itself. If string(queueName) closes all visible notification
* on this queue and shows itself.
*
* @param string|bool $killer
*
-3
View File
@@ -9,9 +9,6 @@ use Flasher\Prime\Factory\NotificationFactory;
*/
final class NotyFactory extends NotificationFactory
{
/**
* @inheritDoc
*/
public function createNotificationBuilder()
{
return new NotyBuilder($this->getStorageManager(), new Noty(), 'noty');
-625
View File
@@ -1,625 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>
<!-- Import PSR-12 coding standard (base) -->
<rule ref="PSR12"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `[...]` -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<!-- But allow empty catch -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>
<!-- Force whitespace after `!` -->
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Require presence of constant visibility -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
<property name="fixable" value="true"/>
</properties>
</rule> -->
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
<!-- Forbid uses of multiple traits separated by comma -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
<property name="linesCountBeforeFirstUse" value="0"/>
<property name="linesCountBetweenUses" value="0"/>
</properties>
</rule>
<!-- Forbid dead code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
<element value="~^Created by .+\.\z~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.\z~i"/>
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
</property>
</properties>
</rule>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@var"/>
<element value="@ORM\"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Require comments with single line written as one-liners -->
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Forbid fancy yoda conditions -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require usage of null coalesce operator equal operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
<!-- Require usage of null coalesce operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
<!-- Forbid usage of conditions when a simple return can be used -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Require using Throwable instead of Exception -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Ensure Arrow Functions declaration format -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="1"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
</properties>
</rule>
<!-- Require closures not referencing $this be static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused variables passed to closures via `use` -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Require presence of declare(strict_types=1) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
</properties>
</rule> -->
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require newlines around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Forbid using absolute class name references -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Forbid spacing before the negative operator `-` -->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Require no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Forbid `list(...)` syntax -->
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
<!-- Forbid use of longhand cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Forbid useless parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require the `null` type hint to be in the last position of annotations -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require ? when default value is null -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid useless inherit doc comment -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid duplicated variables assignments -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Forbid class being in a file with different name -->
<rule ref="Squiz.Classes.ClassFileName"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Disable arrow alignment -->
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
</rule>
<!-- Force rules for function phpDoc -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Allow `@throws` without description -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- Does not work properly with PHP 7 / short-named types -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- Does not support collections, i.e. `string[]` -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<!-- Forces incorrect types -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- Breaks with compound return types, i.e. `string|null` -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Doc comment is not required for every method -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<!-- Do not require comments for `@param` -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Do not require `@param` for all parameters -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<!-- Do not require `@return` for void methods -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<!-- Doesn't respect inheritance -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- `@throws` lines can often be read as a sentence,
i.e. `@throws RuntimeException if the file could not be written.` -->
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
<!-- Doesn't work with self as typehint -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule> -->
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Require there be no space between increment/decrement operator and its operand -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR2 -> turning back on -->
<severity>5</severity>
</rule>
<!-- Checks that class/trait/interface members are in the correct order. -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks that there is a certain number of blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Requires new with parentheses. -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
</ruleset>
@@ -7,9 +7,6 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
final class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('flasher_noty');
@@ -26,7 +23,7 @@ final class Configuration implements ConfigurationInterface
->arrayNode('scripts')
->prototype('scalar')->end()
->defaultValue(array(
'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@0.1.3/dist/flasher-noty.min.js',
'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@0.1.3/dist/flasher-noty.min.js',
))
->end()
->arrayNode('styles')
@@ -37,7 +34,7 @@ final class Configuration implements ConfigurationInterface
->prototype('variable')->end()
->ignoreExtraKeys(false)
->defaultValue(array(
'timeout' => 5000,
'timeout' => 5000,
))
->end()
->end()
@@ -7,17 +7,11 @@ use Symfony\Component\Config\FileLocator;
final class FlasherNotyExtension extends Extension
{
/**
* @inheritDoc
*/
protected function getConfigFileLocator()
{
return new FileLocator(__DIR__.'/../Resources/config');
return new FileLocator(__DIR__ . '/../Resources/config');
}
/**
* @inheritDoc
*/
protected function getConfigClass()
{
return new Configuration();
@@ -16,7 +16,7 @@ class ConfigurationTest extends TestCase
'scripts' => array(
'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@0.1.3/dist/flasher-noty.min.js',
),
'styles' => array(),
'styles' => array(),
'options' => array(
'timeout' => 5000,
),
@@ -2,11 +2,11 @@
namespace Flasher\Noty\Symfony\Tests\DependencyInjection;
use Flasher\Noty\Symfony\DependencyInjection\FlasherNotyExtension;
use Flasher\Noty\Symfony\FlasherNotySymfonyBundle;
use Flasher\Prime\Tests\TestCase;
use Flasher\Symfony\DependencyInjection\FlasherExtension;
use Flasher\Symfony\FlasherSymfonyBundle;
use Flasher\Noty\Symfony\DependencyInjection\FlasherNotyExtension;
use Flasher\Noty\Symfony\FlasherNotySymfonyBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class FlasherNotyExtensionTest extends TestCase
-625
View File
@@ -1,625 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>
<!-- Import PSR-12 coding standard (base) -->
<rule ref="PSR12"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `[...]` -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<!-- But allow empty catch -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>
<!-- Force whitespace after `!` -->
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Require presence of constant visibility -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
<property name="fixable" value="true"/>
</properties>
</rule> -->
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
<!-- Forbid uses of multiple traits separated by comma -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
<property name="linesCountBeforeFirstUse" value="0"/>
<property name="linesCountBetweenUses" value="0"/>
</properties>
</rule>
<!-- Forbid dead code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
<element value="~^Created by .+\.\z~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.\z~i"/>
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
</property>
</properties>
</rule>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@var"/>
<element value="@ORM\"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Require comments with single line written as one-liners -->
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Forbid fancy yoda conditions -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require usage of null coalesce operator equal operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
<!-- Require usage of null coalesce operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
<!-- Forbid usage of conditions when a simple return can be used -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Require using Throwable instead of Exception -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Ensure Arrow Functions declaration format -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="1"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
</properties>
</rule>
<!-- Require closures not referencing $this be static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused variables passed to closures via `use` -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Require presence of declare(strict_types=1) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
</properties>
</rule> -->
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require newlines around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Forbid using absolute class name references -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Forbid spacing before the negative operator `-` -->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Require no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Forbid `list(...)` syntax -->
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
<!-- Forbid use of longhand cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Forbid useless parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require the `null` type hint to be in the last position of annotations -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require ? when default value is null -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid useless inherit doc comment -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid duplicated variables assignments -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Forbid class being in a file with different name -->
<rule ref="Squiz.Classes.ClassFileName"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Disable arrow alignment -->
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
</rule>
<!-- Force rules for function phpDoc -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Allow `@throws` without description -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- Does not work properly with PHP 7 / short-named types -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- Does not support collections, i.e. `string[]` -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<!-- Forces incorrect types -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- Breaks with compound return types, i.e. `string|null` -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Doc comment is not required for every method -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<!-- Do not require comments for `@param` -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Do not require `@param` for all parameters -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<!-- Do not require `@return` for void methods -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<!-- Doesn't respect inheritance -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- `@throws` lines can often be read as a sentence,
i.e. `@throws RuntimeException if the file could not be written.` -->
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
<!-- Doesn't work with self as typehint -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule> -->
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Require there be no space between increment/decrement operator and its operand -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR2 -> turning back on -->
<severity>5</severity>
</rule>
<!-- Checks that class/trait/interface members are in the correct order. -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks that there is a certain number of blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Requires new with parentheses. -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
</ruleset>
+1 -4
View File
@@ -6,11 +6,8 @@ use Illuminate\Support\Facades\Facade;
class Notyf extends Facade
{
/**
* @inheritdoc
*/
protected static function getFacadeAccessor()
{
return 'flasher.notyf';
}
}
}
@@ -2,9 +2,9 @@
namespace Flasher\Notyf\Laravel;
use Flasher\Notyf\Laravel\ServiceProvider\ServiceProviderManager;
use Illuminate\Container\Container;
use Illuminate\Support\ServiceProvider;
use Flasher\Notyf\Laravel\ServiceProvider\ServiceProviderManager;
class FlasherNotyfServiceProvider extends ServiceProvider
{
@@ -43,17 +43,11 @@ class FlasherNotyfServiceProvider extends ServiceProvider
return $this->app;
}
/**
* {@inheritdoc}
*/
public function mergeConfigFrom($path, $key)
{
parent::mergeConfigFrom($path, $key);
}
/**
* {@inheritdoc}
*/
public function publishes(array $paths, $groups = null)
{
parent::publishes($paths, $groups);
@@ -3,11 +3,10 @@
use Flasher\Prime\Notification\NotificationInterface;
use Illuminate\Support\Facades\App;
if (! function_exists('notyf')) {
if (!function_exists('notyf')) {
/**
* @param string $message
* @param string $type
* @param array $options
*
* @return \Flasher\Notyf\Prime\NotyfFactory
*/
@@ -19,4 +18,4 @@ if (! function_exists('notyf')) {
return App::make('flasher.notyf')->addFlash($type, $message, $options);
}
}
}
@@ -17,36 +17,26 @@ class Laravel implements ServiceProviderInterface
*/
protected $app;
/**
* @param Container $app
*/
public function __construct(Container $app)
{
$this->app = $app;
}
/**
* @inheritDoc
*/
public function shouldBeUsed()
{
return $this->app instanceof Application;
}
/**
* @inheritDoc
*/
public function boot(FlasherNotyfServiceProvider $provider)
{
$provider->publishes(array(flasher_path(__DIR__.'/../../Resources/config/config.php') => config_path('flasher_notyf.php')), 'flasher-config');
$provider->publishes(array(
flasher_path(__DIR__ . '/../../Resources/config/config.php') => config_path('flasher_notyf.php'),
), 'flasher-config');
}
/**
* @inheritDoc
*/
public function register(FlasherNotyfServiceProvider $provider)
{
$provider->mergeConfigFrom(flasher_path(__DIR__.'/../../Resources/config/config.php'), 'flasher_notyf');
$provider->mergeConfigFrom(flasher_path(__DIR__ . '/../../Resources/config/config.php'), 'flasher_notyf');
$this->appendToFlasherConfig();
$this->registerServices();
@@ -7,27 +7,22 @@ use Illuminate\Foundation\Application;
final class Laravel4 extends Laravel
{
/**
* @inheritDoc
*/
public function shouldBeUsed()
{
return $this->app instanceof Application && 0 === strpos(Application::VERSION, '4.');
}
/**
* @inheritDoc
*/
public function boot(FlasherNotyfServiceProvider $provider)
{
$provider->package('php-flasher/flasher-notyf-laravel', 'flasher_notyf', flasher_path(__DIR__.'/../../Resources'));
$provider->package(
'php-flasher/flasher-notyf-laravel',
'flasher_notyf',
flasher_path(__DIR__ . '/../../Resources')
);
$this->appendToFlasherConfig();
}
/**
* @inheritDoc
*/
public function register(FlasherNotyfServiceProvider $provider)
{
$this->registerServices();
@@ -11,13 +11,7 @@ interface ServiceProviderInterface
*/
public function shouldBeUsed();
/**
* @param FlasherNotyfServiceProvider $provider
*/
public function boot(FlasherNotyfServiceProvider $provider);
/**
* @param FlasherNotyfServiceProvider $provider
*/
public function register(FlasherNotyfServiceProvider $provider);
}
@@ -26,9 +26,6 @@ final class ServiceProviderManager
*/
private $notifyServiceProvider;
/**
* @param FlasherNotyfServiceProvider $notifyServiceProvider
*/
public function __construct(FlasherNotyfServiceProvider $notifyServiceProvider)
{
$this->notifyServiceProvider = $notifyServiceProvider;
+47 -51
View File
@@ -11,6 +11,52 @@ use Orchestra\Testbench\TestCase as Orchestra;
class TestCase extends Orchestra
{
public function createApplication()
{
if (0 !== strpos(Application::VERSION, '4.0')) {
return parent::createApplication();
}
$app = new Application();
$app->detectEnvironment(array(
'local' => array('your-machine-name'),
));
$app->bindInstallPaths($this->getApplicationPaths());
$app['env'] = 'testing';
$app->instance('app', $app);
Facade::clearResolvedInstances();
Facade::setFacadeApplication($app);
$config = new Config($app->getConfigLoader(), $app['env']);
$app->instance('config', $config);
$app->startExceptionHandling();
if ($app->runningInConsole()) {
$app->setRequestForConsoleEnvironment();
}
date_default_timezone_set($this->getApplicationTimezone());
$aliases = array_merge($this->getApplicationAliases(), $this->getPackageAliases());
AliasLoader::getInstance($aliases)->register();
Request::enableHttpMethodParameterOverride();
$providers = array_merge($this->getApplicationProviders(), $this->getPackageProviders());
$app->getProviderRepository()->load($app, $providers);
$this->getEnvironmentSetUp($app);
$app->boot();
return $app;
}
/**
* @param Application $app
*
@@ -31,61 +77,11 @@ class TestCase extends Orchestra
{
$separator = $this->isLaravel4() ? '::config' : '';
$app['config']->set('session'.$separator.'.driver', 'array');
$app['config']->set('session' . $separator . '.driver', 'array');
}
private function isLaravel4()
{
return 0 === strpos(Application::VERSION, '4.');
}
/**
* {@inheritdoc}
*/
public function createApplication()
{
if (0 !== strpos(Application::VERSION, '4.0')) {
return parent::createApplication();
}
$app = new Application;
$app->detectEnvironment(array(
'local' => array('your-machine-name'),
));
$app->bindInstallPaths($this->getApplicationPaths());
$app['env'] = 'testing';
$app->instance('app', $app);
Facade::clearResolvedInstances();
Facade::setFacadeApplication($app);
$config = new Config($app->getConfigLoader(), $app['env']);
$app->instance('config', $config);
$app->startExceptionHandling();
if ($app->runningInConsole())
{
$app->setRequestForConsoleEnvironment();
}
date_default_timezone_set($this->getApplicationTimezone());
$aliases = array_merge($this->getApplicationAliases(), $this->getPackageAliases());
AliasLoader::getInstance($aliases)->register();
Request::enableHttpMethodParameterOverride();
$providers = array_merge($this->getApplicationProviders(), $this->getPackageProviders());
$app->getProviderRepository()->load($app, $providers);
$this->getEnvironmentSetUp($app);
$app->boot();
return $app;
}
}
-625
View File
@@ -1,625 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>
<!-- Import PSR-12 coding standard (base) -->
<rule ref="PSR12"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `[...]` -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<!-- But allow empty catch -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>
<!-- Force whitespace after `!` -->
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Require presence of constant visibility -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
<property name="fixable" value="true"/>
</properties>
</rule> -->
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
<!-- Forbid uses of multiple traits separated by comma -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
<property name="linesCountBeforeFirstUse" value="0"/>
<property name="linesCountBetweenUses" value="0"/>
</properties>
</rule>
<!-- Forbid dead code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
<element value="~^Created by .+\.\z~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.\z~i"/>
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
</property>
</properties>
</rule>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@var"/>
<element value="@ORM\"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Require comments with single line written as one-liners -->
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Forbid fancy yoda conditions -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require usage of null coalesce operator equal operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
<!-- Require usage of null coalesce operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
<!-- Forbid usage of conditions when a simple return can be used -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Require using Throwable instead of Exception -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Ensure Arrow Functions declaration format -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="1"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
</properties>
</rule>
<!-- Require closures not referencing $this be static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused variables passed to closures via `use` -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Require presence of declare(strict_types=1) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
</properties>
</rule> -->
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require newlines around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Forbid using absolute class name references -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Forbid spacing before the negative operator `-` -->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Require no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Forbid `list(...)` syntax -->
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
<!-- Forbid use of longhand cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Forbid useless parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require the `null` type hint to be in the last position of annotations -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require ? when default value is null -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid useless inherit doc comment -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid duplicated variables assignments -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Forbid class being in a file with different name -->
<rule ref="Squiz.Classes.ClassFileName"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Disable arrow alignment -->
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
</rule>
<!-- Force rules for function phpDoc -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Allow `@throws` without description -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- Does not work properly with PHP 7 / short-named types -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- Does not support collections, i.e. `string[]` -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<!-- Forces incorrect types -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- Breaks with compound return types, i.e. `string|null` -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Doc comment is not required for every method -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<!-- Do not require comments for `@param` -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Do not require `@param` for all parameters -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<!-- Do not require `@return` for void methods -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<!-- Doesn't respect inheritance -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- `@throws` lines can often be read as a sentence,
i.e. `@throws RuntimeException if the file could not be written.` -->
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
<!-- Doesn't work with self as typehint -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule> -->
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Require there be no space between increment/decrement operator and its operand -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR2 -> turning back on -->
<severity>5</severity>
</rule>
<!-- Checks that class/trait/interface members are in the correct order. -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks that there is a certain number of blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Requires new with parentheses. -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
</ruleset>
-3
View File
@@ -9,9 +9,6 @@ use Flasher\Prime\Factory\NotificationFactory;
*/
final class NotyfFactory extends NotificationFactory
{
/**
* @inheritDoc
*/
public function createNotificationBuilder()
{
return new NotyfBuilder($this->getStorageManager(), new Notyf(), 'notyf');
-625
View File
@@ -1,625 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>
<!-- Import PSR-12 coding standard (base) -->
<rule ref="PSR12"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `[...]` -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<!-- But allow empty catch -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>
<!-- Force whitespace after `!` -->
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Require presence of constant visibility -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
<property name="fixable" value="true"/>
</properties>
</rule> -->
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
<!-- Forbid uses of multiple traits separated by comma -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
<property name="linesCountBeforeFirstUse" value="0"/>
<property name="linesCountBetweenUses" value="0"/>
</properties>
</rule>
<!-- Forbid dead code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
<element value="~^Created by .+\.\z~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.\z~i"/>
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
</property>
</properties>
</rule>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@var"/>
<element value="@ORM\"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Require comments with single line written as one-liners -->
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Forbid fancy yoda conditions -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require usage of null coalesce operator equal operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
<!-- Require usage of null coalesce operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
<!-- Forbid usage of conditions when a simple return can be used -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Require using Throwable instead of Exception -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Ensure Arrow Functions declaration format -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="1"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
</properties>
</rule>
<!-- Require closures not referencing $this be static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused variables passed to closures via `use` -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Require presence of declare(strict_types=1) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
</properties>
</rule> -->
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require newlines around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Forbid using absolute class name references -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Forbid spacing before the negative operator `-` -->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Require no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Forbid `list(...)` syntax -->
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
<!-- Forbid use of longhand cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Forbid useless parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require the `null` type hint to be in the last position of annotations -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require ? when default value is null -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid useless inherit doc comment -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid duplicated variables assignments -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Forbid class being in a file with different name -->
<rule ref="Squiz.Classes.ClassFileName"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Disable arrow alignment -->
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
</rule>
<!-- Force rules for function phpDoc -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Allow `@throws` without description -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- Does not work properly with PHP 7 / short-named types -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- Does not support collections, i.e. `string[]` -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<!-- Forces incorrect types -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- Breaks with compound return types, i.e. `string|null` -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Doc comment is not required for every method -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<!-- Do not require comments for `@param` -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Do not require `@param` for all parameters -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<!-- Do not require `@return` for void methods -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<!-- Doesn't respect inheritance -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- `@throws` lines can often be read as a sentence,
i.e. `@throws RuntimeException if the file could not be written.` -->
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
<!-- Doesn't work with self as typehint -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule> -->
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Require there be no space between increment/decrement operator and its operand -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR2 -> turning back on -->
<severity>5</severity>
</rule>
<!-- Checks that class/trait/interface members are in the correct order. -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks that there is a certain number of blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Requires new with parentheses. -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
</ruleset>
@@ -7,9 +7,6 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
final class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('flasher_notyf');
@@ -7,17 +7,11 @@ use Symfony\Component\Config\FileLocator;
final class FlasherNotyfExtension extends Extension
{
/**
* @inheritDoc
*/
protected function getConfigFileLocator()
{
return new FileLocator(__DIR__.'/../Resources/config');
return new FileLocator(__DIR__ . '/../Resources/config');
}
/**
* @inheritDoc
*/
protected function getConfigClass()
{
return new Configuration();
@@ -2,11 +2,11 @@
namespace Flasher\Notyf\Symfony\Tests\DependencyInjection;
use Flasher\Notyf\Symfony\DependencyInjection\FlasherNotyfExtension;
use Flasher\Notyf\Symfony\FlasherNotyfSymfonyBundle;
use Flasher\Prime\Tests\TestCase;
use Flasher\Symfony\DependencyInjection\FlasherExtension;
use Flasher\Symfony\FlasherSymfonyBundle;
use Flasher\Notyf\Symfony\DependencyInjection\FlasherNotyfExtension;
use Flasher\Notyf\Symfony\FlasherNotyfSymfonyBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class FlasherNotyfExtensionTest extends TestCase
-625
View File
@@ -1,625 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>
<!-- Import PSR-12 coding standard (base) -->
<rule ref="PSR12"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `[...]` -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<!-- But allow empty catch -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>
<!-- Force whitespace after `!` -->
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Require presence of constant visibility -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
<property name="fixable" value="true"/>
</properties>
</rule> -->
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
<!-- Forbid uses of multiple traits separated by comma -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
<property name="linesCountBeforeFirstUse" value="0"/>
<property name="linesCountBetweenUses" value="0"/>
</properties>
</rule>
<!-- Forbid dead code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
<element value="~^Created by .+\.\z~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.\z~i"/>
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
</property>
</properties>
</rule>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@var"/>
<element value="@ORM\"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Require comments with single line written as one-liners -->
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Forbid fancy yoda conditions -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require usage of null coalesce operator equal operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
<!-- Require usage of null coalesce operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
<!-- Forbid usage of conditions when a simple return can be used -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Require using Throwable instead of Exception -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Ensure Arrow Functions declaration format -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="1"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
</properties>
</rule>
<!-- Require closures not referencing $this be static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused variables passed to closures via `use` -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Require presence of declare(strict_types=1) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
</properties>
</rule> -->
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require newlines around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Forbid using absolute class name references -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Forbid spacing before the negative operator `-` -->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Require no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Forbid `list(...)` syntax -->
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
<!-- Forbid use of longhand cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Forbid useless parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require the `null` type hint to be in the last position of annotations -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require ? when default value is null -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid useless inherit doc comment -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid duplicated variables assignments -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Forbid class being in a file with different name -->
<rule ref="Squiz.Classes.ClassFileName"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Disable arrow alignment -->
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
</rule>
<!-- Force rules for function phpDoc -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Allow `@throws` without description -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- Does not work properly with PHP 7 / short-named types -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- Does not support collections, i.e. `string[]` -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<!-- Forces incorrect types -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- Breaks with compound return types, i.e. `string|null` -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Doc comment is not required for every method -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<!-- Do not require comments for `@param` -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Do not require `@param` for all parameters -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<!-- Do not require `@return` for void methods -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<!-- Doesn't respect inheritance -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- `@throws` lines can often be read as a sentence,
i.e. `@throws RuntimeException if the file could not be written.` -->
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
<!-- Doesn't work with self as typehint -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule> -->
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Require there be no space between increment/decrement operator and its operand -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR2 -> turning back on -->
<severity>5</severity>
</rule>
<!-- Checks that class/trait/interface members are in the correct order. -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks that there is a certain number of blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Requires new with parentheses. -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
</ruleset>
+1 -4
View File
@@ -6,11 +6,8 @@ use Illuminate\Support\Facades\Facade;
class Pnotify extends Facade
{
/**
* @inheritdoc
*/
protected static function getFacadeAccessor()
{
return 'flasher.pnotify';
}
}
}
@@ -2,9 +2,9 @@
namespace Flasher\Pnotify\Laravel;
use Flasher\Pnotify\Laravel\ServiceProvider\ServiceProviderManager;
use Illuminate\Container\Container;
use Illuminate\Support\ServiceProvider;
use Flasher\Pnotify\Laravel\ServiceProvider\ServiceProviderManager;
final class FlasherPnotifyServiceProvider extends ServiceProvider
{
@@ -43,17 +43,11 @@ final class FlasherPnotifyServiceProvider extends ServiceProvider
return $this->app;
}
/**
* {@inheritdoc}
*/
public function mergeConfigFrom($path, $key)
{
parent::mergeConfigFrom($path, $key);
}
/**
* {@inheritdoc}
*/
public function publishes(array $paths, $groups = null)
{
parent::publishes($paths, $groups);
@@ -5,7 +5,7 @@ return array(
'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js',
'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@0.1.1/dist/flasher-pnotify.min.js',
),
'styles' => array(),
'styles' => array(),
'options' => array(
'delay' => 1000,
),
@@ -3,11 +3,10 @@
use Flasher\Prime\Notification\NotificationInterface;
use Illuminate\Support\Facades\App;
if (! function_exists('pnotify')) {
if (!function_exists('pnotify')) {
/**
* @param string $message
* @param string $type
* @param array $options
*
* @return \Flasher\Pnotify\Prime\PnotifyFactory
*/
@@ -19,4 +18,4 @@ if (! function_exists('pnotify')) {
return App::make('flasher.pnotify')->addFlash($type, $message, $options);
}
}
}
@@ -17,36 +17,26 @@ class Laravel implements ServiceProviderInterface
*/
protected $app;
/**
* @param Container $app
*/
public function __construct(Container $app)
{
$this->app = $app;
}
/**
* @inheritDoc
*/
public function shouldBeUsed()
{
return $this->app instanceof Application;
}
/**
* @inheritDoc
*/
public function boot(FlasherPnotifyServiceProvider $provider)
{
$provider->publishes(array(flasher_path(__DIR__.'/../../Resources/config/config.php') => config_path('flasher_pnotify.php')), 'flasher-config');
$provider->publishes(array(
flasher_path(__DIR__ . '/../../Resources/config/config.php') => config_path('flasher_pnotify.php'),
), 'flasher-config');
}
/**
* @inheritDoc
*/
public function register(FlasherPnotifyServiceProvider $provider)
{
$provider->mergeConfigFrom(flasher_path(__DIR__.'/../../Resources/config/config.php'), 'flasher_pnotify');
$provider->mergeConfigFrom(flasher_path(__DIR__ . '/../../Resources/config/config.php'), 'flasher_pnotify');
$this->appendToFlasherConfig();
$this->registerServices();
@@ -7,27 +7,22 @@ use Illuminate\Foundation\Application;
final class Laravel4 extends Laravel
{
/**
* @inheritDoc
*/
public function shouldBeUsed()
{
return $this->app instanceof Application && 0 === strpos(Application::VERSION, '4.');
}
/**
* @inheritDoc
*/
public function boot(FlasherPnotifyServiceProvider $provider)
{
$provider->package('php-flasher/flasher-pnotify-laravel', 'flasher_pnotify', flasher_path(__DIR__.'/../../Resources'));
$provider->package(
'php-flasher/flasher-pnotify-laravel',
'flasher_pnotify',
flasher_path(__DIR__ . '/../../Resources')
);
$this->appendToFlasherConfig();
}
/**
* @inheritDoc
*/
public function register(FlasherPnotifyServiceProvider $provider)
{
$this->registerServices();
@@ -11,13 +11,7 @@ interface ServiceProviderInterface
*/
public function shouldBeUsed();
/**
* @param FlasherPnotifyServiceProvider $provider
*/
public function boot(FlasherPnotifyServiceProvider $provider);
/**
* @param FlasherPnotifyServiceProvider $provider
*/
public function register(FlasherPnotifyServiceProvider $provider);
}
@@ -25,9 +25,6 @@ final class ServiceProviderManager
*/
private $notifyServiceProvider;
/**
* @param FlasherPnotifyServiceProvider $notifyServiceProvider
*/
public function __construct(FlasherPnotifyServiceProvider $notifyServiceProvider)
{
$this->notifyServiceProvider = $notifyServiceProvider;
+48 -52
View File
@@ -2,15 +2,61 @@
namespace Flasher\Pnotify\Laravel\Tests;
use Illuminate\Config\Repository as Config;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Facade;
use Orchestra\Testbench\TestCase as Orchestra;
use Illuminate\Config\Repository as Config;
class TestCase extends Orchestra
{
public function createApplication()
{
if (0 !== strpos(Application::VERSION, '4.0')) {
return parent::createApplication();
}
$app = new Application();
$app->detectEnvironment(array(
'local' => array('your-machine-name'),
));
$app->bindInstallPaths($this->getApplicationPaths());
$app['env'] = 'testing';
$app->instance('app', $app);
Facade::clearResolvedInstances();
Facade::setFacadeApplication($app);
$config = new Config($app->getConfigLoader(), $app['env']);
$app->instance('config', $config);
$app->startExceptionHandling();
if ($app->runningInConsole()) {
$app->setRequestForConsoleEnvironment();
}
date_default_timezone_set($this->getApplicationTimezone());
$aliases = array_merge($this->getApplicationAliases(), $this->getPackageAliases());
AliasLoader::getInstance($aliases)->register();
Request::enableHttpMethodParameterOverride();
$providers = array_merge($this->getApplicationProviders(), $this->getPackageProviders());
$app->getProviderRepository()->load($app, $providers);
$this->getEnvironmentSetUp($app);
$app->boot();
return $app;
}
/**
* @param Application $app
*
@@ -31,61 +77,11 @@ class TestCase extends Orchestra
{
$separator = $this->isLaravel4() ? '::config' : '';
$app['config']->set('session'.$separator.'.driver', 'array');
$app['config']->set('session' . $separator . '.driver', 'array');
}
private function isLaravel4()
{
return 0 === strpos(Application::VERSION, '4.');
}
/**
* {@inheritdoc}
*/
public function createApplication()
{
if (0 !== strpos(Application::VERSION, '4.0')) {
return parent::createApplication();
}
$app = new Application;
$app->detectEnvironment(array(
'local' => array('your-machine-name'),
));
$app->bindInstallPaths($this->getApplicationPaths());
$app['env'] = 'testing';
$app->instance('app', $app);
Facade::clearResolvedInstances();
Facade::setFacadeApplication($app);
$config = new Config($app->getConfigLoader(), $app['env']);
$app->instance('config', $config);
$app->startExceptionHandling();
if ($app->runningInConsole())
{
$app->setRequestForConsoleEnvironment();
}
date_default_timezone_set($this->getApplicationTimezone());
$aliases = array_merge($this->getApplicationAliases(), $this->getPackageAliases());
AliasLoader::getInstance($aliases)->register();
Request::enableHttpMethodParameterOverride();
$providers = array_merge($this->getApplicationProviders(), $this->getPackageProviders());
$app->getProviderRepository()->load($app, $providers);
$this->getEnvironmentSetUp($app);
$app->boot();
return $app;
}
}
-625
View File
@@ -1,625 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>
<!-- Import PSR-12 coding standard (base) -->
<rule ref="PSR12"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `[...]` -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<!-- But allow empty catch -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>
<!-- Force whitespace after `!` -->
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Require presence of constant visibility -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
<property name="fixable" value="true"/>
</properties>
</rule> -->
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
<!-- Forbid uses of multiple traits separated by comma -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
<property name="linesCountBeforeFirstUse" value="0"/>
<property name="linesCountBetweenUses" value="0"/>
</properties>
</rule>
<!-- Forbid dead code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
<element value="~^Created by .+\.\z~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.\z~i"/>
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
</property>
</properties>
</rule>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@var"/>
<element value="@ORM\"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Require comments with single line written as one-liners -->
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Forbid fancy yoda conditions -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require usage of null coalesce operator equal operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
<!-- Require usage of null coalesce operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
<!-- Forbid usage of conditions when a simple return can be used -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Require using Throwable instead of Exception -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Ensure Arrow Functions declaration format -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="1"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
</properties>
</rule>
<!-- Require closures not referencing $this be static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused variables passed to closures via `use` -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Require presence of declare(strict_types=1) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
</properties>
</rule> -->
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require newlines around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Forbid using absolute class name references -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Forbid spacing before the negative operator `-` -->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Require no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Forbid `list(...)` syntax -->
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
<!-- Forbid use of longhand cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Forbid useless parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require the `null` type hint to be in the last position of annotations -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require ? when default value is null -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid useless inherit doc comment -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid duplicated variables assignments -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Forbid class being in a file with different name -->
<rule ref="Squiz.Classes.ClassFileName"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Disable arrow alignment -->
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
</rule>
<!-- Force rules for function phpDoc -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Allow `@throws` without description -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- Does not work properly with PHP 7 / short-named types -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- Does not support collections, i.e. `string[]` -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<!-- Forces incorrect types -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- Breaks with compound return types, i.e. `string|null` -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Doc comment is not required for every method -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<!-- Do not require comments for `@param` -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Do not require `@param` for all parameters -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<!-- Do not require `@return` for void methods -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<!-- Doesn't respect inheritance -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- `@throws` lines can often be read as a sentence,
i.e. `@throws RuntimeException if the file could not be written.` -->
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
<!-- Doesn't work with self as typehint -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule> -->
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Require there be no space between increment/decrement operator and its operand -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR2 -> turning back on -->
<severity>5</severity>
</rule>
<!-- Checks that class/trait/interface members are in the correct order. -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks that there is a certain number of blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Requires new with parentheses. -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
</ruleset>
+4 -10
View File
@@ -6,9 +6,6 @@ use Flasher\Prime\Notification\NotificationBuilder;
final class PnotifyBuilder extends NotificationBuilder
{
/**
* @inheritDoc
*/
public function warning($message = null, array $options = array())
{
return $this->type('notice', $message, $options);
@@ -56,9 +53,6 @@ final class PnotifyBuilder extends NotificationBuilder
return $this;
}
/**
* @inheritDoc
*/
public function message($message)
{
parent::message($message);
@@ -81,8 +75,8 @@ final class PnotifyBuilder extends NotificationBuilder
}
/**
* What styling classes to use. (Can be either "brighttheme", "bootstrap3", "fontawesome", or a custom style
* object. See the source in the end of pnotify.js for the properties in a style object.)
* What styling classes to use. (Can be either "brighttheme", "bootstrap3", "fontawesome", or a custom style object.
* See the source in the end of pnotify.js for the properties in a style object.)
*
* @param string $styling
*
@@ -166,8 +160,8 @@ final class PnotifyBuilder extends NotificationBuilder
}
/**
* Set icon to true to use the default icon for the selected style/type, false for no icon, or a string for your
* own icon class.
* Set icon to true to use the default icon for the selected style/type, false for no icon, or a string for your own
* icon class.
*
* @param bool $icon
*
-3
View File
@@ -9,9 +9,6 @@ use Flasher\Prime\Factory\NotificationFactory;
*/
final class PnotifyFactory extends NotificationFactory
{
/**
* @inheritDoc
*/
public function createNotificationBuilder()
{
return new PnotifyBuilder($this->getStorageManager(), new Pnotify(), 'pnotify');
-625
View File
@@ -1,625 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>
<!-- Import PSR-12 coding standard (base) -->
<rule ref="PSR12"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `[...]` -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<!-- But allow empty catch -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>
<!-- Force whitespace after `!` -->
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Require presence of constant visibility -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
<property name="fixable" value="true"/>
</properties>
</rule> -->
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
<!-- Forbid uses of multiple traits separated by comma -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
<property name="linesCountBeforeFirstUse" value="0"/>
<property name="linesCountBetweenUses" value="0"/>
</properties>
</rule>
<!-- Forbid dead code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
<element value="~^Created by .+\.\z~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.\z~i"/>
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
</property>
</properties>
</rule>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@var"/>
<element value="@ORM\"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Require comments with single line written as one-liners -->
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Forbid fancy yoda conditions -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require usage of null coalesce operator equal operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
<!-- Require usage of null coalesce operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
<!-- Forbid usage of conditions when a simple return can be used -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Require using Throwable instead of Exception -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Ensure Arrow Functions declaration format -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="1"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
</properties>
</rule>
<!-- Require closures not referencing $this be static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused variables passed to closures via `use` -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Require presence of declare(strict_types=1) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
</properties>
</rule> -->
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require newlines around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Forbid using absolute class name references -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Forbid spacing before the negative operator `-` -->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Require no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Forbid `list(...)` syntax -->
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
<!-- Forbid use of longhand cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Forbid useless parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require the `null` type hint to be in the last position of annotations -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require ? when default value is null -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid useless inherit doc comment -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid duplicated variables assignments -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Forbid class being in a file with different name -->
<rule ref="Squiz.Classes.ClassFileName"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Disable arrow alignment -->
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
</rule>
<!-- Force rules for function phpDoc -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Allow `@throws` without description -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- Does not work properly with PHP 7 / short-named types -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- Does not support collections, i.e. `string[]` -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<!-- Forces incorrect types -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- Breaks with compound return types, i.e. `string|null` -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Doc comment is not required for every method -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<!-- Do not require comments for `@param` -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Do not require `@param` for all parameters -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<!-- Do not require `@return` for void methods -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<!-- Doesn't respect inheritance -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- `@throws` lines can often be read as a sentence,
i.e. `@throws RuntimeException if the file could not be written.` -->
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
<!-- Doesn't work with self as typehint -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule> -->
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Require there be no space between increment/decrement operator and its operand -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR2 -> turning back on -->
<severity>5</severity>
</rule>
<!-- Checks that class/trait/interface members are in the correct order. -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks that there is a certain number of blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Requires new with parentheses. -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
</ruleset>
@@ -7,9 +7,6 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
final class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('flasher_pnotify');
@@ -7,17 +7,11 @@ use Symfony\Component\Config\FileLocator;
final class FlasherPnotifyExtension extends Extension
{
/**
* @inheritDoc
*/
protected function getConfigFileLocator()
{
return new FileLocator(__DIR__.'/../Resources/config');
return new FileLocator(__DIR__ . '/../Resources/config');
}
/**
* @inheritDoc
*/
protected function getConfigClass()
{
return new Configuration();
@@ -17,7 +17,7 @@ class ConfigurationTest extends TestCase
'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js',
'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@0.1.1/dist/flasher-pnotify.min.js',
),
'styles' => array(),
'styles' => array(),
'options' => array(
'delay' => 1000,
),
@@ -2,11 +2,11 @@
namespace Flasher\Pnotify\Symfony\Tests\DependencyInjection;
use Flasher\Pnotify\Symfony\DependencyInjection\FlasherPnotifyExtension;
use Flasher\Pnotify\Symfony\FlasherPnotifySymfonyBundle;
use Flasher\Prime\Tests\TestCase;
use Flasher\Symfony\DependencyInjection\FlasherExtension;
use Flasher\Symfony\FlasherSymfonyBundle;
use Flasher\Pnotify\Symfony\DependencyInjection\FlasherPnotifyExtension;
use Flasher\Pnotify\Symfony\FlasherPnotifySymfonyBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class FlasherPnotifyExtensionTest extends TestCase
-625
View File
@@ -1,625 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>
<!-- Import PSR-12 coding standard (base) -->
<rule ref="PSR12"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `[...]` -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<!-- But allow empty catch -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid useless empty method overrides -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>
<!-- Force whitespace after `!` -->
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="chop" value="rtrim"/>
<element key="close" value="closedir"/>
<element key="compact" value="null"/>
<element key="delete" value="unset"/>
<element key="doubleval" value="floatval"/>
<element key="extract" value="null"/>
<element key="fputs" value="fwrite"/>
<element key="ini_alter" value="ini_set"/>
<element key="is_double" value="is_float"/>
<element key="is_integer" value="is_int"/>
<element key="is_long" value="is_int"/>
<element key="is_null" value="null"/>
<element key="is_real" value="is_float"/>
<element key="is_writeable" value="is_writable"/>
<element key="join" value="implode"/>
<element key="key_exists" value="array_key_exists"/>
<element key="pos" value="current"/>
<element key="settype" value="null"/>
<element key="show_source" value="highlight_file"/>
<element key="sizeof" value="count"/>
<element key="strchr" value="strstr"/>
<element key="user_error" value="trigger_error"/>
</property>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Force PHP 7 param and return types to be lowercased -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<!-- Require presence of constant visibility -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
<properties>
<property name="fixable" value="true"/>
</properties>
</rule> -->
<!-- Forbid LSB for constants (static::FOO) -->
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<!-- Forbid more than one constant declared per statement -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
<!-- Forbid uses of multiple traits separated by comma -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
<property name="linesCountBeforeFirstUse" value="0"/>
<property name="linesCountBetweenUses" value="0"/>
</properties>
</rule>
<!-- Forbid dead code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@api"/>
<element value="@author"/>
<element value="@category"/>
<element value="@copyright"/>
<element value="@created"/>
<element value="@license"/>
<element value="@package"/>
<element value="@since"/>
<element value="@subpackage"/>
<element value="@version"/>
</property>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array">
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
<element value="~^Created by .+\.\z~i"/>
<element value="~^(User|Date|Time): \S+\z~i"/>
<element value="~^\S+ [gs]etter\.\z~i"/>
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
</property>
</properties>
</rule>
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0"/>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
<property name="annotationsGroups" type="array">
<element value="
@internal,
@deprecated,
"/>
<element value="
@link,
@see,
@uses,
"/>
<element value="@var"/>
<element value="@ORM\"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
</property>
</properties>
</rule>
<!-- Report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Require comments with single line written as one-liners -->
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Forbid fancy yoda conditions -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require usage of null coalesce operator equal operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
<!-- Require usage of null coalesce operator when possible -->
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
<!-- Forbid usage of conditions when a simple return can be used -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<!-- Require using Throwable instead of Exception -->
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<!-- Ensure Arrow Functions declaration format -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="1"/>
<property name="spacesCountBeforeArrow" value="1"/>
<property name="spacesCountAfterArrow" value="1"/>
</properties>
</rule>
<!-- Require closures not referencing $this be static -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused variables passed to closures via `use` -->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!-- Require presence of declare(strict_types=1) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
</properties>
</rule> -->
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require newlines around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<!-- Forbid using absolute class name references -->
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountAfterLastUse" value="1"/>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Forbid weak comparisons -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<!-- Forbid spacing before the negative operator `-` -->
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Require no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Forbid `list(...)` syntax -->
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
<!-- Forbid use of longhand cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<!-- Forbid useless parentheses -->
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require the `null` type hint to be in the last position of annotations -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require ? when default value is null -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid useless inherit doc comment -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid duplicated variables assignments -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid useless variables -->
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Forbid class being in a file with different name -->
<rule ref="Squiz.Classes.ClassFileName"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Force camelCase variables -->
<rule ref="Squiz.NamingConventions.ValidVariableName">
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
</rule>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Disable arrow alignment -->
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
</rule>
<!-- Force rules for function phpDoc -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Allow `@throws` without description -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<!-- Does not work properly with PHP 7 / short-named types -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- Does not support collections, i.e. `string[]` -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
<!-- Forces incorrect types -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- Breaks with compound return types, i.e. `string|null` -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
<!-- Doc comment is not required for every method -->
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<!-- Do not require comments for `@param` -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<!-- Do not require `@param` for all parameters -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<!-- Do not require `@return` for void methods -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
<!-- Comments don't have to be sentences -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Breaks when all params are not documented -->
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
<!-- Doesn't respect inheritance -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- `@throws` lines can often be read as a sentence,
i.e. `@throws RuntimeException if the file could not be written.` -->
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
<!-- Doesn't work with self as typehint -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
</rule>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="0"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule> -->
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require 1 line before and after function, except at the top and bottom -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Require there be no space between increment/decrement operator and its operand -->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid spaces before semicolon `;` -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<!-- turned off by PSR2 -> turning back on -->
<severity>5</severity>
</rule>
<!-- Checks that class/trait/interface members are in the correct order. -->
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Checks that there is a certain number of blank lines between properties. -->
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="tokensToCheck" type="array">
<element value="T_RETURN" />
<element value="T_THROW" />
<element value="T_YIELD" />
<element value="T_YIELD_FROM" />
</property>
</properties>
</rule>
<!-- Require consistent spacing for block structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
<properties>
<property name="tokensToCheck" type="array">
<element value="T_IF" />
<element value="T_DO" />
<element value="T_WHILE" />
<element value="T_FOR" />
<element value="T_FOREACH" />
<element value="T_SWITCH" />
<element value="T_TRY" />
<element value="T_DEFAULT" />
</property>
</properties>
</rule>
<!-- Requires new with parentheses. -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
</ruleset>
-6
View File
@@ -9,17 +9,11 @@ final class Config implements ConfigInterface
*/
private $config;
/**
* @param array $config
*/
public function __construct(array $config)
{
$this->config = $config;
}
/**
* @inheritDoc
*/
public function get($key, $default = null)
{
$data = $this->config;
-34
View File
@@ -19,7 +19,6 @@ final class Envelope implements NotificationInterface
private $stamps = array();
/**
* @param NotificationInterface $notification
* @param StampInterface[] $stamps
*/
public function __construct(NotificationInterface $notification, $stamps = array())
@@ -31,7 +30,6 @@ final class Envelope implements NotificationInterface
/**
* Makes sure the notification is in an Envelope and adds the given stamps.
*
* @param NotificationInterface $notification
* @param StampInterface[] $stamps
*
* @return Envelope
@@ -60,8 +58,6 @@ final class Envelope implements NotificationInterface
}
/**
* @param StampInterface $stamp
*
* @return $this
*/
public function withStamp(StampInterface $stamp)
@@ -105,81 +101,51 @@ final class Envelope implements NotificationInterface
return $this->notification;
}
/**
* @inheritDoc
*/
public function getType()
{
return $this->notification->getType();
}
/**
* @inheritDoc
*/
public function setType($type)
{
$this->notification->setType($type);
}
/**
* @inheritDoc
*/
public function getMessage()
{
return $this->notification->getMessage();
}
/**
* @inheritDoc
*/
public function setMessage($message)
{
$this->notification->setMessage($message);
}
/**
* @inheritDoc
*/
public function getOptions()
{
return $this->notification->getOptions();
}
/**
* @inheritDoc
*/
public function setOptions(array $options)
{
$this->notification->setOptions($options);
}
/**
* @inheritDoc
*/
public function getOption($name, $default = null)
{
return $this->notification->getOption($name, $default);
}
/**
* @inheritDoc
*/
public function setOption($name, $value)
{
$this->notification->setOption($name, $value);
}
/**
* @inheritDoc
*/
public function unsetOption($name)
{
$this->notification->unsetOption($name);
}
/**
* @inheritDoc
*/
public function toArray()
{
$array = array(
@@ -18,12 +18,11 @@ final class FilterEvent
/**
* @param Envelope[] $envelopes
* @param array $criteria
*/
public function __construct(array $envelopes, array $criteria)
{
$this->envelopes = $envelopes;
$this->criteria = $criteria;
$this->criteria = $criteria;
}
/**
@@ -50,9 +49,6 @@ final class FilterEvent
return $this->criteria;
}
/**
* @param array $criteria
*/
public function setCriteria(array $criteria)
{
$this->criteria = $criteria;
+29 -34
View File
@@ -17,9 +17,6 @@ final class EventDispatcher implements EventDispatcherInterface
*/
private $sorted = array();
/**
* @inheritDoc
*/
public function dispatch($event)
{
$listeners = $this->getListeners(get_class($event));
@@ -47,6 +44,35 @@ final class EventDispatcher implements EventDispatcherInterface
return $this->sorted[$eventName];
}
public function addListener($eventName, $listener, $priority = 0)
{
$this->listeners[$eventName][$priority][] = $listener;
}
public function addSubscriber(EventSubscriberInterface $subscriber)
{
foreach ((array) $subscriber->getSubscribedEvents() as $eventName => $params) {
if (is_int($eventName)) {
$eventName = $params;
$params = '__invoke';
}
if (is_string($params)) {
$this->addListener($eventName, array($subscriber, $params));
} elseif (is_string($params[0])) {
$this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
} else {
foreach ($params as $listener) {
$this->addListener(
$eventName,
array($subscriber, $listener[0]),
isset($listener[1]) ? $listener[1] : 0
);
}
}
}
}
/**
* @param string $eventName
*/
@@ -75,35 +101,4 @@ final class EventDispatcher implements EventDispatcherInterface
$listener($event, $this);
}
}
/**
* @inheritDoc
*/
public function addListener($eventName, $listener, $priority = 0)
{
$this->listeners[$eventName][$priority][] = $listener;
}
/**
* @inheritdoc
*/
public function addSubscriber(EventSubscriberInterface $subscriber)
{
foreach ((array) $subscriber->getSubscribedEvents() as $eventName => $params) {
if (is_int($eventName)) {
$eventName = $params;
$params = '__invoke';
}
if (is_string($params)) {
$this->addListener($eventName, array($subscriber, $params));
} elseif (is_string($params[0])) {
$this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
} else {
foreach ($params as $listener) {
$this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
}
}
}
}
}
@@ -20,8 +20,5 @@ interface EventDispatcherInterface
*/
public function addListener($eventName, $listener, $priority = 0);
/**
* @param EventSubscriberInterface $subscriber
*/
public function addSubscriber(EventSubscriberInterface $subscriber);
}
@@ -3,7 +3,6 @@
namespace Flasher\Prime\EventDispatcher\EventListener;
use Flasher\Prime\EventDispatcher\Event\FilterEvent;
use Flasher\Prime\Envelope;
use Flasher\Prime\Filter\FilterInterface;
final class FilterListener implements EventSubscriberInterface
@@ -13,17 +12,11 @@ final class FilterListener implements EventSubscriberInterface
*/
private $filter;
/**
* @param FilterInterface $filter
*/
public function __construct(FilterInterface $filter)
{
$this->filter = $filter;
}
/**
* @param FilterEvent $event
*/
public function __invoke(FilterEvent $event)
{
$criteria = $event->getCriteria();
@@ -35,9 +28,6 @@ final class FilterListener implements EventSubscriberInterface
$event->setEnvelopes($envelopes);
}
/**
* @inheritDoc
*/
public static function getSubscribedEvents()
{
return 'Flasher\Prime\EventDispatcher\Event\FilterEvent';
@@ -7,9 +7,6 @@ use Flasher\Prime\Stamp\HopsStamp;
final class RemoveListener implements EventSubscriberInterface
{
/**
* @param RemoveEvent $event
*/
public function __invoke(RemoveEvent $event)
{
$envelopesToKeep = $event->getEnvelopesToKeep();
@@ -31,9 +28,6 @@ final class RemoveListener implements EventSubscriberInterface
$event->setEnvelopesToRemove($envelopesToRemove);
}
/**
* @inheritDoc
*/
public static function getSubscribedEvents()
{
return 'Flasher\Prime\EventDispatcher\Event\RemoveEvent';
@@ -12,17 +12,11 @@ final class ResponseListener implements EventSubscriberInterface
*/
private $filter;
/**
* @param FilterInterface $filter
*/
public function __construct(FilterInterface $filter)
{
$this->filter = $filter;
}
/**
* @param FilterEvent $event
*/
public function __invoke(FilterEvent $event)
{
$criteria = $event->getCriteria();
@@ -34,9 +28,6 @@ final class ResponseListener implements EventSubscriberInterface
$event->setEnvelopes($envelopes);
}
/**
* @inheritDoc
*/
public static function getSubscribedEvents()
{
return 'Flasher\Prime\EventDispatcher\Event\FilterEvent';
@@ -23,9 +23,14 @@ final class StampsListener implements EventSubscriberInterface
}
}
/**
* @param Envelope $envelope
*/
public static function getSubscribedEvents()
{
return array(
'Flasher\Prime\EventDispatcher\Event\PersistEvent',
'Flasher\Prime\EventDispatcher\Event\UpdateEvent',
);
}
private function attachStamps(Envelope $envelope)
{
if (null === $envelope->get('Flasher\Prime\Stamp\CreatedAtStamp')) {
@@ -48,15 +53,4 @@ final class StampsListener implements EventSubscriberInterface
$envelope->withStamp(new PriorityStamp(0));
}
}
/**
* @inheritDoc
*/
public static function getSubscribedEvents()
{
return array(
'Flasher\Prime\EventDispatcher\Event\PersistEvent',
'Flasher\Prime\EventDispatcher\Event\UpdateEvent',
);
}
}
+5 -12
View File
@@ -13,27 +13,15 @@ class NotificationFactory implements NotificationFactoryInterface
*/
protected $storageManager;
/**
* @param StorageManagerInterface $storageManager
*/
public function __construct(StorageManagerInterface $storageManager)
{
$this->storageManager = $storageManager;
}
/**
* {@inheritdoc}
*/
public function createNotificationBuilder()
{
return new NotificationBuilder($this->getStorageManager(), new Notification(), 'template');
}
/**
* Dynamically call the default driver instance.
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
@@ -42,6 +30,11 @@ class NotificationFactory implements NotificationFactoryInterface
return call_user_func_array(array($this->createNotificationBuilder(), $method), $parameters);
}
public function createNotificationBuilder()
{
return new NotificationBuilder($this->getStorageManager(), new Notification(), 'template');
}
/**
* @return StorageManagerInterface
*/
+15 -9
View File
@@ -18,10 +18,6 @@ final class CriteriaBuilder
*/
private $criteria;
/**
* @param FilterBuilder $filterBuilder
* @param array $criteria
*/
public function __construct(FilterBuilder $filterBuilder, array $criteria)
{
$this->filterBuilder = $filterBuilder;
@@ -49,7 +45,9 @@ final class CriteriaBuilder
$priority = $this->criteria['priority'];
if (!is_array($priority)) {
$priority = array('min' => $priority);
$priority = array(
'min' => $priority,
);
}
$min = isset($priority['min']) ? $priority['min'] : null;
@@ -67,7 +65,9 @@ final class CriteriaBuilder
$hops = $this->criteria['hops'];
if (!is_array($hops)) {
$hops = array('min' => $hops);
$hops = array(
'min' => $hops,
);
}
$min = isset($hops['min']) ? $hops['min'] : null;
@@ -85,7 +85,9 @@ final class CriteriaBuilder
$delay = $this->criteria['delay'];
if (!is_array($delay)) {
$delay = array('min' => $delay);
$delay = array(
'min' => $delay,
);
}
$min = isset($delay['min']) ? $delay['min'] : null;
@@ -103,7 +105,9 @@ final class CriteriaBuilder
$life = $this->criteria['life'];
if (!is_array($life)) {
$life = array('min' => $life);
$life = array(
'min' => $life,
);
}
$min = isset($life['min']) ? $life['min'] : null;
@@ -130,7 +134,9 @@ final class CriteriaBuilder
$orderings = $this->criteria['order_by'];
if (!is_array($orderings)) {
$orderings = array($orderings => FilterBuilder::ASC);
$orderings = array(
$orderings => FilterBuilder::ASC,
);
}
$this->filterBuilder->orderBy($orderings);
-3
View File
@@ -17,9 +17,6 @@ final class Filter implements FilterInterface
$this->filterBuilder = $filterBuilder ?: new FilterBuilder();
}
/**
* @inheritDoc
*/
public function filter(array $envelopes, array $criteria)
{
return $this->filterBuilder->withCriteria($criteria)->filter($envelopes);
+4 -11
View File
@@ -10,7 +10,8 @@ use Flasher\Prime\Stamp\OrderableStampInterface;
final class FilterBuilder
{
const ASC = 'ASC';
const ASC = 'ASC';
const DESC = 'DESC';
/**
@@ -36,7 +37,7 @@ final class FilterBuilder
public function orderBy(array $orderings)
{
$this->orderings = array_map(static function ($ordering) {
return strtoupper($ordering) === FilterBuilder::ASC ? FilterBuilder::ASC : FilterBuilder::DESC;
return strtoupper($ordering) === self::ASC ? self::ASC : self::DESC;
}, $orderings);
return $this;
@@ -51,8 +52,6 @@ final class FilterBuilder
}
/**
* @param array $criteria
*
* @return $this
*/
public function withCriteria(array $criteria)
@@ -83,7 +82,7 @@ final class FilterBuilder
if (null !== $orderings) {
usort($envelopes, static function (Envelope $a, Envelope $b) use ($orderings) {
foreach ($orderings as $field => $ordering) {
if (FilterBuilder::ASC !== $ordering) {
if (self::ASC !== $ordering) {
list($a, $b) = array($b, $a);
}
@@ -143,8 +142,6 @@ final class FilterBuilder
}
/**
* @param SpecificationInterface $specification
*
* @return $this
*/
public function andWhere(SpecificationInterface $specification)
@@ -159,8 +156,6 @@ final class FilterBuilder
}
/**
* @param SpecificationInterface $specification
*
* @return $this
*/
public function where(SpecificationInterface $specification)
@@ -171,8 +166,6 @@ final class FilterBuilder
}
/**
* @param SpecificationInterface $specification
*
* @return $this
*/
public function orWhere(SpecificationInterface $specification)
-1
View File
@@ -8,7 +8,6 @@ interface FilterInterface
{
/**
* @param Envelope[] $envelopes
* @param array $criteria
*
* @return array
*/
@@ -21,9 +21,6 @@ final class AndSpecification implements SpecificationInterface
$this->specifications = $specifications;
}
/**
* @inheritDoc
*/
public function isSatisfiedBy(Envelope $envelope)
{
foreach ($this->specifications as $specification) {
@@ -26,9 +26,6 @@ final class DelaySpecification implements SpecificationInterface
$this->maxDelay = $maxDelay;
}
/**
* @inheritDoc
*/
public function isSatisfiedBy(Envelope $envelope)
{
$stamp = $envelope->get('Flasher\Prime\Stamp\DelayStamp');
@@ -26,9 +26,6 @@ final class HopsSpecification implements SpecificationInterface
$this->maxAmount = $maxAmount;
}
/**
* @inheritDoc
*/
public function isSatisfiedBy(Envelope $envelope)
{
$stamp = $envelope->get('Flasher\Prime\Stamp\HopsStamp');
@@ -11,17 +11,11 @@ final class NotSpecification implements SpecificationInterface
*/
private $specification;
/**
* @param SpecificationInterface $specification
*/
public function __construct(SpecificationInterface $specification)
{
$this->specification = $specification;
}
/**
* @inheritDoc
*/
public function isSatisfiedBy(Envelope $envelope)
{
return !$this->specification->isSatisfiedBy($envelope);
@@ -21,9 +21,6 @@ final class OrSpecification implements SpecificationInterface
$this->specifications = $specifications;
}
/**
* @inheritDoc
*/
public function isSatisfiedBy(Envelope $envelope)
{
foreach ($this->specifications as $specification) {
@@ -26,9 +26,6 @@ final class PrioritySpecification implements SpecificationInterface
$this->maxPriority = $maxPriority;
}
/**
* @inheritDoc
*/
public function isSatisfiedBy(Envelope $envelope)
{
$stamp = $envelope->get('Flasher\Prime\Stamp\PriorityStamp');
@@ -7,8 +7,6 @@ use Flasher\Prime\Envelope;
interface SpecificationInterface
{
/**
* @param Envelope $envelope
*
* @return bool
*/
public function isSatisfiedBy(Envelope $envelope);
@@ -17,19 +17,12 @@ final class TimeSpecification implements SpecificationInterface
*/
private $maxTime;
/**
* @param DateTime $minTime
* @param DateTime|null $maxTime
*/
public function __construct(DateTime $minTime, DateTime $maxTime = null)
{
$this->minTime = $minTime;
$this->maxTime = $maxTime;
}
/**
* @inheritDoc
*/
public function isSatisfiedBy(Envelope $envelope)
{
$stamp = $envelope->get('Flasher\Prime\Stamp\CreatedAtStamp');
+10 -20
View File
@@ -19,17 +19,23 @@ final class Flasher implements FlasherInterface
*/
private $config;
/**
* @param ConfigInterface $config
*/
public function __construct(ConfigInterface $config)
{
$this->config = $config;
}
/**
* @inheritDoc
* Dynamically call the default factory instance.
*
* @param string $method
*
* @return mixed
*/
public function __call($method, array $parameters)
{
return call_user_func_array(array($this->create(), $method), $parameters);
}
public function create($alias = null)
{
$alias = $alias ?: $this->getDefaultFactory();
@@ -41,9 +47,6 @@ final class Flasher implements FlasherInterface
return $this->factories[$alias];
}
/**
* @inheritDoc
*/
public function addFactory($alias, NotificationFactoryInterface $factory)
{
$this->factories[$alias] = $factory;
@@ -58,17 +61,4 @@ final class Flasher implements FlasherInterface
{
return $this->config->get('default');
}
/**
* Dynamically call the default factory instance.
*
* @param string $method
* @param array $parameters
*
* @return mixed
*/
public function __call($method, array $parameters)
{
return call_user_func_array(array($this->create(), $method), $parameters);
}
}
-1
View File
@@ -25,7 +25,6 @@ interface FlasherInterface
* Register a custom driver creator.
*
* @param string $alias
* @param NotificationFactoryInterface $factory
*
* @return $this
*/
+1 -31
View File
@@ -19,57 +19,36 @@ class Notification implements NotificationInterface
*/
protected $options = array();
/**
* @inheritDoc
*/
public function getType()
{
return $this->type;
}
/**
* @inheritDoc
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @inheritDoc
*/
public function getMessage()
{
return $this->message;
}
/**
* @inheritDoc
*/
public function setMessage($message)
{
$this->message = $message;
}
/**
* @inheritDoc
*/
public function getOptions()
{
return $this->options;
}
/**
* @inheritDoc
*/
public function setOptions(array $options)
{
$this->options = $options;
}
/**
* @inheritDoc
*/
public function getOption($name, $default = null)
{
if (!isset($this->options[$name])) {
@@ -79,29 +58,20 @@ class Notification implements NotificationInterface
return $this->options[$name];
}
/**
* @inheritDoc
*/
public function setOption($name, $value)
{
$this->options[$name] = $value;
}
/**
* @inheritDoc
*/
public function unsetOption($name)
{
unset($this->options[$name]);
}
/**
* @inheritDoc
*/
public function toArray()
{
return array(
'type' => $this->getType(),
'type' => $this->getType(),
'message' => $this->getMessage(),
'options' => $this->getOptions(),
);
@@ -9,7 +9,6 @@ use Flasher\Prime\Stamp\HopsStamp;
use Flasher\Prime\Stamp\PriorityStamp;
use Flasher\Prime\Stamp\StampInterface;
use Flasher\Prime\Storage\StorageManagerInterface;
use Flasher\Toastr\Prime\ToastrBuilder;
class NotificationBuilder implements NotificationBuilderInterface
{
@@ -24,8 +23,6 @@ class NotificationBuilder implements NotificationBuilderInterface
protected $storageManager;
/**
* @param StorageManagerInterface $storageManager
* @param NotificationInterface $notification
* @param string $handler
*/
public function __construct(StorageManagerInterface $storageManager, NotificationInterface $notification, $handler)
@@ -37,7 +34,6 @@ class NotificationBuilder implements NotificationBuilderInterface
/**
* @param string $message
* @param array $options
*
* @return Envelope
*/
@@ -48,7 +44,6 @@ class NotificationBuilder implements NotificationBuilderInterface
/**
* @param string $message
* @param array $options
*
* @return Envelope
*/
@@ -59,7 +54,6 @@ class NotificationBuilder implements NotificationBuilderInterface
/**
* @param string $message
* @param array $options
*
* @return Envelope
*/
@@ -70,7 +64,6 @@ class NotificationBuilder implements NotificationBuilderInterface
/**
* @param string $message
* @param array $options
*
* @return Envelope
*/
@@ -79,9 +72,6 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this->addFlash(NotificationInterface::TYPE_INFO, $message, $options);
}
/**
* @inheritDoc
*/
public function addFlash($type, $message = null, array $options = array())
{
if ($type instanceof NotificationInterface) {
@@ -94,9 +84,6 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this->flash();
}
/**
* @inheritDoc
*/
public function flash($stamps = array())
{
if (!empty($stamps)) {
@@ -108,9 +95,6 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this->getEnvelope();
}
/**
* @inheritDoc
*/
public function type($type, $message = null, array $options = array())
{
$this->envelope->setType($type);
@@ -126,9 +110,6 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this;
}
/**
* @inheritDoc
*/
public function message($message)
{
$this->envelope->setMessage(addslashes($message));
@@ -136,9 +117,6 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this;
}
/**
* @inheritDoc
*/
public function options($options, $merge = true)
{
if (true === $merge) {
@@ -150,9 +128,6 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this;
}
/**
* @inheritDoc
*/
public function option($name, $value)
{
$this->envelope->setOption($name, $value);
@@ -160,41 +135,26 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this;
}
/**
* @inheritDoc
*/
public function success($message = null, array $options = array())
{
return $this->type(NotificationInterface::TYPE_SUCCESS, $message, $options);
}
/**
* @inheritDoc
*/
public function error($message = null, array $options = array())
{
return $this->type(NotificationInterface::TYPE_ERROR, $message, $options);
}
/**
* @inheritDoc
*/
public function info($message = null, array $options = array())
{
return $this->type(NotificationInterface::TYPE_INFO, $message, $options);
}
/**
* @inheritDoc
*/
public function warning($message = null, array $options = array())
{
return $this->type(NotificationInterface::TYPE_WARNING, $message, $options);
}
/**
* @inheritDoc
*/
public function priority($priority)
{
$this->envelope->withStamp(new PriorityStamp($priority));
@@ -202,9 +162,6 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this;
}
/**
* @inheritDoc
*/
public function hops($amount)
{
$this->envelope->withStamp(new HopsStamp($amount));
@@ -212,9 +169,6 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this;
}
/**
* @inheritDoc
*/
public function keep()
{
$hopsStamp = $this->envelope->get('Flasher\Prime\Stamp\HopsStamp');
@@ -225,9 +179,6 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this;
}
/**
* @inheritDoc
*/
public function delay($delay)
{
$this->envelope->withStamp(new DelayStamp($delay));
@@ -235,17 +186,11 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this;
}
/**
* @inheritDoc
*/
public function now()
{
return $this->delay(0);
}
/**
* @inheritDoc
*/
public function with(array $stamps = array())
{
$this->envelope->with($stamps);
@@ -253,9 +198,6 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this;
}
/**
* @inheritDoc
*/
public function withStamp(StampInterface $stamp)
{
$this->envelope->withStamp($stamp);
@@ -263,17 +205,11 @@ class NotificationBuilder implements NotificationBuilderInterface
return $this;
}
/**
* @inheritDoc
*/
public function getEnvelope()
{
return $this->envelope;
}
/**
* @inheritDoc
*/
public function handler($handler)
{
$this->envelope->withStamp(new HandlerStamp($handler));
@@ -9,7 +9,6 @@ interface NotificationBuilderInterface
{
/**
* @param string $message
* @param array $options
*
* @return Envelope
*/
@@ -17,7 +16,6 @@ interface NotificationBuilderInterface
/**
* @param string $message
* @param array $options
*
* @return Envelope
*/
@@ -25,7 +23,6 @@ interface NotificationBuilderInterface
/**
* @param string $message
* @param array $options
*
* @return Envelope
*/
@@ -33,7 +30,6 @@ interface NotificationBuilderInterface
/**
* @param string $message
* @param array $options
*
* @return Envelope
*/
@@ -42,7 +38,6 @@ interface NotificationBuilderInterface
/**
* @param string|NotificationInterface $type
* @param string $message
* @param array $options
*
* @return Envelope|mixed
*/
@@ -51,7 +46,6 @@ interface NotificationBuilderInterface
/**
* @param string $type
* @param string|null $message
* @param array $options
*
* @return self
*/
@@ -82,7 +76,6 @@ interface NotificationBuilderInterface
/**
* @param string|null $message
* @param array $options
*
* @return self
*/
@@ -90,16 +83,13 @@ interface NotificationBuilderInterface
/**
* @param string|null $message
* @param array $options
*
* @return self
*/
public function error($message = null, array $options = array());
/**
* @param string|null $message
* @param array $options
*
* @return self
*/
@@ -107,7 +97,6 @@ interface NotificationBuilderInterface
/**
* @param string|null $message
* @param array $options
*
* @return self
*/
@@ -140,8 +129,6 @@ interface NotificationBuilderInterface
public function handler($handler);
/**
* @param StampInterface $stamp
*
* @return self
*/
public function withStamp(StampInterface $stamp);

Some files were not shown because too many files have changed in this diff Show More