Skip to content

Commit

Permalink
Fixed coding standard issues
Browse files Browse the repository at this point in the history
  • Loading branch information
divineniiquaye committed Apr 28, 2021
1 parent 9ef09d5 commit 87e64ee
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 104 deletions.
10 changes: 5 additions & 5 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon

parameters:
level: max
level: 4
paths: [src]
treatPhpDocTypesAsCertain: false
checkMissingIterableValueType: false

ignoreErrors:
- "#^Construct empty\\(\\) is not allowed. Use more strict comparison.$#"
-
message: "#^Cannot call method add\\(\\) on DateTime\\|false.$#"
path: src/CacheItem.php
-
message: "#^Strict comparison using !== between false and true will always evaluate to true.$#"
message: "#^Variable \\$deleteItem might not be defined|Variable method call on Psr\\\\Cache\\\\CacheItemPoolInterface\\|Psr\\\\SimpleCache\\\\CacheInterface.$#"
path: src/FastCache.php
-
message: "#^Short ternary operator is not allowed. Use null coalesce operator if applicable or consider using long ternary|Class Symfony\\\\Component\\\\Cache\\\\DoctrineProvider not found.$#"
path: src/AdapterFactory.php
90 changes: 30 additions & 60 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -1,60 +1,30 @@
<?xml version="1.0"?>
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
name="Psalm for PHP Library Starter"
useDocblockTypes="true"
errorLevel="3"
strictBinaryOperands="false"
rememberPropertyAssignmentsAfterCall="true"
checkForThrowsDocblock="false"
throwExceptionOnError="0"
ensureArrayStringOffsetsExist="true"
ensureArrayIntOffsetsExist="false"
resolveFromConfigFile="true"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>

<issueHandlers>
<InaccessibleProperty>
<errorLevel type="suppress">
<file name="src/CacheItemPool.php"/>
</errorLevel>
</InaccessibleProperty>

<PossiblyUndefinedVariable>
<errorLevel type="suppress">
<file name="src/CacheItemPool.php"/>
</errorLevel>
</PossiblyUndefinedVariable>

<PossiblyUndefinedStringArrayOffset>
<errorLevel type="suppress">
<file name="src/LoggableStorage.php"/>
</errorLevel>
</PossiblyUndefinedStringArrayOffset>

<UndefinedClass>
<errorLevel type="suppress">
<file name="src/AdapterFactory.php"/>
</errorLevel>
</UndefinedClass>

<InvalidLiteralArgument>
<errorLevel type="suppress">
<file name="src/AdapterFactory.php"/>
</errorLevel>
</InvalidLiteralArgument>

<RedundantCondition>
<errorLevel type="suppress">
<file name="src/FastCache.php"/>
</errorLevel>
</RedundantCondition>
</issueHandlers>
</psalm>
<?xml version="1.0"?>
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
name="Psalm for PHP Library Starter"
useDocblockTypes="true"
errorLevel="7"
strictBinaryOperands="false"
rememberPropertyAssignmentsAfterCall="true"
checkForThrowsDocblock="false"
throwExceptionOnError="0"
ensureArrayStringOffsetsExist="true"
ensureArrayIntOffsetsExist="false"
resolveFromConfigFile="true"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>

<issueHandlers>
<UndefinedClass>
<errorLevel type="suppress">
<file name="src/AdapterFactory.php"/>
</errorLevel>
</UndefinedClass>
</issueHandlers>
</psalm>
4 changes: 2 additions & 2 deletions src/AdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static function createHandler($connection): CacheItemPoolInterface
/**
* @param mixed $adapter
*
* @return \Redis|\Memcache|\Memcached|DoctrineCache|null
* @return \Redis|\Memcache|\Memcached|DoctrineCache\Cache|null
*/
private static function getPrefixedAdapter(string $connection, $adapter)
{
Expand All @@ -119,7 +119,7 @@ private static function getPrefixedAdapter(string $connection, $adapter)

case 'Memcache':
case 'Memcache':
/** @var \Memcache|\Memcached */
/** @var \Memcache|\Memcached $adapter */
($adapter = new $connectionServer())->addServer($host, $port ?? 11211);

break;
Expand Down
13 changes: 1 addition & 12 deletions src/FastCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ public function derive(string $namespace): self
/**
* Reads the specified item from the cache or generate it.
*
* @param mixed $key
*
* @return mixed
*/
public function load(string $key, callable $fallback = null, ?float $beta = null)
Expand Down Expand Up @@ -152,9 +150,6 @@ static function (CacheItemInterface $item) use ($key, $fallback) {
/**
* Writes an item into the cache.
*
* @param mixed $key
* @param callable|null $callback
*
* @return mixed value itself
*/
public function save(string $key, callable $callback, ?float $beta = null)
Expand All @@ -172,8 +167,6 @@ public function save(string $key, callable $callback, ?float $beta = null)

/**
* Remove an item from the cache.
*
* @param mixed $key
*/
public function delete(string $key): bool
{
Expand Down Expand Up @@ -206,8 +199,6 @@ static function (CacheItemInterface $item) use ($callback, $key) {
*
* @see {@call}
*
* @param float|null $beta
*
* @return callable so arguments can be passed into for final results
*/
public function wrap(callable $callback /* ... arguments passed to $callback */): callable
Expand All @@ -219,10 +210,8 @@ public function wrap(callable $callback /* ... arguments passed to $callback */)

/**
* Starts the output cache.
*
* @param mixed $key
*/
public function start($key): ?OutputHelper
public function start(string $key): ?OutputHelper
{
$data = $this->load($key);

Expand Down
50 changes: 25 additions & 25 deletions tests/FastCacheTest.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?php

declare(strict_types=1);

/*
* This file is part of Biurad opensource projects.
*
* PHP version 7.1 and above required
*
* @author Divine Niiquaye Ibok <divineibok@gmail.com>
* @copyright 2019 Biurad Group (https://biurad.com/)
* @license https://opensource.org/licenses/BSD-3-Clause License
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Biurad\Cache\Tests;

use Biurad\Cache\FastCache;
use PHPUnit\Framework\TestCase;

class FastCacheTest extends TestCase
{
}
<?php

declare(strict_types=1);

/*
* This file is part of Biurad opensource projects.
*
* PHP version 7.1 and above required
*
* @author Divine Niiquaye Ibok <divineibok@gmail.com>
* @copyright 2019 Biurad Group (https://biurad.com/)
* @license https://opensource.org/licenses/BSD-3-Clause License
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Biurad\Cache\Tests;

use Biurad\Cache\FastCache;
use PHPUnit\Framework\TestCase;

class FastCacheTest extends TestCase
{
}

0 comments on commit 87e64ee

Please sign in to comment.