Skip to content

Commit

Permalink
Updated minimum PHP version, and used Qubus coding standards.
Browse files Browse the repository at this point in the history
  • Loading branch information
nomadicjosh committed Aug 24, 2023
1 parent b072d56 commit 2bda10c
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 137 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor/
.idea
.phpcs-cache
composer.lock
index.php
7 changes: 4 additions & 3 deletions ConverterAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
* Qubus\Inheritance
*
* @link https://github.com/QubusPHP/inheritance
* @copyright 2021 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2022
* @author Joshua Parker <josh@joshuaparker.blog>
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
* @since 2.0.1
*/

declare(strict_types=1);
Expand All @@ -25,7 +26,7 @@ trait ConverterAware
* @param array $array Array of data.
* @return object
*/
public function toObject(array $array)
public function toObject(array $array): object
{
foreach ($array as $key => $value) {
if (is_array($value)) {
Expand Down
7 changes: 5 additions & 2 deletions Helpers/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* Qubus\Inheritance
*
* @link https://github.com/QubusPHP/inheritance
* @copyright 2022 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2022
* @author Joshua Parker <josh@joshuaparker.blog>
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 2.0.1
Expand All @@ -19,7 +20,9 @@
/**
* Call the given callable with the given value then return the value.
*
* @param callable|null $callable
* @param mixed $value
* @param callable|null $callback
* @return mixed
*/
function tap(mixed $value, ?callable $callback = null): mixed
{
Expand Down
14 changes: 9 additions & 5 deletions InvokerAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
* Qubus\Inheritance
*
* @link https://github.com/QubusPHP/inheritance
* @copyright 2021 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2022
* @author Joshua Parker <josh@joshuaparker.blog>
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 2.0.0
* @since 2.0.1
*/

declare(strict_types=1);

namespace Qubus\Inheritance;

use Closure;

use function call_user_func_array;
use function ob_get_clean;
use function ob_start;
Expand All @@ -23,11 +26,12 @@ trait InvokerAware
/**
* Call the given Closure with buffering support.
*
* @param callable|Closure $closure
* @param array $parameters
* @param callable|Closure $closure
* @param array $parameters
* @param bool $buffer
* @return mixed
*/
public function call($closure, array $parameters = [], bool $buffer = false)
public function call(callable|Closure $closure, array $parameters = [], bool $buffer = false): mixed
{
if ($buffer) {
ob_start();
Expand Down
12 changes: 10 additions & 2 deletions MultitonAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,35 @@
* Qubus\Inheritance
*
* @link https://github.com/QubusPHP/inheritance
* @copyright 2021 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2022
* @author Joshua Parker <josh@joshuaparker.blog>
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
* @since 2.0.1
*/

declare(strict_types=1);

namespace Qubus\Inheritance;

use ReflectionClass;
use ReflectionException;

trait MultitonAware
{
use StaticProxyAware;

/**
* @throws ReflectionException
*/
public static function getInstance()
{
return static::getNamedInstance();
}

/**
* @throws ReflectionException
*/
public static function getNamedInstance($key = '__DEFAULT__')
{
if (! isset(static::$instance[$key])) {
Expand Down
3 changes: 2 additions & 1 deletion Proxy/TapProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* Qubus\Inheritance
*
* @link https://github.com/QubusPHP/inheritance
* @copyright 2022 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2022
* @author Joshua Parker <josh@joshuaparker.blog>
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 2.0.1
Expand Down
9 changes: 5 additions & 4 deletions SortCallbackAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
* Qubus\Inheritance
*
* @link https://github.com/QubusPHP/inheritance
* @copyright 2021 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2022
* @author Joshua Parker <josh@joshuaparker.blog>
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
* @since 2.0.1
*/

declare(strict_types=1);
Expand All @@ -21,9 +22,9 @@ trait SortCallbackAware
*
* @param array $a Action or Filter.
* @param array $b Action or Filter.
* @return int Comparision
* @return int Comparison
*/
protected function afsort(array $a, array $b)
protected function afsort(array $a, array $b): int
{
if (isset($a['priority']) && isset($b['priority'])) {
$priority1 = (int) $a['priority'];
Expand Down
11 changes: 7 additions & 4 deletions StaticProxyAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
* Qubus\Inheritance
*
* @link https://github.com/QubusPHP/inheritance
* @copyright 2021 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2022
* @author Joshua Parker <josh@joshuaparker.blog>
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
* @since 2.0.1
*/

declare(strict_types=1);

namespace Qubus\Inheritance;

use ReflectionClass;
use ReflectionException;
use RuntimeException;

trait StaticProxyAware
Expand All @@ -30,8 +32,9 @@ trait StaticProxyAware
* Creates the original or retrieves the stored singleton instance.
*
* @return self
* @throws ReflectionException
*/
public static function getInstance()
public static function getInstance(): static
{
if (! static::$instance) {
static::$instance = (new ReflectionClass(static::class))
Expand All @@ -44,7 +47,7 @@ public static function getInstance()
/**
* Reset the Container instance.
*/
public static function resetInstance()
public static function resetInstance(): void
{
if (self::$instance) {
self::$instance = null;
Expand Down
7 changes: 5 additions & 2 deletions TapAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* Qubus\Inheritance
*
* @link https://github.com/QubusPHP/inheritance
* @copyright 2022 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2022
* @author Joshua Parker <josh@joshuaparker.blog>
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 2.0.1
Expand All @@ -21,7 +22,9 @@ trait TapAware
/**
* Call the given callable with the given value then return the value.
*
* @param callable|null $callable
* @param mixed $value
* @param callable|null $callback
* @return mixed
*/
protected function tap(mixed $value, ?callable $callback = null): mixed
{
Expand Down
6 changes: 4 additions & 2 deletions TapObjectAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* Qubus\Inheritance
*
* @link https://github.com/QubusPHP/inheritance
* @copyright 2022 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2022
* @author Joshua Parker <josh@joshuaparker.blog>
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 2.0.1
Expand All @@ -21,7 +22,8 @@ trait TapObjectAware
/**
* Call the given callable with $this object then return the value.
*
* @param callable|null $callable
* @param callable|null $callback
* @return mixed
*/
public function tap(?callable $callback = null): mixed
{
Expand Down
11 changes: 7 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
"authors": [
{
"name": "Joshua Parker",
"email": "josh@joshuaparker.blog"
"email": "joshua@joshuaparker.dev"
}
],
"support": {
"issues": "https://github.com/QubusPHP/inheritance/issues"
},
"require": {
"php": ">=8.1"
"php": ">=8.2"
},
"require-dev": {
"laminas/laminas-coding-standard": "^2.0",
"qubus/qubus-coding-standard": "^1.1",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
Expand All @@ -34,6 +34,9 @@
},
"config": {
"optimize-autoloader": true,
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
110 changes: 2 additions & 108 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,112 +22,6 @@
<file>./TapAware.php</file>
<file>./TapObjectAware.php</file>

<!-- Additional QubusPHP Coding Standard rules. -->

<!-- File names should be lowercased and class names should be uppercase. -->
<rule ref="Generic.Files.LowercasedFilename">
<exclude name="Generic.Files.LowercasedFilename.NotFound"/>
</rule>
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<exclude name="SlevomatCodingStandard.Files.TypeNameMatchesFileName.NoMatchBetweenTypeNameAndFileName"/>
</rule>

<!-- A cast statement MUST NOT be preceeded by a single space. -->
<rule ref="Generic.Formatting.SpaceBeforeCast">
<exclude name="Generic.Formatting.SpaceBeforeCast.NoSpace"/>
</rule>

<!-- The Short array syntax MUST be used-->
<rule ref="Generic.Arrays.DisallowShortArraySyntax">
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found"/>
</rule>

<!-- Opening brace must be on a new line. -->
<rule ref="Generic.Classes.OpeningBraceSameLine">
<exclude name="Generic.Classes.OpeningBraceSameLine.BraceOnNewLine"/>
</rule>

<!-- Opening brace should be on a new line after declaration. -->
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine"/>
</rule>

<!-- Constants true, false and null MUST be lowercase. -->
<rule ref="Generic.PHP.UpperCaseConstant">
<exclude name="Generic.PHP.UpperCaseConstant.Found"/>
</rule>
<rule ref="Generic.PHP.LowerCaseConstant"/>

<!-- There MUST be at least one space on either side of an equals sign used
to assign a value to a variable. In case of a block of related
assignments, more spaces MUST NOT be inserted before the equal sign. -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSame"/>
<properties>
<property name="error" value="true"/>
<property name="maxPadding" value="50"/>
</properties>
</rule>

<!-- Code MUST use an indent of 4 spaces for each indent level, and MUST
NOT use tabs for indenting. If tabs are use, indent with 4 spaces. -->
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="4"/>
<property name="exact" value="true"/>
<property name="tabIndent" value="true"/>
<property name="--tab-width" value="4"/>
</properties>
</rule>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent">
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed"/>
</rule>

<!-- Abstract classes MUST NOT have an `Abstract` prefix/suffix. -->
<rule ref="WebimpressCodingStandard.NamingConventions.AbstractClass">
<exclude name="WebimpressCodingStandard.NamingConventions.AbstractClass.Prefix"/>
<exclude name="WebimpressCodingStandard.NamingConventions.AbstractClass.Suffix"/>
</rule>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>

<!-- Exception classes MUST have an `Exception` suffix. -->
<rule ref="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming">
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix"/>
</rule>
<rule ref="WebimpressCodingStandard.NamingConventions.Exception"/>

<!-- Interface classes MUST NOT have an `Interface` prefix/suffix. -->
<rule ref="WebimpressCodingStandard.NamingConventions.Interface">
<exclude name="WebimpressCodingStandard.NamingConventions.Interface.Prefix"/>
<exclude name="WebimpressCodingStandard.NamingConventions.Interface.Suffix"/>
</rule>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>

<!-- Trait classes MUST NOT have a `Trait` prefix/suffix. -->
<rule ref="WebimpressCodingStandard.NamingConventions.Trait">
<exclude name="WebimpressCodingStandard.NamingConventions.Trait.Prefix"/>
<exclude name="WebimpressCodingStandard.NamingConventions.Trait.Suffix"/>
</rule>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousTraitNaming"/>

<!-- The Yoda comparison CAN be used. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison">
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison.DisallowedYodaComparison"/>
</rule>

<!-- @author and @copyright Annotations can be used. -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<exclude name="SlevomatCodingStandard.Commenting.ForbiddenAnnotations"/>
</rule>

<!-- File names should be lowercased and class names should be uppercase. -->
<rule ref="Generic.Files.LowercasedFilename">
<exclude name="Generic.Files.LowercasedFilename.NotFound"/>
</rule>
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<exclude name="SlevomatCodingStandard.Files.TypeNameMatchesFileName.NoMatchBetweenTypeNameAndFileName"/>
</rule>

<!-- Include the rest of the rules from the Laminas Coding Standard -->
<rule ref="LaminasCodingStandard"/>
<!-- Include rules from the Qubus Coding Standard -->
<rule ref="QubusCodingStandard"/>
</ruleset>

0 comments on commit 2bda10c

Please sign in to comment.