Skip to content

Commit

Permalink
Merge pull request #7 from weierophinney/feature/php-8.1-support
Browse files Browse the repository at this point in the history
Provide PHP 8.1 support
  • Loading branch information
weierophinney authored Dec 2, 2021
2 parents 2557446 + 9149aa3 commit 570b206
Show file tree
Hide file tree
Showing 34 changed files with 817 additions and 630 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.phpcs-cache
/.phpunit.result.cache
/clover.xml
/coveralls-upload.json
Expand Down
17 changes: 8 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
"sort-packages": true
},
"require": {
"php": "^7.3 || ~8.0.0",
"laminas/laminas-escaper": "^2.7",
"laminas/laminas-stdlib": "^3.3",
"laminas/laminas-zendframework-bridge": "^1.0"
"php": "^7.4 || ~8.0.0 || ~8.1.0",
"laminas/laminas-escaper": "^2.9",
"laminas/laminas-stdlib": "^3.6"
},
"require-dev": {
"laminas/laminas-coding-standard": "~1.0.0",
"laminas/laminas-servicemanager": "^3.4.1",
"phpunit/phpunit": "^9.3"
"laminas/laminas-coding-standard": "~2.3",
"laminas/laminas-servicemanager": "^3.8",
"phpunit/phpunit": "^9.5.5"
},
"suggest": {
"laminas/laminas-servicemanager": "Laminas\\ServiceManager component"
Expand All @@ -52,7 +51,7 @@
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
},
"replace": {
"zendframework/zend-tag": "^2.7.1"
"conflict": {
"zendframework/zend-tag": "*"
}
}
690 changes: 425 additions & 265 deletions composer.lock

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
<?xml version="1.0"?>
<ruleset name="Laminas coding standard">
<rule ref="./vendor/laminas/laminas-coding-standard/ruleset.xml"/>
<?xml version="1.0"?>
<ruleset
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">

<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>

<!-- Show progress -->
<arg value="p"/>

<!-- Paths to check -->
<file>src</file>
<file>test</file>

<!-- Include all rules from Laminas Coding Standard -->
<rule ref="LaminasCodingStandard"/>
</ruleset>
22 changes: 12 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
convertDeprecationsToExceptions="true"
colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>

<testsuites>
<testsuite name="laminas-tag Test Suite">
<directory>./test</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
70 changes: 40 additions & 30 deletions src/Cloud.php
Original file line number Diff line number Diff line change
@@ -1,48 +1,60 @@
<?php

/**
* @see https://github.com/laminas/laminas-tag for the canonical source repository
* @copyright https://github.com/laminas/laminas-tag/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-tag/blob/master/LICENSE.md New BSD License
*/
declare(strict_types=1);

namespace Laminas\Tag;

use Exception;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Stdlib\ArrayUtils;
use Laminas\Tag\Cloud\Decorator\HtmlCloud;
use Laminas\Tag\Cloud\Decorator\HtmlTag;
use Laminas\Tag\Exception\InvalidArgumentException;
use Traversable;

use function count;
use function get_class;
use function gettype;
use function in_array;
use function is_array;
use function is_object;
use function is_string;
use function method_exists;
use function sprintf;
use function strtolower;
use function trigger_error;

use const E_USER_WARNING;

class Cloud
{
/**
* DecoratorInterface for the cloud
*
* @var Cloud\Decorator\AbstractCloud
*/
protected $cloudDecorator = null;
protected $cloudDecorator;

/**
* DecoratorInterface for the tags
*
* @var Cloud\Decorator\AbstractTag
*/
protected $tagDecorator = null;
protected $tagDecorator;

/**
* List of all tags
*
* @var ItemList
*/
protected $tags = null;
protected $tags;

/**
* Plugin manager for decorators
*
* @var Cloud\DecoratorPluginManager
*/
protected $decorators = null;
protected $decorators;

/**
* Option keys to skip when calling setOptions()
Expand Down Expand Up @@ -101,7 +113,7 @@ public function setOptions(array $options)
* decorators.
*
* @param array $tags
* @throws Exception\InvalidArgumentException
* @throws InvalidArgumentException
* @return Cloud
*/
public function setTags(array $tags)
Expand All @@ -116,7 +128,7 @@ public function setTags(array $tags)
* Append a single tag to the cloud
*
* @param TaggableInterface|array $tag
* @throws Exception\InvalidArgumentException
* @throws InvalidArgumentException
* @return Cloud
*/
public function appendTag($tag)
Expand All @@ -129,10 +141,10 @@ public function appendTag($tag)
}

if (! is_array($tag)) {
throw new Exception\InvalidArgumentException(sprintf(
throw new InvalidArgumentException(sprintf(
'Tag must be an instance of %s\TaggableInterface or an array; received "%s"',
__NAMESPACE__,
(is_object($tag) ? get_class($tag) : gettype($tag))
is_object($tag) ? get_class($tag) : gettype($tag)
));
}

Expand All @@ -144,7 +156,6 @@ public function appendTag($tag)
/**
* Set the item list
*
* @param ItemList $itemList
* @return Cloud
*/
public function setItemList(ItemList $itemList)
Expand Down Expand Up @@ -172,7 +183,7 @@ public function getItemList()
* Set the decorator for the cloud
*
* @param mixed $decorator
* @throws Exception\InvalidArgumentException
* @throws InvalidArgumentException
* @return Cloud
*/
public function setCloudDecorator($decorator)
Expand All @@ -193,8 +204,8 @@ public function setCloudDecorator($decorator)
$decorator = $this->getDecoratorPluginManager()->get($decorator, $options);
}

if (! ($decorator instanceof Cloud\Decorator\AbstractCloud)) {
throw new Exception\InvalidArgumentException(
if (! $decorator instanceof Cloud\Decorator\AbstractCloud) {
throw new InvalidArgumentException(
'DecoratorInterface is no instance of Cloud\Decorator\AbstractCloud'
);
}
Expand All @@ -221,7 +232,7 @@ public function getCloudDecorator()
* Set the decorator for the tags
*
* @param mixed $decorator
* @throws Exception\InvalidArgumentException
* @throws InvalidArgumentException
* @return Cloud
*/
public function setTagDecorator($decorator)
Expand All @@ -242,8 +253,8 @@ public function setTagDecorator($decorator)
$decorator = $this->getDecoratorPluginManager()->get($decorator, $options);
}

if (! ($decorator instanceof Cloud\Decorator\AbstractTag)) {
throw new Exception\InvalidArgumentException(
if (! $decorator instanceof Cloud\Decorator\AbstractTag) {
throw new InvalidArgumentException(
'DecoratorInterface is no instance of Cloud\Decorator\AbstractTag'
);
}
Expand All @@ -269,7 +280,6 @@ public function getTagDecorator()
/**
* Set plugin manager for use with decorators
*
* @param Cloud\DecoratorPluginManager $decorators
* @return Cloud
*/
public function setDecoratorPluginManager(Cloud\DecoratorPluginManager $decorators)
Expand Down Expand Up @@ -305,10 +315,8 @@ public function render()
return '';
}

$tagsResult = $this->getTagDecorator()->render($tags);
$cloudResult = $this->getCloudDecorator()->render($tagsResult);

return $cloudResult;
$tagsResult = $this->getTagDecorator()->render($tags);
return $this->getCloudDecorator()->render($tagsResult);
}

/**
Expand All @@ -319,11 +327,13 @@ public function render()
public function __toString()
{
try {
$result = $this->render();
return $result;
} catch (\Exception $e) {
$message = "Exception caught by tag cloud: " . $e->getMessage()
. "\nStack Trace:\n" . $e->getTraceAsString();
return $this->render();
} catch (Exception $e) {
$message = sprintf(
"Exception caught by tag cloud: %s\nStack Trace:\n%s",
$e->getMessage(),
$e->getTraceAsString()
);
trigger_error($message, E_USER_WARNING);
return '';
}
Expand Down
6 changes: 1 addition & 5 deletions src/Cloud/Decorator/AbstractCloud.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?php

/**
* @see https://github.com/laminas/laminas-tag for the canonical source repository
* @copyright https://github.com/laminas/laminas-tag/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-tag/blob/master/LICENSE.md New BSD License
*/
declare(strict_types=1);

namespace Laminas\Tag\Cloud\Decorator;

Expand Down
23 changes: 11 additions & 12 deletions src/Cloud/Decorator/AbstractDecorator.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?php

/**
* @see https://github.com/laminas/laminas-tag for the canonical source repository
* @copyright https://github.com/laminas/laminas-tag/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-tag/blob/master/LICENSE.md New BSD License
*/
declare(strict_types=1);

namespace Laminas\Tag\Cloud\Decorator;

Expand All @@ -14,19 +10,22 @@
use Laminas\Tag\Exception;
use Traversable;

use function in_array;
use function is_array;
use function method_exists;
use function preg_match;
use function sprintf;
use function strtolower;

/**
* Abstract class for decorators
*/
abstract class AbstractDecorator implements Decorator
{
/**
* @var string Encoding to use
*/
/** @var string Encoding to use */
protected $encoding = 'UTF-8';

/**
* @var Escaper
*/
/** @var Escaper */
protected $escaper;

/**
Expand Down Expand Up @@ -89,7 +88,7 @@ public function getEncoding()
/**
* Set encoding
*
* @param string
* @param string $value
* @return HTMLCloud
*/
public function setEncoding($value)
Expand Down
6 changes: 1 addition & 5 deletions src/Cloud/Decorator/AbstractTag.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?php

/**
* @see https://github.com/laminas/laminas-tag for the canonical source repository
* @copyright https://github.com/laminas/laminas-tag/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-tag/blob/master/LICENSE.md New BSD License
*/
declare(strict_types=1);

namespace Laminas\Tag\Cloud\Decorator;

Expand Down
6 changes: 1 addition & 5 deletions src/Cloud/Decorator/DecoratorInterface.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?php

/**
* @see https://github.com/laminas/laminas-tag for the canonical source repository
* @copyright https://github.com/laminas/laminas-tag/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-tag/blob/master/LICENSE.md New BSD License
*/
declare(strict_types=1);

namespace Laminas\Tag\Cloud\Decorator;

Expand Down
6 changes: 1 addition & 5 deletions src/Cloud/Decorator/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?php

/**
* @see https://github.com/laminas/laminas-tag for the canonical source repository
* @copyright https://github.com/laminas/laminas-tag/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-tag/blob/master/LICENSE.md New BSD License
*/
declare(strict_types=1);

namespace Laminas\Tag\Cloud\Decorator\Exception;

Expand Down
6 changes: 1 addition & 5 deletions src/Cloud/Decorator/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?php

/**
* @see https://github.com/laminas/laminas-tag for the canonical source repository
* @copyright https://github.com/laminas/laminas-tag/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-tag/blob/master/LICENSE.md New BSD License
*/
declare(strict_types=1);

namespace Laminas\Tag\Cloud\Decorator\Exception;

Expand Down
Loading

0 comments on commit 570b206

Please sign in to comment.