Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added PHP 8.0 support #19

Merged
merged 4 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Continuous Integration"

on:
pull_request:
push:
branches:
- '[0-9]+.[0-9]+.x'
- 'refs/pull/*'
tags:

jobs:
matrix:
name: Generate job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Gather CI configuration
id: matrix
uses: laminas/laminas-ci-matrix-action@v1

qa:
name: QA Checks
needs: [matrix]
runs-on: ${{ matrix.operatingSystem }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
steps:
- name: ${{ matrix.name }}
uses: laminas/laminas-continuous-integration-action@v1
with:
job: ${{ matrix.job }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
/laminas-mkdoc-theme/
/phpunit.xml
/vendor/
/.phpcs-cache
/.phpunit.result.cache
73 changes: 0 additions & 73 deletions .travis.yml

This file was deleted.

7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@
"class": "Laminas\\SkeletonInstaller\\Plugin"
},
"require": {
"php": "^5.6 || ^7.0",
"php": "^7.3 || ~8.0.0",
"composer-plugin-api": "^1.0 || ^2.0",
"laminas/laminas-component-installer": "^1.0 || ^2.1.2",
"laminas/laminas-zendframework-bridge": "^1.0"
},
"require-dev": {
"composer/composer": "^1.5.2 || ~2.0.0.0@dev || ^2.0",
"laminas/laminas-coding-standard": "~1.0.0",
"laminas/laminas-coding-standard": "^2.1",
"malukenho/docheader": "^0.1.7",
"mikey179/vfsstream": "^1.6.7",
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.4"
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.3"
},
"autoload": {
"psr-4": {
Expand Down
18 changes: 15 additions & 3 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
<?xml version="1.0"?>
<ruleset name="Laminas coding standard">
<rule ref="./vendor/laminas/laminas-coding-standard/ruleset.xml"/>
<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>
</ruleset>

<!-- Include all rules from the Laminas Coding Standard -->
<rule ref="LaminasCodingStandard"/>
</ruleset>
22 changes: 11 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="laminas-skeleton-installer Tests">
<directory>./test</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="laminas-skeleton-installer Tests">
<directory>./test</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
9 changes: 7 additions & 2 deletions src/BroadcastEventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Composer\IO\IOInterface;
use Composer\Util\ProcessExecutor;

use function in_array;

class BroadcastEventDispatcher extends EventDispatcher
{
/** @var null|EventDispatcher */
Expand All @@ -29,8 +31,8 @@ class BroadcastEventDispatcher extends EventDispatcher
public function __construct(
Composer $composer,
IOInterface $io,
ProcessExecutor $process = null,
EventDispatcher $eventDispatcher = null,
?ProcessExecutor $process = null,
?EventDispatcher $eventDispatcher = null,
array $broadcastEvents = []
) {
parent::__construct($composer, $io, $process);
Expand All @@ -39,6 +41,9 @@ public function __construct(
$this->broadcastEvents = $broadcastEvents;
}

/**
* @inheritDoc
*/
protected function doDispatch(Event $event)
{
if ($this->eventDispatcher && in_array($event->getName(), $this->broadcastEvents, true)) {
Expand Down
17 changes: 8 additions & 9 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
use OutOfRangeException;
use Traversable;

use function array_key_exists;
use function count;
use function is_array;
use function iterator_to_array;
use function sprintf;

class Collection implements
ArrayAccess,
Countable,
IteratorAggregate
{
/**
* @param array
*/
/** @var array */
protected $items;

/**
Expand All @@ -46,7 +50,7 @@ public function __construct($items)
/**
* Factory method
*
* @param array|Traversable
* @param array|Traversable $items
* @return static
*/
public static function create($items)
Expand All @@ -67,7 +71,6 @@ public function toArray()
/**
* Apply a callback to each item in the collection.
*
* @param callable $callback
* @return self
*/
public function each(callable $callback)
Expand All @@ -81,7 +84,6 @@ public function each(callable $callback)
/**
* Reduce the collection to a single value.
*
* @param callable $callback
* @param mixed $initial Initial value.
* @return mixed
*/
Expand All @@ -101,7 +103,6 @@ public function reduce(callable $callback, $initial = null)
*
* Filter callback should return true for values to keep.
*
* @param callable $callback
* @return static
*/
public function filter(callable $callback)
Expand All @@ -119,7 +120,6 @@ public function filter(callable $callback)
*
* Filter callback should return true for values to reject.
*
* @param callable $callback
* @return static
*/
public function reject(callable $callback)
Expand All @@ -137,7 +137,6 @@ public function reject(callable $callback)
*
* Callback should return the new value to use.
*
* @param callable $callback
* @return static
*/
public function map(callable $callback)
Expand Down
6 changes: 2 additions & 4 deletions src/ComposerJsonRetrievalTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

trait ComposerJsonRetrievalTrait
{
/**
* @var callable Factory to use for returning the composer.json path
*/
/** @var callable Factory to use for returning the composer.json path */
private $composerFileFactory = [Factory::class, 'getComposerFile'];

/**
Expand All @@ -25,7 +23,7 @@ trait ComposerJsonRetrievalTrait
*/
private function getComposerJson()
{
$composerFile = call_user_func($this->composerFileFactory);
$composerFile = ($this->composerFileFactory)();
return new JsonFile($composerFile);
}
}
29 changes: 17 additions & 12 deletions src/OptionalPackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,30 @@

namespace Laminas\SkeletonInstaller;

use function array_key_exists;

class OptionalPackage
{
/** @var string */
private $constraint;

/** @var bool */
private $dev = false;

/** @var bool */
private $module = false;

/** @var string*/
private $name;

/** @var string */
private $prompt;

public function __construct(array $spec)
{
$this->constraint = $spec['constraint'];
$this->name = $spec['name'];
$this->prompt = $spec['prompt'];
$this->name = $spec['name'];
$this->prompt = $spec['prompt'];

if (array_key_exists('dev', $spec)) {
$this->dev = (bool) $spec['dev'];
Expand All @@ -35,36 +42,34 @@ public function __construct(array $spec)
}
}

public static function isValidSpec(array $spec)
public static function isValidSpec(array $spec): bool
{
return (
array_key_exists('name', $spec)
return array_key_exists('name', $spec)
&& array_key_exists('constraint', $spec)
&& array_key_exists('prompt', $spec)
);
&& array_key_exists('prompt', $spec);
}

public function getName()
public function getName(): string
{
return $this->name;
}

public function getPrompt()
public function getPrompt(): string
{
return $this->prompt;
}

public function getConstraint()
public function getConstraint(): string
{
return $this->constraint;
}

public function isDev()
public function isDev(): bool
{
return $this->dev;
}

public function isModule()
public function isModule(): bool
{
return $this->module;
}
Expand Down
Loading