laravel-6 support
This commit is contained in:
7
vendor/phar-io/manifest/.gitignore
vendored
7
vendor/phar-io/manifest/.gitignore
vendored
@@ -1,7 +0,0 @@
|
||||
/.idea
|
||||
/.php_cs.cache
|
||||
/src/autoload.php
|
||||
/tools
|
||||
/vendor
|
||||
|
||||
/build
|
67
vendor/phar-io/manifest/.php_cs
vendored
67
vendor/phar-io/manifest/.php_cs
vendored
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
$finder = Symfony\CS\Finder\DefaultFinder::create()
|
||||
->files()
|
||||
->in('src')
|
||||
->in('tests')
|
||||
->name('*.php');
|
||||
|
||||
return Symfony\CS\Config\Config::create()
|
||||
->setUsingCache(true)
|
||||
->level(\Symfony\CS\FixerInterface::NONE_LEVEL)
|
||||
->fixers(
|
||||
array(
|
||||
'align_double_arrow',
|
||||
'align_equals',
|
||||
'concat_with_spaces',
|
||||
'duplicate_semicolon',
|
||||
'elseif',
|
||||
'empty_return',
|
||||
'encoding',
|
||||
'eof_ending',
|
||||
'extra_empty_lines',
|
||||
'function_call_space',
|
||||
'function_declaration',
|
||||
'indentation',
|
||||
'join_function',
|
||||
'line_after_namespace',
|
||||
'linefeed',
|
||||
'list_commas',
|
||||
'lowercase_constants',
|
||||
'lowercase_keywords',
|
||||
'method_argument_space',
|
||||
'multiple_use',
|
||||
'namespace_no_leading_whitespace',
|
||||
'no_blank_lines_after_class_opening',
|
||||
'no_empty_lines_after_phpdocs',
|
||||
'parenthesis',
|
||||
'php_closing_tag',
|
||||
'phpdoc_indent',
|
||||
'phpdoc_no_access',
|
||||
'phpdoc_no_empty_return',
|
||||
'phpdoc_no_package',
|
||||
'phpdoc_params',
|
||||
'phpdoc_scalar',
|
||||
'phpdoc_separation',
|
||||
'phpdoc_to_comment',
|
||||
'phpdoc_trim',
|
||||
'phpdoc_types',
|
||||
'phpdoc_var_without_name',
|
||||
'remove_lines_between_uses',
|
||||
'return',
|
||||
'self_accessor',
|
||||
'short_array_syntax',
|
||||
'short_tag',
|
||||
'single_line_after_imports',
|
||||
'single_quote',
|
||||
'spaces_before_semicolon',
|
||||
'spaces_cast',
|
||||
'ternary_spaces',
|
||||
'trailing_spaces',
|
||||
'trim_array_spaces',
|
||||
'unused_use',
|
||||
'visibility',
|
||||
'whitespacy_lines'
|
||||
)
|
||||
)
|
||||
->finder($finder);
|
||||
|
33
vendor/phar-io/manifest/.travis.yml
vendored
33
vendor/phar-io/manifest/.travis.yml
vendored
@@ -1,33 +0,0 @@
|
||||
os:
|
||||
- linux
|
||||
|
||||
language: php
|
||||
|
||||
before_install:
|
||||
- wget https://phar.io/releases/phive.phar
|
||||
- wget https://phar.io/releases/phive.phar.asc
|
||||
- gpg --keyserver hkps.pool.sks-keyservers.net --recv-keys 0x9B2D5D79
|
||||
- gpg --verify phive.phar.asc phive.phar
|
||||
- chmod +x phive.phar
|
||||
- sudo mv phive.phar /usr/bin/phive
|
||||
|
||||
install:
|
||||
- ant setup
|
||||
|
||||
script: ./tools/phpunit
|
||||
|
||||
php:
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.0snapshot
|
||||
- 7.1snapshot
|
||||
- master
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: master
|
||||
fast_finish: true
|
||||
|
||||
notifications:
|
||||
email: false
|
36
vendor/phar-io/manifest/CHANGELOG.md
vendored
Normal file
36
vendor/phar-io/manifest/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to phar-io/manifest are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
|
||||
|
||||
## [2.0.3] - 20.07.2021
|
||||
|
||||
- Fixed PHP 7.2 / PHP 7.3 incompatibility introduced in previous release
|
||||
|
||||
## [2.0.2] - 20.07.2021
|
||||
|
||||
- Fixed PHP 8.1 deprecation notice
|
||||
|
||||
## [2.0.1] - 27.06.2020
|
||||
|
||||
This release now supports the use of PHP 7.2+ and ^8.0
|
||||
|
||||
## [2.0.0] - 10.05.2020
|
||||
|
||||
This release now requires PHP 7.2+
|
||||
|
||||
### Changed
|
||||
|
||||
- Upgraded to phar-io/version 3.0
|
||||
- Version strings `v1.2.3` will now be converted to valid semantic version strings `1.2.3`
|
||||
- Abreviated strings like `1.0` will get expaneded to `1.0.0`
|
||||
|
||||
### Unreleased
|
||||
|
||||
[Unreleased]: https://github.com/phar-io/manifest/compare/2.0.3...HEAD
|
||||
[2.0.3]: https://github.com/phar-io/manifest/compare/2.0.2...2.0.3
|
||||
[2.0.2]: https://github.com/phar-io/manifest/compare/2.0.1...2.0.2
|
||||
[2.0.1]: https://github.com/phar-io/manifest/compare/2.0.0...2.0.1
|
||||
[2.0.0]: https://github.com/phar-io/manifest/compare/1.0.1...2.0.0
|
||||
[1.0.3]: https://github.com/phar-io/manifest/compare/1.0.2...1.0.3
|
||||
[1.0.2]: https://github.com/phar-io/manifest/compare/1.0.1...1.0.2
|
||||
[1.0.1]: https://github.com/phar-io/manifest/compare/1.0.0...1.0.1
|
4
vendor/phar-io/manifest/LICENSE
vendored
4
vendor/phar-io/manifest/LICENSE
vendored
@@ -1,6 +1,6 @@
|
||||
manifest
|
||||
Phar.io - Manifest
|
||||
|
||||
Copyright (c) 2016 Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>, and contributors
|
||||
Copyright (c) 2016-2019 Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>, and contributors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
|
50
vendor/phar-io/manifest/build.xml
vendored
50
vendor/phar-io/manifest/build.xml
vendored
@@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="manifest" default="setup">
|
||||
<target name="setup" depends="clean,install-tools,install-dependencies"/>
|
||||
|
||||
<target name="clean" unless="clean.done" description="Cleanup build artifacts">
|
||||
<delete dir="${basedir}/tools"/>
|
||||
<delete dir="${basedir}/vendor"/>
|
||||
<delete file="${basedir}/src/autoload.php"/>
|
||||
|
||||
<property name="clean.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="prepare" unless="prepare.done" depends="clean" description="Prepare for build">
|
||||
<property name="prepare.done" value="true"/>
|
||||
</target>
|
||||
|
||||
<target name="install-dependencies" unless="dependencies-installed" depends="-dependencies-installed" description="Install dependencies with Composer">
|
||||
<exec executable="composer" taskname="composer">
|
||||
<env key="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
|
||||
<arg value="update"/>
|
||||
<arg value="--no-interaction"/>
|
||||
<arg value="--no-progress"/>
|
||||
<arg value="--no-ansi"/>
|
||||
<arg value="--no-suggest"/>
|
||||
<arg value="--optimize-autoloader"/>
|
||||
<arg value="--prefer-stable"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="install-tools" unless="tools-installed" depends="-tools-installed" description="Install tools with Phive">
|
||||
<exec executable="phive" taskname="phive">
|
||||
<arg value="install"/>
|
||||
<arg value="--trust-gpg-keys" />
|
||||
<arg value="4AA394086372C20A,2A8299CE842DD38C" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="test" depends="install-tools,install-dependencies" description="Run tests">
|
||||
<exec executable="${basedir}/tools/phpunit" taskname="phpunit"/>
|
||||
</target>
|
||||
|
||||
<target name="-dependencies-installed">
|
||||
<available file="${basedir}/composer.lock" property="dependencies-installed"/>
|
||||
</target>
|
||||
|
||||
<target name="-tools-installed">
|
||||
<available file="${basedir}/tools" property="tools-installed" type="dir"/>
|
||||
</target>
|
||||
</project>
|
||||
|
8
vendor/phar-io/manifest/composer.json
vendored
8
vendor/phar-io/manifest/composer.json
vendored
@@ -23,10 +23,11 @@
|
||||
"issues": "https://github.com/phar-io/manifest/issues"
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.6 || ^7.0",
|
||||
"php": "^7.2 || ^8.0",
|
||||
"ext-dom": "*",
|
||||
"ext-phar": "*",
|
||||
"phar-io/version": "^2.0"
|
||||
"ext-xmlwriter": "*",
|
||||
"phar-io/version": "^3.0.1"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
@@ -35,8 +36,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
21
vendor/phar-io/manifest/composer.lock
generated
vendored
21
vendor/phar-io/manifest/composer.lock
generated
vendored
@@ -1,27 +1,27 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "f00846dde236d314a19d00d268d737dd",
|
||||
"content-hash": "f2ac4614ce4f7273fd54a64b65fd047a",
|
||||
"packages": [
|
||||
{
|
||||
"name": "phar-io/version",
|
||||
"version": "2.0.1",
|
||||
"version": "3.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phar-io/version.git",
|
||||
"reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6"
|
||||
"reference": "d06a5000ac1a258a7d035295f0bd4ae7c859bc4f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6",
|
||||
"reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6",
|
||||
"url": "https://api.github.com/repos/phar-io/version/zipball/d06a5000ac1a258a7d035295f0bd4ae7c859bc4f",
|
||||
"reference": "d06a5000ac1a258a7d035295f0bd4ae7c859bc4f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.6 || ^7.0"
|
||||
"php": "^7.2"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
@@ -51,7 +51,7 @@
|
||||
}
|
||||
],
|
||||
"description": "Library for handling version information and constraints",
|
||||
"time": "2018-07-08T19:19:57+00:00"
|
||||
"time": "2020-05-09T21:27:55+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
@@ -61,9 +61,10 @@
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"php": "^5.6 || ^7.0",
|
||||
"php": "^7.2",
|
||||
"ext-dom": "*",
|
||||
"ext-phar": "*"
|
||||
"ext-phar": "*",
|
||||
"ext-xmlwriter": "*"
|
||||
},
|
||||
"platform-dev": []
|
||||
}
|
||||
|
23
vendor/phar-io/manifest/examples/example-01.php
vendored
23
vendor/phar-io/manifest/examples/example-01.php
vendored
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use PharIo\Manifest\ManifestLoader;
|
||||
use PharIo\Manifest\ManifestSerializer;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$manifest = ManifestLoader::fromFile(__DIR__ . '/../tests/_fixture/phpunit-5.6.5.xml');
|
||||
|
||||
echo sprintf(
|
||||
"Manifest for %s (%s):\n\n",
|
||||
$manifest->getName(),
|
||||
$manifest->getVersion()->getVersionString()
|
||||
);
|
||||
echo (new ManifestSerializer)->serializeToString($manifest);
|
4
vendor/phar-io/manifest/phive.xml
vendored
4
vendor/phar-io/manifest/phive.xml
vendored
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phive xmlns="https://phar.io/phive">
|
||||
<phar name="phpunit" version="^5.7" installed="5.7.15" location="./tools/phpunit"/>
|
||||
</phive>
|
20
vendor/phar-io/manifest/phpunit.xml
vendored
20
vendor/phar-io/manifest/phpunit.xml
vendored
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.6/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
backupGlobals="false"
|
||||
beStrictAboutCoversAnnotation="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
beStrictAboutTestsThatDoNotTestAnything="true"
|
||||
beStrictAboutTodoAnnotatedTests="true"
|
||||
verbose="true">
|
||||
<testsuite>
|
||||
<directory suffix="Test.php">tests</directory>
|
||||
</testsuite>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,22 +7,14 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\Version;
|
||||
use PharIo\Version\Exception as VersionException;
|
||||
use PharIo\Version\Version;
|
||||
use PharIo\Version\VersionConstraintParser;
|
||||
|
||||
class ManifestDocumentMapper {
|
||||
/**
|
||||
* @param ManifestDocument $document
|
||||
*
|
||||
* @returns Manifest
|
||||
*
|
||||
* @throws ManifestDocumentMapperException
|
||||
*/
|
||||
public function map(ManifestDocument $document) {
|
||||
public function map(ManifestDocument $document): Manifest {
|
||||
try {
|
||||
$contains = $document->getContainsElement();
|
||||
$type = $this->mapType($contains);
|
||||
@@ -39,20 +31,13 @@ class ManifestDocumentMapper {
|
||||
$bundledComponents
|
||||
);
|
||||
} catch (VersionException $e) {
|
||||
throw new ManifestDocumentMapperException($e->getMessage(), $e->getCode(), $e);
|
||||
throw new ManifestDocumentMapperException($e->getMessage(), (int)$e->getCode(), $e);
|
||||
} catch (Exception $e) {
|
||||
throw new ManifestDocumentMapperException($e->getMessage(), $e->getCode(), $e);
|
||||
throw new ManifestDocumentMapperException($e->getMessage(), (int)$e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainsElement $contains
|
||||
*
|
||||
* @return Type
|
||||
*
|
||||
* @throws ManifestDocumentMapperException
|
||||
*/
|
||||
private function mapType(ContainsElement $contains) {
|
||||
private function mapType(ContainsElement $contains): Type {
|
||||
switch ($contains->getType()) {
|
||||
case 'application':
|
||||
return Type::application();
|
||||
@@ -63,22 +48,14 @@ class ManifestDocumentMapper {
|
||||
}
|
||||
|
||||
throw new ManifestDocumentMapperException(
|
||||
sprintf('Unsupported type %s', $contains->getType())
|
||||
\sprintf('Unsupported type %s', $contains->getType())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CopyrightElement $copyright
|
||||
*
|
||||
* @return CopyrightInformation
|
||||
*
|
||||
* @throws InvalidUrlException
|
||||
* @throws InvalidEmailException
|
||||
*/
|
||||
private function mapCopyright(CopyrightElement $copyright) {
|
||||
private function mapCopyright(CopyrightElement $copyright): CopyrightInformation {
|
||||
$authors = new AuthorCollection();
|
||||
|
||||
foreach($copyright->getAuthorElements() as $authorElement) {
|
||||
foreach ($copyright->getAuthorElements() as $authorElement) {
|
||||
$authors->add(
|
||||
new Author(
|
||||
$authorElement->getName(),
|
||||
@@ -99,14 +76,7 @@ class ManifestDocumentMapper {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RequiresElement $requires
|
||||
*
|
||||
* @return RequirementCollection
|
||||
*
|
||||
* @throws ManifestDocumentMapperException
|
||||
*/
|
||||
private function mapRequirements(RequiresElement $requires) {
|
||||
private function mapRequirements(RequiresElement $requires): RequirementCollection {
|
||||
$collection = new RequirementCollection();
|
||||
$phpElement = $requires->getPHPElement();
|
||||
$parser = new VersionConstraintParser;
|
||||
@@ -115,8 +85,8 @@ class ManifestDocumentMapper {
|
||||
$versionConstraint = $parser->parse($phpElement->getVersion());
|
||||
} catch (VersionException $e) {
|
||||
throw new ManifestDocumentMapperException(
|
||||
sprintf('Unsupported version constraint - %s', $e->getMessage()),
|
||||
$e->getCode(),
|
||||
\sprintf('Unsupported version constraint - %s', $e->getMessage()),
|
||||
(int)$e->getCode(),
|
||||
$e
|
||||
);
|
||||
}
|
||||
@@ -131,7 +101,7 @@ class ManifestDocumentMapper {
|
||||
return $collection;
|
||||
}
|
||||
|
||||
foreach($phpElement->getExtElements() as $extElement) {
|
||||
foreach ($phpElement->getExtElements() as $extElement) {
|
||||
$collection->add(
|
||||
new PhpExtensionRequirement($extElement->getName())
|
||||
);
|
||||
@@ -140,19 +110,14 @@ class ManifestDocumentMapper {
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ManifestDocument $document
|
||||
*
|
||||
* @return BundledComponentCollection
|
||||
*/
|
||||
private function mapBundledComponents(ManifestDocument $document) {
|
||||
private function mapBundledComponents(ManifestDocument $document): BundledComponentCollection {
|
||||
$collection = new BundledComponentCollection();
|
||||
|
||||
if (!$document->hasBundlesElement()) {
|
||||
return $collection;
|
||||
}
|
||||
|
||||
foreach($document->getBundlesElement()->getComponentElements() as $componentElement) {
|
||||
foreach ($document->getBundlesElement()->getComponentElements() as $componentElement) {
|
||||
$collection->add(
|
||||
new BundledComponent(
|
||||
$componentElement->getName(),
|
||||
@@ -166,17 +131,9 @@ class ManifestDocumentMapper {
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ExtensionElement $extension
|
||||
*
|
||||
* @return Extension
|
||||
*
|
||||
* @throws ManifestDocumentMapperException
|
||||
*/
|
||||
private function mapExtension(ExtensionElement $extension) {
|
||||
private function mapExtension(ExtensionElement $extension): Extension {
|
||||
try {
|
||||
$parser = new VersionConstraintParser;
|
||||
$versionConstraint = $parser->parse($extension->getCompatible());
|
||||
$versionConstraint = (new VersionConstraintParser)->parse($extension->getCompatible());
|
||||
|
||||
return Type::extension(
|
||||
new ApplicationName($extension->getFor()),
|
||||
@@ -184,8 +141,8 @@ class ManifestDocumentMapper {
|
||||
);
|
||||
} catch (VersionException $e) {
|
||||
throw new ManifestDocumentMapperException(
|
||||
sprintf('Unsupported version constraint - %s', $e->getMessage()),
|
||||
$e->getCode(),
|
||||
\sprintf('Unsupported version constraint - %s', $e->getMessage()),
|
||||
(int)$e->getCode(),
|
||||
$e
|
||||
);
|
||||
}
|
||||
|
36
vendor/phar-io/manifest/src/ManifestLoader.php
vendored
36
vendor/phar-io/manifest/src/ManifestLoader.php
vendored
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,50 +7,28 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ManifestLoader {
|
||||
/**
|
||||
* @param string $filename
|
||||
*
|
||||
* @return Manifest
|
||||
*
|
||||
* @throws ManifestLoaderException
|
||||
*/
|
||||
public static function fromFile($filename) {
|
||||
public static function fromFile(string $filename): Manifest {
|
||||
try {
|
||||
return (new ManifestDocumentMapper())->map(
|
||||
ManifestDocument::fromFile($filename)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
throw new ManifestLoaderException(
|
||||
sprintf('Loading %s failed.', $filename),
|
||||
$e->getCode(),
|
||||
\sprintf('Loading %s failed.', $filename),
|
||||
(int)$e->getCode(),
|
||||
$e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
*
|
||||
* @return Manifest
|
||||
*
|
||||
* @throws ManifestLoaderException
|
||||
*/
|
||||
public static function fromPhar($filename) {
|
||||
public static function fromPhar(string $filename): Manifest {
|
||||
return self::fromFile('phar://' . $filename . '/manifest.xml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $manifest
|
||||
*
|
||||
* @return Manifest
|
||||
*
|
||||
* @throws ManifestLoaderException
|
||||
*/
|
||||
public static function fromString($manifest) {
|
||||
public static function fromString(string $manifest): Manifest {
|
||||
try {
|
||||
return (new ManifestDocumentMapper())->map(
|
||||
ManifestDocument::fromString($manifest)
|
||||
@@ -58,7 +36,7 @@ class ManifestLoader {
|
||||
} catch (Exception $e) {
|
||||
throw new ManifestLoaderException(
|
||||
'Processing string failed',
|
||||
$e->getCode(),
|
||||
(int)$e->getCode(),
|
||||
$e
|
||||
);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\AnyVersionConstraint;
|
||||
@@ -15,20 +14,19 @@ use PharIo\Version\Version;
|
||||
use PharIo\Version\VersionConstraint;
|
||||
use XMLWriter;
|
||||
|
||||
/** @psalm-suppress MissingConstructor */
|
||||
class ManifestSerializer {
|
||||
/**
|
||||
* @var XMLWriter
|
||||
*/
|
||||
/** @var XMLWriter */
|
||||
private $xmlWriter;
|
||||
|
||||
public function serializeToFile(Manifest $manifest, $filename) {
|
||||
file_put_contents(
|
||||
public function serializeToFile(Manifest $manifest, string $filename): void {
|
||||
\file_put_contents(
|
||||
$filename,
|
||||
$this->serializeToString($manifest)
|
||||
);
|
||||
}
|
||||
|
||||
public function serializeToString(Manifest $manifest) {
|
||||
public function serializeToString(Manifest $manifest): string {
|
||||
$this->startDocument();
|
||||
|
||||
$this->addContains($manifest->getName(), $manifest->getVersion(), $manifest->getType());
|
||||
@@ -39,11 +37,11 @@ class ManifestSerializer {
|
||||
return $this->finishDocument();
|
||||
}
|
||||
|
||||
private function startDocument() {
|
||||
private function startDocument(): void {
|
||||
$xmlWriter = new XMLWriter();
|
||||
$xmlWriter->openMemory();
|
||||
$xmlWriter->setIndent(true);
|
||||
$xmlWriter->setIndentString(str_repeat(' ', 4));
|
||||
$xmlWriter->setIndentString(\str_repeat(' ', 4));
|
||||
$xmlWriter->startDocument('1.0', 'UTF-8');
|
||||
$xmlWriter->startElement('phar');
|
||||
$xmlWriter->writeAttribute('xmlns', 'https://phar.io/xml/manifest/1.0');
|
||||
@@ -51,33 +49,39 @@ class ManifestSerializer {
|
||||
$this->xmlWriter = $xmlWriter;
|
||||
}
|
||||
|
||||
private function finishDocument() {
|
||||
private function finishDocument(): string {
|
||||
$this->xmlWriter->endElement();
|
||||
$this->xmlWriter->endDocument();
|
||||
|
||||
return $this->xmlWriter->outputMemory();
|
||||
}
|
||||
|
||||
private function addContains($name, Version $version, Type $type) {
|
||||
private function addContains(ApplicationName $name, Version $version, Type $type): void {
|
||||
$this->xmlWriter->startElement('contains');
|
||||
$this->xmlWriter->writeAttribute('name', $name);
|
||||
$this->xmlWriter->writeAttribute('name', $name->asString());
|
||||
$this->xmlWriter->writeAttribute('version', $version->getVersionString());
|
||||
|
||||
switch (true) {
|
||||
case $type->isApplication(): {
|
||||
$this->xmlWriter->writeAttribute('type', 'application');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case $type->isLibrary(): {
|
||||
$this->xmlWriter->writeAttribute('type', 'library');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case $type->isExtension(): {
|
||||
/* @var $type Extension */
|
||||
$this->xmlWriter->writeAttribute('type', 'extension');
|
||||
$this->addExtension($type->getApplicationName(), $type->getVersionConstraint());
|
||||
/* @var $type Extension */
|
||||
$this->addExtension(
|
||||
$type->getApplicationName(),
|
||||
$type->getVersionConstraint()
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -89,13 +93,13 @@ class ManifestSerializer {
|
||||
$this->xmlWriter->endElement();
|
||||
}
|
||||
|
||||
private function addCopyright(CopyrightInformation $copyrightInformation) {
|
||||
private function addCopyright(CopyrightInformation $copyrightInformation): void {
|
||||
$this->xmlWriter->startElement('copyright');
|
||||
|
||||
foreach($copyrightInformation->getAuthors() as $author) {
|
||||
foreach ($copyrightInformation->getAuthors() as $author) {
|
||||
$this->xmlWriter->startElement('author');
|
||||
$this->xmlWriter->writeAttribute('name', $author->getName());
|
||||
$this->xmlWriter->writeAttribute('email', (string) $author->getEmail());
|
||||
$this->xmlWriter->writeAttribute('email', $author->getEmail()->asString());
|
||||
$this->xmlWriter->endElement();
|
||||
}
|
||||
|
||||
@@ -103,24 +107,25 @@ class ManifestSerializer {
|
||||
|
||||
$this->xmlWriter->startElement('license');
|
||||
$this->xmlWriter->writeAttribute('type', $license->getName());
|
||||
$this->xmlWriter->writeAttribute('url', $license->getUrl());
|
||||
$this->xmlWriter->writeAttribute('url', $license->getUrl()->asString());
|
||||
$this->xmlWriter->endElement();
|
||||
|
||||
$this->xmlWriter->endElement();
|
||||
}
|
||||
|
||||
private function addRequirements(RequirementCollection $requirementCollection) {
|
||||
private function addRequirements(RequirementCollection $requirementCollection): void {
|
||||
$phpRequirement = new AnyVersionConstraint();
|
||||
$extensions = [];
|
||||
|
||||
foreach($requirementCollection as $requirement) {
|
||||
foreach ($requirementCollection as $requirement) {
|
||||
if ($requirement instanceof PhpVersionRequirement) {
|
||||
$phpRequirement = $requirement->getVersionConstraint();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($requirement instanceof PhpExtensionRequirement) {
|
||||
$extensions[] = (string) $requirement;
|
||||
$extensions[] = $requirement->asString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +133,7 @@ class ManifestSerializer {
|
||||
$this->xmlWriter->startElement('php');
|
||||
$this->xmlWriter->writeAttribute('version', $phpRequirement->asString());
|
||||
|
||||
foreach($extensions as $extension) {
|
||||
foreach ($extensions as $extension) {
|
||||
$this->xmlWriter->startElement('ext');
|
||||
$this->xmlWriter->writeAttribute('name', $extension);
|
||||
$this->xmlWriter->endElement();
|
||||
@@ -138,13 +143,13 @@ class ManifestSerializer {
|
||||
$this->xmlWriter->endElement();
|
||||
}
|
||||
|
||||
private function addBundles(BundledComponentCollection $bundledComponentCollection) {
|
||||
if (count($bundledComponentCollection) === 0) {
|
||||
private function addBundles(BundledComponentCollection $bundledComponentCollection): void {
|
||||
if (\count($bundledComponentCollection) === 0) {
|
||||
return;
|
||||
}
|
||||
$this->xmlWriter->startElement('bundles');
|
||||
|
||||
foreach($bundledComponentCollection as $bundledComponent) {
|
||||
foreach ($bundledComponentCollection as $bundledComponent) {
|
||||
$this->xmlWriter->startElement('component');
|
||||
$this->xmlWriter->writeAttribute('name', $bundledComponent->getName());
|
||||
$this->xmlWriter->writeAttribute('version', $bundledComponent->getVersion()->getVersionString());
|
||||
@@ -154,9 +159,9 @@ class ManifestSerializer {
|
||||
$this->xmlWriter->endElement();
|
||||
}
|
||||
|
||||
private function addExtension($application, VersionConstraint $versionConstraint) {
|
||||
private function addExtension(ApplicationName $applicationName, VersionConstraint $versionConstraint): void {
|
||||
$this->xmlWriter->startElement('extension');
|
||||
$this->xmlWriter->writeAttribute('for', $application);
|
||||
$this->xmlWriter->writeAttribute('for', $applicationName->asString());
|
||||
$this->xmlWriter->writeAttribute('compatible', $versionConstraint->asString());
|
||||
$this->xmlWriter->endElement();
|
||||
}
|
||||
|
13
vendor/phar-io/manifest/src/exceptions/ElementCollectionException.php
vendored
Normal file
13
vendor/phar-io/manifest/src/exceptions/ElementCollectionException.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ElementCollectionException extends \InvalidArgumentException implements Exception {
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,8 +7,7 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
interface Exception {
|
||||
interface Exception extends \Throwable {
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,10 +7,8 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class InvalidApplicationNameException extends \InvalidArgumentException implements Exception {
|
||||
const NotAString = 1;
|
||||
const InvalidFormat = 2;
|
||||
public const InvalidFormat = 2;
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class InvalidEmailException extends \InvalidArgumentException implements Exception {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class InvalidUrlException extends \InvalidArgumentException implements Exception {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
<?php declare(strict_types = 1);
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ManifestDocumentException extends \RuntimeException implements Exception {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,15 +7,12 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use LibXMLError;
|
||||
|
||||
class ManifestDocumentLoadingException extends \Exception implements Exception {
|
||||
/**
|
||||
* @var LibXMLError[]
|
||||
*/
|
||||
/** @var LibXMLError[] */
|
||||
private $libxmlErrors;
|
||||
|
||||
/**
|
||||
@@ -28,7 +25,7 @@ class ManifestDocumentLoadingException extends \Exception implements Exception {
|
||||
$first = $this->libxmlErrors[0];
|
||||
|
||||
parent::__construct(
|
||||
sprintf(
|
||||
\sprintf(
|
||||
'%s (Line: %d / Column: %d / File: %s)',
|
||||
$first->message,
|
||||
$first->line,
|
||||
@@ -42,7 +39,7 @@ class ManifestDocumentLoadingException extends \Exception implements Exception {
|
||||
/**
|
||||
* @return LibXMLError[]
|
||||
*/
|
||||
public function getLibxmlErrors() {
|
||||
public function getLibxmlErrors(): array {
|
||||
return $this->libxmlErrors;
|
||||
}
|
||||
}
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
<?php declare(strict_types = 1);
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ManifestDocumentMapperException extends \RuntimeException implements Exception {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
<?php declare(strict_types = 1);
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ManifestElementException extends \RuntimeException implements Exception {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
<?php declare(strict_types = 1);
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ManifestLoaderException extends \Exception implements Exception {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,14 +7,10 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class Application extends Type {
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isApplication() {
|
||||
public function isApplication(): bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,59 +7,31 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ApplicationName {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* ApplicationName constructor.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws InvalidApplicationNameException
|
||||
*/
|
||||
public function __construct($name) {
|
||||
$this->ensureIsString($name);
|
||||
public function __construct(string $name) {
|
||||
$this->ensureValidFormat($name);
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
public function asString(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function isEqual(ApplicationName $name) {
|
||||
public function isEqual(ApplicationName $name): bool {
|
||||
return $this->name === $name->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @throws InvalidApplicationNameException
|
||||
*/
|
||||
private function ensureValidFormat($name) {
|
||||
if (!preg_match('#\w/\w#', $name)) {
|
||||
private function ensureValidFormat(string $name): void {
|
||||
if (!\preg_match('#\w/\w#', $name)) {
|
||||
throw new InvalidApplicationNameException(
|
||||
sprintf('Format of name "%s" is not valid - expected: vendor/packagename', $name),
|
||||
\sprintf('Format of name "%s" is not valid - expected: vendor/packagename', $name),
|
||||
InvalidApplicationNameException::InvalidFormat
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function ensureIsString($name) {
|
||||
if (!is_string($name)) {
|
||||
throw new InvalidApplicationNameException(
|
||||
'Name must be a string',
|
||||
InvalidApplicationNameException::NotAString
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
46
vendor/phar-io/manifest/src/values/Author.php
vendored
46
vendor/phar-io/manifest/src/values/Author.php
vendored
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,51 +7,33 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class Author {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var Email
|
||||
*/
|
||||
/** @var Email */
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param Email $email
|
||||
*/
|
||||
public function __construct($name, Email $email) {
|
||||
public function __construct(string $name, Email $email) {
|
||||
$this->name = $name;
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
public function asString(): string {
|
||||
return \sprintf(
|
||||
'%s <%s>',
|
||||
$this->name,
|
||||
$this->email->asString()
|
||||
);
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Email
|
||||
*/
|
||||
public function getEmail() {
|
||||
public function getEmail(): Email {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
return sprintf(
|
||||
'%s <%s>',
|
||||
$this->name,
|
||||
$this->email
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,37 +7,28 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class AuthorCollection implements \Countable, \IteratorAggregate {
|
||||
/**
|
||||
* @var Author[]
|
||||
*/
|
||||
/** @var Author[] */
|
||||
private $authors = [];
|
||||
|
||||
public function add(Author $author) {
|
||||
public function add(Author $author): void {
|
||||
$this->authors[] = $author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Author[]
|
||||
*/
|
||||
public function getAuthors() {
|
||||
public function getAuthors(): array {
|
||||
return $this->authors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->authors);
|
||||
public function count(): int {
|
||||
return \count($this->authors);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AuthorCollectionIterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator(): AuthorCollectionIterator {
|
||||
return new AuthorCollectionIterator($this);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,50 +7,36 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class AuthorCollectionIterator implements \Iterator {
|
||||
/**
|
||||
* @var Author[]
|
||||
*/
|
||||
private $authors = [];
|
||||
/** @var Author[] */
|
||||
private $authors;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $position;
|
||||
/** @var int */
|
||||
private $position = 0;
|
||||
|
||||
public function __construct(AuthorCollection $authors) {
|
||||
$this->authors = $authors->getAuthors();
|
||||
}
|
||||
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {
|
||||
return $this->position < count($this->authors);
|
||||
public function valid(): bool {
|
||||
return $this->position < \count($this->authors);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function key() {
|
||||
public function key(): int {
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Author
|
||||
*/
|
||||
public function current() {
|
||||
public function current(): Author {
|
||||
return $this->authors[$this->position];
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
$this->position++;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,42 +7,27 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\Version;
|
||||
|
||||
class BundledComponent {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var Version
|
||||
*/
|
||||
/** @var Version */
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param Version $version
|
||||
*/
|
||||
public function __construct($name, Version $version) {
|
||||
public function __construct(string $name, Version $version) {
|
||||
$this->name = $name;
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Version
|
||||
*/
|
||||
public function getVersion() {
|
||||
public function getVersion(): Version {
|
||||
return $this->version;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,37 +7,28 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class BundledComponentCollection implements \Countable, \IteratorAggregate {
|
||||
/**
|
||||
* @var BundledComponent[]
|
||||
*/
|
||||
/** @var BundledComponent[] */
|
||||
private $bundledComponents = [];
|
||||
|
||||
public function add(BundledComponent $bundledComponent) {
|
||||
public function add(BundledComponent $bundledComponent): void {
|
||||
$this->bundledComponents[] = $bundledComponent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BundledComponent[]
|
||||
*/
|
||||
public function getBundledComponents() {
|
||||
public function getBundledComponents(): array {
|
||||
return $this->bundledComponents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->bundledComponents);
|
||||
public function count(): int {
|
||||
return \count($this->bundledComponents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BundledComponentCollectionIterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator(): BundledComponentCollectionIterator {
|
||||
return new BundledComponentCollectionIterator($this);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,50 +7,36 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class BundledComponentCollectionIterator implements \Iterator {
|
||||
/**
|
||||
* @var BundledComponent[]
|
||||
*/
|
||||
private $bundledComponents = [];
|
||||
/** @var BundledComponent[] */
|
||||
private $bundledComponents;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $position;
|
||||
/** @var int */
|
||||
private $position = 0;
|
||||
|
||||
public function __construct(BundledComponentCollection $bundledComponents) {
|
||||
$this->bundledComponents = $bundledComponents->getBundledComponents();
|
||||
}
|
||||
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {
|
||||
return $this->position < count($this->bundledComponents);
|
||||
public function valid(): bool {
|
||||
return $this->position < \count($this->bundledComponents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function key() {
|
||||
public function key(): int {
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BundledComponent
|
||||
*/
|
||||
public function current() {
|
||||
public function current(): BundledComponent {
|
||||
return $this->bundledComponents[$this->position];
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
$this->position++;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,18 +7,13 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class CopyrightInformation {
|
||||
/**
|
||||
* @var AuthorCollection
|
||||
*/
|
||||
/** @var AuthorCollection */
|
||||
private $authors;
|
||||
|
||||
/**
|
||||
* @var License
|
||||
*/
|
||||
/** @var License */
|
||||
private $license;
|
||||
|
||||
public function __construct(AuthorCollection $authors, License $license) {
|
||||
@@ -26,17 +21,11 @@ class CopyrightInformation {
|
||||
$this->license = $license;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AuthorCollection
|
||||
*/
|
||||
public function getAuthors() {
|
||||
public function getAuthors(): AuthorCollection {
|
||||
return $this->authors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return License
|
||||
*/
|
||||
public function getLicense() {
|
||||
public function getLicense(): License {
|
||||
return $this->license;
|
||||
}
|
||||
}
|
||||
|
28
vendor/phar-io/manifest/src/values/Email.php
vendored
28
vendor/phar-io/manifest/src/values/Email.php
vendored
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,40 +7,24 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class Email {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
*
|
||||
* @throws InvalidEmailException
|
||||
*/
|
||||
public function __construct($email) {
|
||||
public function __construct(string $email) {
|
||||
$this->ensureEmailIsValid($email);
|
||||
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
public function asString(): string {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*
|
||||
* @throws InvalidEmailException
|
||||
*/
|
||||
private function ensureEmailIsValid($url) {
|
||||
if (filter_var($url, \FILTER_VALIDATE_EMAIL) === false) {
|
||||
private function ensureEmailIsValid(string $url): void {
|
||||
if (\filter_var($url, \FILTER_VALIDATE_EMAIL) === false) {
|
||||
throw new InvalidEmailException;
|
||||
}
|
||||
}
|
||||
|
45
vendor/phar-io/manifest/src/values/Extension.php
vendored
45
vendor/phar-io/manifest/src/values/Extension.php
vendored
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,69 +7,40 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\Version;
|
||||
use PharIo\Version\VersionConstraint;
|
||||
|
||||
class Extension extends Type {
|
||||
/**
|
||||
* @var ApplicationName
|
||||
*/
|
||||
/** @var ApplicationName */
|
||||
private $application;
|
||||
|
||||
/**
|
||||
* @var VersionConstraint
|
||||
*/
|
||||
/** @var VersionConstraint */
|
||||
private $versionConstraint;
|
||||
|
||||
/**
|
||||
* @param ApplicationName $application
|
||||
* @param VersionConstraint $versionConstraint
|
||||
*/
|
||||
public function __construct(ApplicationName $application, VersionConstraint $versionConstraint) {
|
||||
$this->application = $application;
|
||||
$this->versionConstraint = $versionConstraint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ApplicationName
|
||||
*/
|
||||
public function getApplicationName() {
|
||||
public function getApplicationName(): ApplicationName {
|
||||
return $this->application;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return VersionConstraint
|
||||
*/
|
||||
public function getVersionConstraint() {
|
||||
public function getVersionConstraint(): VersionConstraint {
|
||||
return $this->versionConstraint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isExtension() {
|
||||
public function isExtension(): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ApplicationName $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isExtensionFor(ApplicationName $name) {
|
||||
public function isExtensionFor(ApplicationName $name): bool {
|
||||
return $this->application->isEqual($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ApplicationName $name
|
||||
* @param Version $version
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCompatibleWith(ApplicationName $name, Version $version) {
|
||||
public function isCompatibleWith(ApplicationName $name, Version $version): bool {
|
||||
return $this->isExtensionFor($name) && $this->versionConstraint->complies($version);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,14 +7,10 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class Library extends Type {
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLibrary() {
|
||||
public function isLibrary(): bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
23
vendor/phar-io/manifest/src/values/License.php
vendored
23
vendor/phar-io/manifest/src/values/License.php
vendored
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,36 +7,25 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class License {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var Url
|
||||
*/
|
||||
/** @var Url */
|
||||
private $url;
|
||||
|
||||
public function __construct($name, Url $url) {
|
||||
public function __construct(string $name, Url $url) {
|
||||
$this->name = $name;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Url
|
||||
*/
|
||||
public function getUrl() {
|
||||
public function getUrl(): Url {
|
||||
return $this->url;
|
||||
}
|
||||
}
|
||||
|
80
vendor/phar-io/manifest/src/values/Manifest.php
vendored
80
vendor/phar-io/manifest/src/values/Manifest.php
vendored
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,40 +7,27 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\Version;
|
||||
|
||||
class Manifest {
|
||||
/**
|
||||
* @var ApplicationName
|
||||
*/
|
||||
/** @var ApplicationName */
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var Version
|
||||
*/
|
||||
/** @var Version */
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* @var Type
|
||||
*/
|
||||
/** @var Type */
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var CopyrightInformation
|
||||
*/
|
||||
/** @var CopyrightInformation */
|
||||
private $copyrightInformation;
|
||||
|
||||
/**
|
||||
* @var RequirementCollection
|
||||
*/
|
||||
/** @var RequirementCollection */
|
||||
private $requirements;
|
||||
|
||||
/**
|
||||
* @var BundledComponentCollection
|
||||
*/
|
||||
/** @var BundledComponentCollection */
|
||||
private $bundledComponents;
|
||||
|
||||
public function __construct(ApplicationName $name, Version $version, Type $type, CopyrightInformation $copyrightInformation, RequirementCollection $requirements, BundledComponentCollection $bundledComponents) {
|
||||
@@ -52,76 +39,43 @@ class Manifest {
|
||||
$this->bundledComponents = $bundledComponents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ApplicationName
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): ApplicationName {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Version
|
||||
*/
|
||||
public function getVersion() {
|
||||
public function getVersion(): Version {
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Type
|
||||
*/
|
||||
public function getType() {
|
||||
public function getType(): Type {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CopyrightInformation
|
||||
*/
|
||||
public function getCopyrightInformation() {
|
||||
public function getCopyrightInformation(): CopyrightInformation {
|
||||
return $this->copyrightInformation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RequirementCollection
|
||||
*/
|
||||
public function getRequirements() {
|
||||
public function getRequirements(): RequirementCollection {
|
||||
return $this->requirements;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BundledComponentCollection
|
||||
*/
|
||||
public function getBundledComponents() {
|
||||
public function getBundledComponents(): BundledComponentCollection {
|
||||
return $this->bundledComponents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isApplication() {
|
||||
public function isApplication(): bool {
|
||||
return $this->type->isApplication();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLibrary() {
|
||||
public function isLibrary(): bool {
|
||||
return $this->type->isLibrary();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isExtension() {
|
||||
public function isExtension(): bool {
|
||||
return $this->type->isExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ApplicationName $application
|
||||
* @param Version|null $version
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isExtensionFor(ApplicationName $application, Version $version = null) {
|
||||
public function isExtensionFor(ApplicationName $application, Version $version = null): bool {
|
||||
if (!$this->isExtension()) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,26 +7,17 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class PhpExtensionRequirement implements Requirement {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $extension;
|
||||
|
||||
/**
|
||||
* @param string $extension
|
||||
*/
|
||||
public function __construct($extension) {
|
||||
public function __construct(string $extension) {
|
||||
$this->extension = $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
public function asString(): string {
|
||||
return $this->extension;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,25 +7,19 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\VersionConstraint;
|
||||
|
||||
class PhpVersionRequirement implements Requirement {
|
||||
/**
|
||||
* @var VersionConstraint
|
||||
*/
|
||||
/** @var VersionConstraint */
|
||||
private $versionConstraint;
|
||||
|
||||
public function __construct(VersionConstraint $versionConstraint) {
|
||||
$this->versionConstraint = $versionConstraint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return VersionConstraint
|
||||
*/
|
||||
public function getVersionConstraint() {
|
||||
public function getVersionConstraint(): VersionConstraint {
|
||||
return $this->versionConstraint;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,7 +7,6 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
interface Requirement {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,37 +7,28 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class RequirementCollection implements \Countable, \IteratorAggregate {
|
||||
/**
|
||||
* @var Requirement[]
|
||||
*/
|
||||
/** @var Requirement[] */
|
||||
private $requirements = [];
|
||||
|
||||
public function add(Requirement $requirement) {
|
||||
public function add(Requirement $requirement): void {
|
||||
$this->requirements[] = $requirement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Requirement[]
|
||||
*/
|
||||
public function getRequirements() {
|
||||
public function getRequirements(): array {
|
||||
return $this->requirements;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->requirements);
|
||||
public function count(): int {
|
||||
return \count($this->requirements);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RequirementCollectionIterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator(): RequirementCollectionIterator {
|
||||
return new RequirementCollectionIterator($this);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,50 +7,36 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class RequirementCollectionIterator implements \Iterator {
|
||||
/**
|
||||
* @var Requirement[]
|
||||
*/
|
||||
private $requirements = [];
|
||||
/** @var Requirement[] */
|
||||
private $requirements;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $position;
|
||||
/** @var int */
|
||||
private $position = 0;
|
||||
|
||||
public function __construct(RequirementCollection $requirements) {
|
||||
$this->requirements = $requirements->getRequirements();
|
||||
}
|
||||
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {
|
||||
return $this->position < count($this->requirements);
|
||||
public function valid(): bool {
|
||||
return $this->position < \count($this->requirements);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function key() {
|
||||
public function key(): int {
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Requirement
|
||||
*/
|
||||
public function current() {
|
||||
public function current(): Requirement {
|
||||
return $this->requirements[$this->position];
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
$this->position++;
|
||||
}
|
||||
}
|
||||
|
39
vendor/phar-io/manifest/src/values/Type.php
vendored
39
vendor/phar-io/manifest/src/values/Type.php
vendored
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,54 +7,35 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\VersionConstraint;
|
||||
|
||||
abstract class Type {
|
||||
/**
|
||||
* @return Application
|
||||
*/
|
||||
public static function application() {
|
||||
public static function application(): Application {
|
||||
return new Application;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Library
|
||||
*/
|
||||
public static function library() {
|
||||
public static function library(): Library {
|
||||
return new Library;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ApplicationName $application
|
||||
* @param VersionConstraint $versionConstraint
|
||||
*
|
||||
* @return Extension
|
||||
*/
|
||||
public static function extension(ApplicationName $application, VersionConstraint $versionConstraint) {
|
||||
public static function extension(ApplicationName $application, VersionConstraint $versionConstraint): Extension {
|
||||
return new Extension($application, $versionConstraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isApplication() {
|
||||
/** @psalm-assert-if-true Application $this */
|
||||
public function isApplication(): bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLibrary() {
|
||||
/** @psalm-assert-if-true Library $this */
|
||||
public function isLibrary(): bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isExtension() {
|
||||
/** @psalm-assert-if-true Extension $this */
|
||||
public function isExtension(): bool {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
23
vendor/phar-io/manifest/src/values/Url.php
vendored
23
vendor/phar-io/manifest/src/values/Url.php
vendored
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,30 +7,19 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class Url {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*
|
||||
* @throws InvalidUrlException
|
||||
*/
|
||||
public function __construct($url) {
|
||||
public function __construct(string $url) {
|
||||
$this->ensureUrlIsValid($url);
|
||||
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
public function asString(): string {
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
@@ -39,8 +28,8 @@ class Url {
|
||||
*
|
||||
* @throws InvalidUrlException
|
||||
*/
|
||||
private function ensureUrlIsValid($url) {
|
||||
if (filter_var($url, \FILTER_VALIDATE_URL) === false) {
|
||||
private function ensureUrlIsValid($url): void {
|
||||
if (\filter_var($url, \FILTER_VALIDATE_URL) === false) {
|
||||
throw new InvalidUrlException;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,15 +7,14 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class AuthorElement extends ManifestElement {
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return $this->getAttributeValue('name');
|
||||
}
|
||||
|
||||
public function getEmail() {
|
||||
public function getEmail(): string {
|
||||
return $this->getAttributeValue('email');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,11 +7,10 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class AuthorElementCollection extends ElementCollection {
|
||||
public function current() {
|
||||
public function current(): AuthorElement {
|
||||
return new AuthorElement(
|
||||
$this->getCurrentElement()
|
||||
);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,11 +7,10 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class BundlesElement extends ManifestElement {
|
||||
public function getComponentElements() {
|
||||
public function getComponentElements(): ComponentElementCollection {
|
||||
return new ComponentElementCollection(
|
||||
$this->getChildrenByName('component')
|
||||
);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,15 +7,14 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ComponentElement extends ManifestElement {
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return $this->getAttributeValue('name');
|
||||
}
|
||||
|
||||
public function getVersion() {
|
||||
public function getVersion(): string {
|
||||
return $this->getAttributeValue('version');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,11 +7,10 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ComponentElementCollection extends ElementCollection {
|
||||
public function current() {
|
||||
public function current(): ComponentElement {
|
||||
return new ComponentElement(
|
||||
$this->getCurrentElement()
|
||||
);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,23 +7,22 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ContainsElement extends ManifestElement {
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return $this->getAttributeValue('name');
|
||||
}
|
||||
|
||||
public function getVersion() {
|
||||
public function getVersion(): string {
|
||||
return $this->getAttributeValue('version');
|
||||
}
|
||||
|
||||
public function getType() {
|
||||
public function getType(): string {
|
||||
return $this->getAttributeValue('type');
|
||||
}
|
||||
|
||||
public function getExtensionElement() {
|
||||
public function getExtensionElement(): ExtensionElement {
|
||||
return new ExtensionElement(
|
||||
$this->getChildByName('extension')
|
||||
);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,17 +7,16 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class CopyrightElement extends ManifestElement {
|
||||
public function getAuthorElements() {
|
||||
public function getAuthorElements(): AuthorElementCollection {
|
||||
return new AuthorElementCollection(
|
||||
$this->getChildrenByName('author')
|
||||
);
|
||||
}
|
||||
|
||||
public function getLicenseElement() {
|
||||
public function getLicenseElement(): LicenseElement {
|
||||
return new LicenseElement(
|
||||
$this->getChildByName('license')
|
||||
);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,52 +7,55 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use DOMElement;
|
||||
use DOMNodeList;
|
||||
|
||||
abstract class ElementCollection implements \Iterator {
|
||||
/**
|
||||
* @var DOMNodeList
|
||||
*/
|
||||
private $nodeList;
|
||||
/** @var DOMElement[] */
|
||||
private $nodes = [];
|
||||
|
||||
/** @var int */
|
||||
private $position;
|
||||
|
||||
/**
|
||||
* ElementCollection constructor.
|
||||
*
|
||||
* @param DOMNodeList $nodeList
|
||||
*/
|
||||
public function __construct(DOMNodeList $nodeList) {
|
||||
$this->nodeList = $nodeList;
|
||||
$this->position = 0;
|
||||
$this->importNodes($nodeList);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
abstract public function current();
|
||||
|
||||
/**
|
||||
* @return DOMElement
|
||||
*/
|
||||
protected function getCurrentElement() {
|
||||
return $this->nodeList->item($this->position);
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
$this->position++;
|
||||
}
|
||||
|
||||
public function key() {
|
||||
public function key(): int {
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
return $this->position < $this->nodeList->length;
|
||||
public function valid(): bool {
|
||||
return $this->position < \count($this->nodes);
|
||||
}
|
||||
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
protected function getCurrentElement(): DOMElement {
|
||||
return $this->nodes[$this->position];
|
||||
}
|
||||
|
||||
private function importNodes(DOMNodeList $nodeList): void {
|
||||
foreach ($nodeList as $node) {
|
||||
if (!$node instanceof DOMElement) {
|
||||
throw new ElementCollectionException(
|
||||
\sprintf('\DOMElement expected, got \%s', \get_class($node))
|
||||
);
|
||||
}
|
||||
|
||||
$this->nodes[] = $node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,11 +7,10 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ExtElement extends ManifestElement {
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return $this->getAttributeValue('name');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,14 +7,12 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ExtElementCollection extends ElementCollection {
|
||||
public function current() {
|
||||
public function current(): ExtElement {
|
||||
return new ExtElement(
|
||||
$this->getCurrentElement()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,15 +7,14 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ExtensionElement extends ManifestElement {
|
||||
public function getFor() {
|
||||
public function getFor(): string {
|
||||
return $this->getAttributeValue('for');
|
||||
}
|
||||
|
||||
public function getCompatible() {
|
||||
public function getCompatible(): string {
|
||||
return $this->getAttributeValue('compatible');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,15 +7,14 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class LicenseElement extends ManifestElement {
|
||||
public function getType() {
|
||||
public function getType(): string {
|
||||
return $this->getAttributeValue('type');
|
||||
}
|
||||
|
||||
public function getUrl() {
|
||||
public function getUrl(): string {
|
||||
return $this->getAttributeValue('url');
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,89 +7,81 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
|
||||
class ManifestDocument {
|
||||
const XMLNS = 'https://phar.io/xml/manifest/1.0';
|
||||
public const XMLNS = 'https://phar.io/xml/manifest/1.0';
|
||||
|
||||
/**
|
||||
* @var DOMDocument
|
||||
*/
|
||||
/** @var DOMDocument */
|
||||
private $dom;
|
||||
|
||||
/**
|
||||
* ManifestDocument constructor.
|
||||
*
|
||||
* @param DOMDocument $dom
|
||||
*/
|
||||
private function __construct(DOMDocument $dom) {
|
||||
$this->ensureCorrectDocumentType($dom);
|
||||
|
||||
$this->dom = $dom;
|
||||
}
|
||||
|
||||
public static function fromFile($filename) {
|
||||
if (!file_exists($filename)) {
|
||||
public static function fromFile(string $filename): ManifestDocument {
|
||||
if (!\file_exists($filename)) {
|
||||
throw new ManifestDocumentException(
|
||||
sprintf('File "%s" not found', $filename)
|
||||
\sprintf('File "%s" not found', $filename)
|
||||
);
|
||||
}
|
||||
|
||||
return self::fromString(
|
||||
file_get_contents($filename)
|
||||
\file_get_contents($filename)
|
||||
);
|
||||
}
|
||||
|
||||
public static function fromString($xmlString) {
|
||||
$prev = libxml_use_internal_errors(true);
|
||||
libxml_clear_errors();
|
||||
public static function fromString(string $xmlString): ManifestDocument {
|
||||
$prev = \libxml_use_internal_errors(true);
|
||||
\libxml_clear_errors();
|
||||
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML($xmlString);
|
||||
|
||||
$errors = libxml_get_errors();
|
||||
libxml_use_internal_errors($prev);
|
||||
$errors = \libxml_get_errors();
|
||||
\libxml_use_internal_errors($prev);
|
||||
|
||||
if (count($errors) !== 0) {
|
||||
if (\count($errors) !== 0) {
|
||||
throw new ManifestDocumentLoadingException($errors);
|
||||
}
|
||||
|
||||
return new self($dom);
|
||||
}
|
||||
|
||||
public function getContainsElement() {
|
||||
private function __construct(DOMDocument $dom) {
|
||||
$this->ensureCorrectDocumentType($dom);
|
||||
|
||||
$this->dom = $dom;
|
||||
}
|
||||
|
||||
public function getContainsElement(): ContainsElement {
|
||||
return new ContainsElement(
|
||||
$this->fetchElementByName('contains')
|
||||
);
|
||||
}
|
||||
|
||||
public function getCopyrightElement() {
|
||||
public function getCopyrightElement(): CopyrightElement {
|
||||
return new CopyrightElement(
|
||||
$this->fetchElementByName('copyright')
|
||||
);
|
||||
}
|
||||
|
||||
public function getRequiresElement() {
|
||||
public function getRequiresElement(): RequiresElement {
|
||||
return new RequiresElement(
|
||||
$this->fetchElementByName('requires')
|
||||
);
|
||||
}
|
||||
|
||||
public function hasBundlesElement() {
|
||||
public function hasBundlesElement(): bool {
|
||||
return $this->dom->getElementsByTagNameNS(self::XMLNS, 'bundles')->length === 1;
|
||||
}
|
||||
|
||||
public function getBundlesElement() {
|
||||
public function getBundlesElement(): BundlesElement {
|
||||
return new BundlesElement(
|
||||
$this->fetchElementByName('bundles')
|
||||
);
|
||||
}
|
||||
|
||||
private function ensureCorrectDocumentType(DOMDocument $dom) {
|
||||
private function ensureCorrectDocumentType(DOMDocument $dom): void {
|
||||
$root = $dom->documentElement;
|
||||
|
||||
if ($root->localName !== 'phar' || $root->namespaceURI !== self::XMLNS) {
|
||||
@@ -97,19 +89,12 @@ class ManifestDocument {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $elementName
|
||||
*
|
||||
* @return DOMElement
|
||||
*
|
||||
* @throws ManifestDocumentException
|
||||
*/
|
||||
private function fetchElementByName($elementName) {
|
||||
private function fetchElementByName(string $elementName): DOMElement {
|
||||
$element = $this->dom->getElementsByTagNameNS(self::XMLNS, $elementName)->item(0);
|
||||
|
||||
if (!$element instanceof DOMElement) {
|
||||
throw new ManifestDocumentException(
|
||||
sprintf('Element %s missing', $elementName)
|
||||
\sprintf('Element %s missing', $elementName)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,40 +7,25 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use DOMElement;
|
||||
use DOMNodeList;
|
||||
|
||||
class ManifestElement {
|
||||
const XMLNS = 'https://phar.io/xml/manifest/1.0';
|
||||
public const XMLNS = 'https://phar.io/xml/manifest/1.0';
|
||||
|
||||
/**
|
||||
* @var DOMElement
|
||||
*/
|
||||
/** @var DOMElement */
|
||||
private $element;
|
||||
|
||||
/**
|
||||
* ContainsElement constructor.
|
||||
*
|
||||
* @param DOMElement $element
|
||||
*/
|
||||
public function __construct(DOMElement $element) {
|
||||
$this->element = $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws ManifestElementException
|
||||
*/
|
||||
protected function getAttributeValue($name) {
|
||||
protected function getAttributeValue(string $name): string {
|
||||
if (!$this->element->hasAttribute($name)) {
|
||||
throw new ManifestElementException(
|
||||
sprintf(
|
||||
\sprintf(
|
||||
'Attribute %s not set on element %s',
|
||||
$name,
|
||||
$this->element->localName
|
||||
@@ -51,50 +36,31 @@ class ManifestElement {
|
||||
return $this->element->getAttribute($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $elementName
|
||||
*
|
||||
* @return DOMElement
|
||||
*
|
||||
* @throws ManifestElementException
|
||||
*/
|
||||
protected function getChildByName($elementName) {
|
||||
protected function getChildByName(string $elementName): DOMElement {
|
||||
$element = $this->element->getElementsByTagNameNS(self::XMLNS, $elementName)->item(0);
|
||||
|
||||
if (!$element instanceof DOMElement) {
|
||||
throw new ManifestElementException(
|
||||
sprintf('Element %s missing', $elementName)
|
||||
\sprintf('Element %s missing', $elementName)
|
||||
);
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $elementName
|
||||
*
|
||||
* @return DOMNodeList
|
||||
*
|
||||
* @throws ManifestElementException
|
||||
*/
|
||||
protected function getChildrenByName($elementName) {
|
||||
protected function getChildrenByName(string $elementName): DOMNodeList {
|
||||
$elementList = $this->element->getElementsByTagNameNS(self::XMLNS, $elementName);
|
||||
|
||||
if ($elementList->length === 0) {
|
||||
throw new ManifestElementException(
|
||||
sprintf('Element(s) %s missing', $elementName)
|
||||
\sprintf('Element(s) %s missing', $elementName)
|
||||
);
|
||||
}
|
||||
|
||||
return $elementList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $elementName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasChild($elementName) {
|
||||
protected function hasChild(string $elementName): bool {
|
||||
return $this->element->getElementsByTagNameNS(self::XMLNS, $elementName)->length !== 0;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,19 +7,18 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class PhpElement extends ManifestElement {
|
||||
public function getVersion() {
|
||||
public function getVersion(): string {
|
||||
return $this->getAttributeValue('version');
|
||||
}
|
||||
|
||||
public function hasExtElements() {
|
||||
public function hasExtElements(): bool {
|
||||
return $this->hasChild('ext');
|
||||
}
|
||||
|
||||
public function getExtElements() {
|
||||
public function getExtElements(): ExtElementCollection {
|
||||
return new ExtElementCollection(
|
||||
$this->getChildrenByName('ext')
|
||||
);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
@@ -7,11 +7,10 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class RequiresElement extends ManifestElement {
|
||||
public function getPHPElement() {
|
||||
public function getPHPElement(): PhpElement {
|
||||
return new PhpElement(
|
||||
$this->getChildByName('php')
|
||||
);
|
||||
|
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
/**
|
||||
* @covers \PharIo\Manifest\ManifestDocumentMapper
|
||||
*
|
||||
* @uses \PharIo\Manifest\ApplicationName
|
||||
* @uses \PharIo\Manifest\Author
|
||||
* @uses \PharIo\Manifest\AuthorCollection
|
||||
* @uses \PharIo\Manifest\AuthorCollectionIterator
|
||||
* @uses \PharIo\Manifest\AuthorElement
|
||||
* @uses \PharIo\Manifest\AuthorElementCollection
|
||||
* @uses \PharIo\Manifest\BundledComponent
|
||||
* @uses \PharIo\Manifest\BundledComponentCollection
|
||||
* @uses \PharIo\Manifest\BundledComponentCollectionIterator
|
||||
* @uses \PharIo\Manifest\BundlesElement
|
||||
* @uses \PharIo\Manifest\ComponentElement
|
||||
* @uses \PharIo\Manifest\ComponentElementCollection
|
||||
* @uses \PharIo\Manifest\ContainsElement
|
||||
* @uses \PharIo\Manifest\CopyrightElement
|
||||
* @uses \PharIo\Manifest\CopyrightInformation
|
||||
* @uses \PharIo\Manifest\ElementCollection
|
||||
* @uses \PharIo\Manifest\Email
|
||||
* @uses \PharIo\Manifest\ExtElement
|
||||
* @uses \PharIo\Manifest\ExtElementCollection
|
||||
* @uses \PharIo\Manifest\License
|
||||
* @uses \PharIo\Manifest\LicenseElement
|
||||
* @uses \PharIo\Manifest\Manifest
|
||||
* @uses \PharIo\Manifest\ManifestDocument
|
||||
* @uses \PharIo\Manifest\ManifestDocumentMapper
|
||||
* @uses \PharIo\Manifest\ManifestElement
|
||||
* @uses \PharIo\Manifest\ManifestLoader
|
||||
* @uses \PharIo\Manifest\PhpElement
|
||||
* @uses \PharIo\Manifest\PhpExtensionRequirement
|
||||
* @uses \PharIo\Manifest\PhpVersionRequirement
|
||||
* @uses \PharIo\Manifest\RequirementCollection
|
||||
* @uses \PharIo\Manifest\RequirementCollectionIterator
|
||||
* @uses \PharIo\Manifest\RequiresElement
|
||||
* @uses \PharIo\Manifest\Type
|
||||
* @uses \PharIo\Manifest\Url
|
||||
* @uses \PharIo\Version\Version
|
||||
* @uses \PharIo\Version\VersionConstraint
|
||||
*/
|
||||
class ManifestDocumentMapperTest extends \PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* @dataProvider dataProvider
|
||||
*
|
||||
* @param $expected
|
||||
*
|
||||
* @uses \PharIo\Manifest\Application
|
||||
* @uses \PharIo\Manifest\ApplicationName
|
||||
* @uses \PharIo\Manifest\Library
|
||||
* @uses \PharIo\Manifest\Extension
|
||||
* @uses \PharIo\Manifest\ExtensionElement
|
||||
*/
|
||||
public function testCanSerializeToString($expected) {
|
||||
$manifestDocument = ManifestDocument::fromFile($expected);
|
||||
$mapper = new ManifestDocumentMapper();
|
||||
|
||||
$this->assertInstanceOf(
|
||||
Manifest::class,
|
||||
$mapper->map($manifestDocument)
|
||||
);
|
||||
}
|
||||
|
||||
public function dataProvider() {
|
||||
return [
|
||||
'application' => [__DIR__ . '/_fixture/phpunit-5.6.5.xml'],
|
||||
'library' => [__DIR__ . '/_fixture/library.xml'],
|
||||
'extension' => [__DIR__ . '/_fixture/extension.xml']
|
||||
];
|
||||
}
|
||||
|
||||
public function testThrowsExceptionOnUnsupportedType() {
|
||||
$manifestDocument = ManifestDocument::fromFile(__DIR__ . '/_fixture/custom.xml');
|
||||
$mapper = new ManifestDocumentMapper();
|
||||
|
||||
$this->expectException(ManifestDocumentMapperException::class);
|
||||
$mapper->map($manifestDocument);
|
||||
}
|
||||
|
||||
public function testInvalidVersionInformationThrowsException() {
|
||||
$manifestDocument = ManifestDocument::fromFile(__DIR__ . '/_fixture/invalidversion.xml');
|
||||
$mapper = new ManifestDocumentMapper();
|
||||
|
||||
$this->expectException(ManifestDocumentMapperException::class);
|
||||
$mapper->map($manifestDocument);
|
||||
}
|
||||
|
||||
public function testInvalidVersionConstraintThrowsException() {
|
||||
$manifestDocument = ManifestDocument::fromFile(__DIR__ . '/_fixture/invalidversionconstraint.xml');
|
||||
$mapper = new ManifestDocumentMapper();
|
||||
|
||||
$this->expectException(ManifestDocumentMapperException::class);
|
||||
$mapper->map($manifestDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \PharIo\Manifest\ExtensionElement
|
||||
*/
|
||||
public function testInvalidCompatibleConstraintThrowsException() {
|
||||
$manifestDocument = ManifestDocument::fromFile(__DIR__ . '/_fixture/extension-invalidcompatible.xml');
|
||||
$mapper = new ManifestDocumentMapper();
|
||||
|
||||
$this->expectException(ManifestDocumentMapperException::class);
|
||||
$mapper->map($manifestDocument);
|
||||
}
|
||||
|
||||
}
|
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
/**
|
||||
* @covers \PharIo\Manifest\ManifestLoader
|
||||
*
|
||||
* @uses \PharIo\Manifest\Author
|
||||
* @uses \PharIo\Manifest\AuthorCollection
|
||||
* @uses \PharIo\Manifest\AuthorCollectionIterator
|
||||
* @uses \PharIo\Manifest\AuthorElement
|
||||
* @uses \PharIo\Manifest\AuthorElementCollection
|
||||
* @uses \PharIo\Manifest\ApplicationName
|
||||
* @uses \PharIo\Manifest\BundledComponent
|
||||
* @uses \PharIo\Manifest\BundledComponentCollection
|
||||
* @uses \PharIo\Manifest\BundledComponentCollectionIterator
|
||||
* @uses \PharIo\Manifest\BundlesElement
|
||||
* @uses \PharIo\Manifest\ComponentElement
|
||||
* @uses \PharIo\Manifest\ComponentElementCollection
|
||||
* @uses \PharIo\Manifest\ContainsElement
|
||||
* @uses \PharIo\Manifest\CopyrightElement
|
||||
* @uses \PharIo\Manifest\CopyrightInformation
|
||||
* @uses \PharIo\Manifest\ElementCollection
|
||||
* @uses \PharIo\Manifest\Email
|
||||
* @uses \PharIo\Manifest\ExtElement
|
||||
* @uses \PharIo\Manifest\ExtElementCollection
|
||||
* @uses \PharIo\Manifest\License
|
||||
* @uses \PharIo\Manifest\LicenseElement
|
||||
* @uses \PharIo\Manifest\Manifest
|
||||
* @uses \PharIo\Manifest\ManifestDocument
|
||||
* @uses \PharIo\Manifest\ManifestDocumentMapper
|
||||
* @uses \PharIo\Manifest\ManifestElement
|
||||
* @uses \PharIo\Manifest\ManifestLoader
|
||||
* @uses \PharIo\Manifest\PhpElement
|
||||
* @uses \PharIo\Manifest\PhpExtensionRequirement
|
||||
* @uses \PharIo\Manifest\PhpVersionRequirement
|
||||
* @uses \PharIo\Manifest\RequirementCollection
|
||||
* @uses \PharIo\Manifest\RequirementCollectionIterator
|
||||
* @uses \PharIo\Manifest\RequiresElement
|
||||
* @uses \PharIo\Manifest\Type
|
||||
* @uses \PharIo\Manifest\Url
|
||||
* @uses \PharIo\Version\Version
|
||||
* @uses \PharIo\Version\VersionConstraint
|
||||
*/
|
||||
class ManifestLoaderTest extends \PHPUnit\Framework\TestCase {
|
||||
public function testCanBeLoadedFromFile() {
|
||||
$this->assertInstanceOf(
|
||||
Manifest::class,
|
||||
ManifestLoader::fromFile(__DIR__ . '/_fixture/library.xml')
|
||||
);
|
||||
}
|
||||
|
||||
public function testCanBeLoadedFromString() {
|
||||
$this->assertInstanceOf(
|
||||
Manifest::class,
|
||||
ManifestLoader::fromString(
|
||||
file_get_contents(__DIR__ . '/_fixture/library.xml')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testCanBeLoadedFromPhar() {
|
||||
$this->assertInstanceOf(
|
||||
Manifest::class,
|
||||
ManifestLoader::fromPhar(__DIR__ . '/_fixture/test.phar')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function testLoadingNonExistingFileThrowsException() {
|
||||
$this->expectException(ManifestLoaderException::class);
|
||||
ManifestLoader::fromFile('/not/existing');
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \PharIo\Manifest\ManifestDocumentLoadingException
|
||||
*/
|
||||
public function testLoadingInvalidXmlThrowsException() {
|
||||
$this->expectException(ManifestLoaderException::class);
|
||||
ManifestLoader::fromString('<?xml version="1.0" ?><broken>');
|
||||
}
|
||||
|
||||
}
|
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\Version;
|
||||
|
||||
/**
|
||||
* @covers \PharIo\Manifest\ManifestSerializer
|
||||
*
|
||||
* @uses \PharIo\Manifest\ApplicationName
|
||||
* @uses \PharIo\Manifest\Author
|
||||
* @uses \PharIo\Manifest\AuthorCollection
|
||||
* @uses \PharIo\Manifest\AuthorCollectionIterator
|
||||
* @uses \PharIo\Manifest\AuthorElement
|
||||
* @uses \PharIo\Manifest\AuthorElementCollection
|
||||
* @uses \PharIo\Manifest\BundledComponent
|
||||
* @uses \PharIo\Manifest\BundledComponentCollection
|
||||
* @uses \PharIo\Manifest\BundledComponentCollectionIterator
|
||||
* @uses \PharIo\Manifest\BundlesElement
|
||||
* @uses \PharIo\Manifest\ComponentElement
|
||||
* @uses \PharIo\Manifest\ComponentElementCollection
|
||||
* @uses \PharIo\Manifest\ContainsElement
|
||||
* @uses \PharIo\Manifest\CopyrightElement
|
||||
* @uses \PharIo\Manifest\CopyrightInformation
|
||||
* @uses \PharIo\Manifest\ElementCollection
|
||||
* @uses \PharIo\Manifest\Email
|
||||
* @uses \PharIo\Manifest\ExtElement
|
||||
* @uses \PharIo\Manifest\ExtElementCollection
|
||||
* @uses \PharIo\Manifest\License
|
||||
* @uses \PharIo\Manifest\LicenseElement
|
||||
* @uses \PharIo\Manifest\Manifest
|
||||
* @uses \PharIo\Manifest\ManifestDocument
|
||||
* @uses \PharIo\Manifest\ManifestDocumentMapper
|
||||
* @uses \PharIo\Manifest\ManifestElement
|
||||
* @uses \PharIo\Manifest\ManifestLoader
|
||||
* @uses \PharIo\Manifest\PhpElement
|
||||
* @uses \PharIo\Manifest\PhpExtensionRequirement
|
||||
* @uses \PharIo\Manifest\PhpVersionRequirement
|
||||
* @uses \PharIo\Manifest\RequirementCollection
|
||||
* @uses \PharIo\Manifest\RequirementCollectionIterator
|
||||
* @uses \PharIo\Manifest\RequiresElement
|
||||
* @uses \PharIo\Manifest\Type
|
||||
* @uses \PharIo\Manifest\Url
|
||||
* @uses \PharIo\Version\Version
|
||||
* @uses \PharIo\Version\VersionConstraint
|
||||
*/
|
||||
class ManifestSerializerTest extends \PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* @dataProvider dataProvider
|
||||
*
|
||||
* @param $expected
|
||||
*
|
||||
* @uses \PharIo\Manifest\Application
|
||||
* @uses \PharIo\Manifest\Library
|
||||
* @uses \PharIo\Manifest\Extension
|
||||
* @uses \PharIo\Manifest\ExtensionElement
|
||||
*/
|
||||
public function testCanSerializeToString($expected) {
|
||||
$manifest = ManifestLoader::fromString($expected);
|
||||
|
||||
$serializer = new ManifestSerializer();
|
||||
|
||||
$this->assertXmlStringEqualsXmlString(
|
||||
$expected,
|
||||
$serializer->serializeToString($manifest)
|
||||
);
|
||||
}
|
||||
|
||||
public function dataProvider() {
|
||||
return [
|
||||
'application' => [file_get_contents(__DIR__ . '/_fixture/phpunit-5.6.5.xml')],
|
||||
'library' => [file_get_contents(__DIR__ . '/_fixture/library.xml')],
|
||||
'extension' => [file_get_contents(__DIR__ . '/_fixture/extension.xml')]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \PharIo\Manifest\Library
|
||||
* @uses \PharIo\Manifest\ApplicationName
|
||||
*/
|
||||
public function testCanSerializeToFile() {
|
||||
$src = __DIR__ . '/_fixture/library.xml';
|
||||
$dest = '/tmp/' . uniqid('serializer', true);
|
||||
$manifest = ManifestLoader::fromFile($src);
|
||||
$serializer = new ManifestSerializer();
|
||||
$serializer->serializeToFile($manifest, $dest);
|
||||
$this->assertXmlFileEqualsXmlFile($src, $dest);
|
||||
unlink($dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \PharIo\Manifest\ApplicationName
|
||||
*/
|
||||
public function testCanHandleUnknownType() {
|
||||
$type = $this->getMockForAbstractClass(Type::class);
|
||||
$manifest = new Manifest(
|
||||
new ApplicationName('testvendor/testname'),
|
||||
new Version('1.0.0'),
|
||||
$type,
|
||||
new CopyrightInformation(
|
||||
new AuthorCollection(),
|
||||
new License('bsd-3', new Url('https://some/uri'))
|
||||
),
|
||||
new RequirementCollection(),
|
||||
new BundledComponentCollection()
|
||||
);
|
||||
|
||||
$serializer = new ManifestSerializer();
|
||||
$this->assertXmlStringEqualsXmlFile(
|
||||
__DIR__ . '/_fixture/custom.xml',
|
||||
$serializer->serializeToString($manifest)
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phar xmlns="https://phar.io/xml/manifest/1.0">
|
||||
<contains name="testvendor/testname" version="1.0.0" type="custom"/>
|
||||
<copyright>
|
||||
<license type="bsd-3" url="https://some/uri"/>
|
||||
</copyright>
|
||||
<requires>
|
||||
<php version="*"/>
|
||||
</requires>
|
||||
</phar>
|
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phar xmlns="https://phar.io/xml/manifest/1.0">
|
||||
<contains name="phpunit/phpunit-example-extension" version="1.0.0" type="extension">
|
||||
<extension for="phpunit/phpunit" compatible="invalid"/>
|
||||
</contains>
|
||||
<copyright>
|
||||
<author name="Sebastian Bergmann" email="sebastian@phpunit.de"/>
|
||||
<license type="BSD-3-Clause" url="https://github.com/sebastianbergmann/phpunit-example-extension/blob/master/LICENSE"/>
|
||||
</copyright>
|
||||
<requires>
|
||||
<php version="^7.0"/>
|
||||
</requires>
|
||||
</phar>
|
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phar xmlns="https://phar.io/xml/manifest/1.0">
|
||||
<contains name="phpunit/phpunit-example-extension" version="1.0.0" type="extension">
|
||||
<extension for="phpunit/phpunit" compatible="^5.7"/>
|
||||
</contains>
|
||||
<copyright>
|
||||
<author name="Sebastian Bergmann" email="sebastian@phpunit.de"/>
|
||||
<license type="BSD-3-Clause" url="https://github.com/sebastianbergmann/phpunit-example-extension/blob/master/LICENSE"/>
|
||||
</copyright>
|
||||
<requires>
|
||||
<php version="^7.0"/>
|
||||
</requires>
|
||||
</phar>
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phar xmlns="https://phar.io/xml/manifest/1.0">
|
||||
<contains name="some/library" version="abc" type="library" />
|
||||
<copyright>
|
||||
<author name="Reiner Zufall" email="reiner@zufall.de"/>
|
||||
<license type="BSD-3-Clause" url="https://domain.tld/LICENSE"/>
|
||||
</copyright>
|
||||
<requires>
|
||||
<php version="7.0"/>
|
||||
</requires>
|
||||
</phar>
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phar xmlns="https://phar.io/xml/manifest/1.0">
|
||||
<contains name="some/library" version="1.0.0" type="library" />
|
||||
<copyright>
|
||||
<author name="Reiner Zufall" email="reiner@zufall.de"/>
|
||||
<license type="BSD-3-Clause" url="https://domain.tld/LICENSE"/>
|
||||
</copyright>
|
||||
<requires>
|
||||
<php version="invalid"/>
|
||||
</requires>
|
||||
</phar>
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phar xmlns="https://phar.io/xml/manifest/1.0">
|
||||
<contains name="some/library" version="1.0.0" type="library" />
|
||||
<copyright>
|
||||
<author name="Reiner Zufall" email="reiner@zufall.de"/>
|
||||
<license type="BSD-3-Clause" url="https://domain.tld/LICENSE"/>
|
||||
</copyright>
|
||||
<requires>
|
||||
<php version="7.0"/>
|
||||
</requires>
|
||||
</phar>
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phar xmlns="https://phar.io/xml/manifest/1.0">
|
||||
<contains name="some/library" version="1.0.0" type="library" />
|
||||
<copyright>
|
||||
<author name="Reiner Zufall" email="reiner@zufall.de"/>
|
||||
<license type="BSD-3-Clause" url="https://domain.tld/LICENSE"/>
|
||||
</copyright>
|
||||
<requires>
|
||||
<php version="7.0"/>
|
||||
</requires>
|
||||
</phar>
|
@@ -1,46 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phar xmlns="https://phar.io/xml/manifest/1.0">
|
||||
<contains name="phpunit/phpunit" version="5.6.5" type="application"/>
|
||||
<copyright>
|
||||
<author name="Sebastian Bergmann" email="sebastian@phpunit.de"/>
|
||||
<license type="BSD-3-Clause" url="https://github.com/sebastianbergmann/phpunit/blob/master/LICENSE"/>
|
||||
</copyright>
|
||||
<requires>
|
||||
<!-- constraint on next line should be ^5.6 || ^7.0 -->
|
||||
<php version="^7.0">
|
||||
<ext name="dom"/>
|
||||
<ext name="json"/>
|
||||
<ext name="mbstring"/>
|
||||
<ext name="xml"/>
|
||||
<ext name="libxml"/>
|
||||
</php>
|
||||
</requires>
|
||||
<bundles>
|
||||
<component name="doctrine/instantiator" version="1.0.5"/>
|
||||
<component name="myclabs/deep-copy" version="1.5.5"/>
|
||||
<component name="phpdocumentor/reflection-common" version="1.0"/>
|
||||
<component name="phpdocumentor/reflection-docblock" version="3.1.1"/>
|
||||
<component name="phpdocumentor/type-resolver" version="0.2"/>
|
||||
<component name="phpspec/prophecy" version="v1.6.2"/>
|
||||
<component name="phpunit/dbunit" version="2.0.2"/>
|
||||
<component name="phpunit/php-code-coverage" version="4.0.2"/>
|
||||
<component name="phpunit/php-file-iterator" version="1.4.1"/>
|
||||
<component name="phpunit/php-invoker" version="1.1.4"/>
|
||||
<component name="phpunit/php-text-template" version="1.2.1"/>
|
||||
<component name="phpunit/php-timer" version="1.0.8"/>
|
||||
<component name="phpunit/php-token-stream" version="1.4.9"/>
|
||||
<component name="phpunit/phpunit-mock-objects" version="3.4.1"/>
|
||||
<component name="sebastian/code-unit-reverse-lookup" version="1.0.0"/>
|
||||
<component name="sebastian/comparator" version="1.2.2"/>
|
||||
<component name="sebastian/diff" version="1.4.1"/>
|
||||
<component name="sebastian/environment" version="1.3.8"/>
|
||||
<component name="sebastian/exporter" version="2.0.0"/>
|
||||
<component name="sebastian/global-state" version="1.1.1"/>
|
||||
<component name="sebastian/object-enumerator" version="2.0.0"/>
|
||||
<component name="sebastian/recursion-context" version="2.0.0"/>
|
||||
<component name="sebastian/resource-operations" version="1.0.0"/>
|
||||
<component name="sebastian/version" version="2.0.0"/>
|
||||
<component name="symfony/yaml" version="v3.1.7"/>
|
||||
<component name="webmozart/assert" version="1.1.0"/>
|
||||
</bundles>
|
||||
</phar>
|
BIN
vendor/phar-io/manifest/tests/_fixture/test.phar
vendored
BIN
vendor/phar-io/manifest/tests/_fixture/test.phar
vendored
Binary file not shown.
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use DOMDocument;
|
||||
use LibXMLError;
|
||||
|
||||
class ManifestDocumentLoadingExceptionTest extends \PHPUnit\Framework\TestCase {
|
||||
public function testXMLErrorsCanBeRetrieved() {
|
||||
$dom = new DOMDocument();
|
||||
$prev = libxml_use_internal_errors(true);
|
||||
$dom->loadXML('<?xml version="1.0" ?><broken>');
|
||||
$exception = new ManifestDocumentLoadingException(libxml_get_errors());
|
||||
libxml_use_internal_errors($prev);
|
||||
|
||||
$this->assertContainsOnlyInstancesOf(LibXMLError::class, $exception->getLibxmlErrors());
|
||||
}
|
||||
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ApplicationNameTest extends TestCase {
|
||||
|
||||
public function testCanBeCreatedWithValidName() {
|
||||
$this->assertInstanceOf(
|
||||
ApplicationName::class,
|
||||
new ApplicationName('foo/bar')
|
||||
);
|
||||
}
|
||||
|
||||
public function testUsingInvalidFormatForNameThrowsException() {
|
||||
$this->expectException(InvalidApplicationNameException::class);
|
||||
$this->expectExceptionCode(InvalidApplicationNameException::InvalidFormat);
|
||||
new ApplicationName('foo');
|
||||
}
|
||||
|
||||
public function testUsingWrongTypeForNameThrowsException() {
|
||||
$this->expectException(InvalidApplicationNameException::class);
|
||||
$this->expectExceptionCode(InvalidApplicationNameException::NotAString);
|
||||
new ApplicationName(123);
|
||||
}
|
||||
|
||||
public function testReturnsTrueForEqualNamesWhenCompared() {
|
||||
$app = new ApplicationName('foo/bar');
|
||||
$this->assertTrue(
|
||||
$app->isEqual($app)
|
||||
);
|
||||
}
|
||||
|
||||
public function testReturnsFalseForNonEqualNamesWhenCompared() {
|
||||
$app1 = new ApplicationName('foo/bar');
|
||||
$app2 = new ApplicationName('foo/foo');
|
||||
$this->assertFalse(
|
||||
$app1->isEqual($app2)
|
||||
);
|
||||
}
|
||||
|
||||
public function testCanBeConvertedToString() {
|
||||
$this->assertEquals(
|
||||
'foo/bar',
|
||||
new ApplicationName('foo/bar')
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers PharIo\Manifest\Application
|
||||
* @covers PharIo\Manifest\Type
|
||||
*/
|
||||
class ApplicationTest extends TestCase {
|
||||
/**
|
||||
* @var Application
|
||||
*/
|
||||
private $type;
|
||||
|
||||
protected function setUp() {
|
||||
$this->type = Type::application();
|
||||
}
|
||||
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(Application::class, $this->type);
|
||||
}
|
||||
|
||||
public function testIsApplication() {
|
||||
$this->assertTrue($this->type->isApplication());
|
||||
}
|
||||
|
||||
public function testIsNotLibrary() {
|
||||
$this->assertFalse($this->type->isLibrary());
|
||||
}
|
||||
|
||||
public function testIsNotExtension() {
|
||||
$this->assertFalse($this->type->isExtension());
|
||||
}
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \PharIo\Manifest\AuthorCollection
|
||||
* @covers \PharIo\Manifest\AuthorCollectionIterator
|
||||
*
|
||||
* @uses \PharIo\Manifest\Author
|
||||
* @uses \PharIo\Manifest\Email
|
||||
*/
|
||||
class AuthorCollectionTest extends TestCase {
|
||||
/**
|
||||
* @var AuthorCollection
|
||||
*/
|
||||
private $collection;
|
||||
|
||||
/**
|
||||
* @var Author
|
||||
*/
|
||||
private $item;
|
||||
|
||||
protected function setUp() {
|
||||
$this->collection = new AuthorCollection;
|
||||
$this->item = new Author('Joe Developer', new Email('user@example.com'));
|
||||
}
|
||||
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(AuthorCollection::class, $this->collection);
|
||||
}
|
||||
|
||||
public function testCanBeCounted() {
|
||||
$this->collection->add($this->item);
|
||||
|
||||
$this->assertCount(1, $this->collection);
|
||||
}
|
||||
|
||||
public function testCanBeIterated() {
|
||||
$this->collection->add(
|
||||
new Author('Dummy First', new Email('dummy@example.com'))
|
||||
);
|
||||
$this->collection->add($this->item);
|
||||
$this->assertContains($this->item, $this->collection);
|
||||
}
|
||||
|
||||
public function testKeyPositionCanBeRetreived() {
|
||||
$this->collection->add($this->item);
|
||||
foreach($this->collection as $key => $item) {
|
||||
$this->assertEquals(0, $key);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers PharIo\Manifest\Author
|
||||
*
|
||||
* @uses PharIo\Manifest\Email
|
||||
*/
|
||||
class AuthorTest extends TestCase {
|
||||
/**
|
||||
* @var Author
|
||||
*/
|
||||
private $author;
|
||||
|
||||
protected function setUp() {
|
||||
$this->author = new Author('Joe Developer', new Email('user@example.com'));
|
||||
}
|
||||
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(Author::class, $this->author);
|
||||
}
|
||||
|
||||
public function testNameCanBeRetrieved() {
|
||||
$this->assertEquals('Joe Developer', $this->author->getName());
|
||||
}
|
||||
|
||||
public function testEmailCanBeRetrieved() {
|
||||
$this->assertEquals('user@example.com', $this->author->getEmail());
|
||||
}
|
||||
|
||||
public function testCanBeUsedAsString() {
|
||||
$this->assertEquals('Joe Developer <user@example.com>', $this->author);
|
||||
}
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\Version;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \PharIo\Manifest\BundledComponentCollection
|
||||
* @covers \PharIo\Manifest\BundledComponentCollectionIterator
|
||||
*
|
||||
* @uses \PharIo\Manifest\BundledComponent
|
||||
* @uses \PharIo\Version\Version
|
||||
*/
|
||||
class BundledComponentCollectionTest extends TestCase {
|
||||
/**
|
||||
* @var BundledComponentCollection
|
||||
*/
|
||||
private $collection;
|
||||
|
||||
/**
|
||||
* @var BundledComponent
|
||||
*/
|
||||
private $item;
|
||||
|
||||
protected function setUp() {
|
||||
$this->collection = new BundledComponentCollection;
|
||||
$this->item = new BundledComponent('phpunit/php-code-coverage', new Version('4.0.2'));
|
||||
}
|
||||
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(BundledComponentCollection::class, $this->collection);
|
||||
}
|
||||
|
||||
public function testCanBeCounted() {
|
||||
$this->collection->add($this->item);
|
||||
|
||||
$this->assertCount(1, $this->collection);
|
||||
}
|
||||
|
||||
public function testCanBeIterated() {
|
||||
$this->collection->add($this->createMock(BundledComponent::class));
|
||||
$this->collection->add($this->item);
|
||||
|
||||
$this->assertContains($this->item, $this->collection);
|
||||
}
|
||||
|
||||
public function testKeyPositionCanBeRetreived() {
|
||||
$this->collection->add($this->item);
|
||||
foreach($this->collection as $key => $item) {
|
||||
$this->assertEquals(0, $key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\Version;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers PharIo\Manifest\BundledComponent
|
||||
*
|
||||
* @uses \PharIo\Version\Version
|
||||
*/
|
||||
class BundledComponentTest extends TestCase {
|
||||
/**
|
||||
* @var BundledComponent
|
||||
*/
|
||||
private $bundledComponent;
|
||||
|
||||
protected function setUp() {
|
||||
$this->bundledComponent = new BundledComponent('phpunit/php-code-coverage', new Version('4.0.2'));
|
||||
}
|
||||
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(BundledComponent::class, $this->bundledComponent);
|
||||
}
|
||||
|
||||
public function testNameCanBeRetrieved() {
|
||||
$this->assertEquals('phpunit/php-code-coverage', $this->bundledComponent->getName());
|
||||
}
|
||||
|
||||
public function testVersionCanBeRetrieved() {
|
||||
$this->assertEquals('4.0.2', $this->bundledComponent->getVersion()->getVersionString());
|
||||
}
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers PharIo\Manifest\CopyrightInformation
|
||||
*
|
||||
* @uses PharIo\Manifest\AuthorCollection
|
||||
* @uses PharIo\Manifest\AuthorCollectionIterator
|
||||
* @uses PharIo\Manifest\Author
|
||||
* @uses PharIo\Manifest\Email
|
||||
* @uses PharIo\Manifest\License
|
||||
* @uses PharIo\Manifest\Url
|
||||
*/
|
||||
class CopyrightInformationTest extends TestCase {
|
||||
/**
|
||||
* @var CopyrightInformation
|
||||
*/
|
||||
private $copyrightInformation;
|
||||
|
||||
/**
|
||||
* @var Author
|
||||
*/
|
||||
private $author;
|
||||
|
||||
/**
|
||||
* @var License
|
||||
*/
|
||||
private $license;
|
||||
|
||||
protected function setUp() {
|
||||
$this->author = new Author('Joe Developer', new Email('user@example.com'));
|
||||
$this->license = new License('BSD-3-Clause', new Url('https://github.com/sebastianbergmann/phpunit/blob/master/LICENSE'));
|
||||
|
||||
$authors = new AuthorCollection;
|
||||
$authors->add($this->author);
|
||||
|
||||
$this->copyrightInformation = new CopyrightInformation($authors, $this->license);
|
||||
}
|
||||
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(CopyrightInformation::class, $this->copyrightInformation);
|
||||
}
|
||||
|
||||
public function testAuthorsCanBeRetrieved() {
|
||||
$this->assertContains($this->author, $this->copyrightInformation->getAuthors());
|
||||
}
|
||||
|
||||
public function testLicenseCanBeRetrieved() {
|
||||
$this->assertEquals($this->license, $this->copyrightInformation->getLicense());
|
||||
}
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers PharIo\Manifest\Email
|
||||
*/
|
||||
class EmailTest extends TestCase {
|
||||
public function testCanBeCreatedForValidEmail() {
|
||||
$this->assertInstanceOf(Email::class, new Email('user@example.com'));
|
||||
}
|
||||
|
||||
public function testCanBeUsedAsString() {
|
||||
$this->assertEquals('user@example.com', new Email('user@example.com'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PharIo\Manifest\InvalidEmailException
|
||||
*/
|
||||
public function testCannotBeCreatedForInvalidEmail() {
|
||||
$this->expectException(InvalidEmailException::class);
|
||||
|
||||
new Email('invalid');
|
||||
}
|
||||
}
|
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\AnyVersionConstraint;
|
||||
use PharIo\Version\Version;
|
||||
use PharIo\Version\VersionConstraint;
|
||||
use PharIo\Version\VersionConstraintParser;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \PharIo\Manifest\Extension
|
||||
* @covers \PharIo\Manifest\Type
|
||||
*
|
||||
* @uses \PharIo\Version\VersionConstraint
|
||||
* @uses \PharIo\Manifest\ApplicationName
|
||||
*/
|
||||
class ExtensionTest extends TestCase {
|
||||
/**
|
||||
* @var Extension
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var ApplicationName|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $name;
|
||||
|
||||
protected function setUp() {
|
||||
$this->name = $this->createMock(ApplicationName::class);
|
||||
$this->type = Type::extension($this->name, new AnyVersionConstraint);
|
||||
}
|
||||
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(Extension::class, $this->type);
|
||||
}
|
||||
|
||||
public function testIsNotApplication() {
|
||||
$this->assertFalse($this->type->isApplication());
|
||||
}
|
||||
|
||||
public function testIsNotLibrary() {
|
||||
$this->assertFalse($this->type->isLibrary());
|
||||
}
|
||||
|
||||
public function testIsExtension() {
|
||||
$this->assertTrue($this->type->isExtension());
|
||||
}
|
||||
|
||||
public function testApplicationCanBeRetrieved()
|
||||
{
|
||||
$this->assertInstanceOf(ApplicationName::class, $this->type->getApplicationName());
|
||||
}
|
||||
|
||||
public function testVersionConstraintCanBeRetrieved() {
|
||||
$this->assertInstanceOf(
|
||||
VersionConstraint::class,
|
||||
$this->type->getVersionConstraint()
|
||||
);
|
||||
}
|
||||
|
||||
public function testApplicationCanBeQueried()
|
||||
{
|
||||
$this->name->method('isEqual')->willReturn(true);
|
||||
$this->assertTrue(
|
||||
$this->type->isExtensionFor($this->createMock(ApplicationName::class))
|
||||
);
|
||||
}
|
||||
|
||||
public function testCompatibleWithReturnsTrueForMatchingVersionConstraintAndApplicaiton() {
|
||||
$app = new ApplicationName('foo/bar');
|
||||
$extension = Type::extension($app, (new VersionConstraintParser)->parse('^1.0'));
|
||||
$version = new Version('1.0.0');
|
||||
|
||||
$this->assertTrue(
|
||||
$extension->isCompatibleWith($app, $version)
|
||||
);
|
||||
}
|
||||
|
||||
public function testCompatibleWithReturnsFalseForNotMatchingVersionConstraint() {
|
||||
$app = new ApplicationName('foo/bar');
|
||||
$extension = Type::extension($app, (new VersionConstraintParser)->parse('^1.0'));
|
||||
$version = new Version('2.0.0');
|
||||
|
||||
$this->assertFalse(
|
||||
$extension->isCompatibleWith($app, $version)
|
||||
);
|
||||
}
|
||||
|
||||
public function testCompatibleWithReturnsFalseForNotMatchingApplication() {
|
||||
$app1 = new ApplicationName('foo/bar');
|
||||
$app2 = new ApplicationName('foo/foo');
|
||||
$extension = Type::extension($app1, (new VersionConstraintParser)->parse('^1.0'));
|
||||
$version = new Version('1.0.0');
|
||||
|
||||
$this->assertFalse(
|
||||
$extension->isCompatibleWith($app2, $version)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers PharIo\Manifest\Library
|
||||
* @covers PharIo\Manifest\Type
|
||||
*/
|
||||
class LibraryTest extends TestCase {
|
||||
/**
|
||||
* @var Library
|
||||
*/
|
||||
private $type;
|
||||
|
||||
protected function setUp() {
|
||||
$this->type = Type::library();
|
||||
}
|
||||
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(Library::class, $this->type);
|
||||
}
|
||||
|
||||
public function testIsNotApplication() {
|
||||
$this->assertFalse($this->type->isApplication());
|
||||
}
|
||||
|
||||
public function testIsLibrary() {
|
||||
$this->assertTrue($this->type->isLibrary());
|
||||
}
|
||||
|
||||
public function testIsNotExtension() {
|
||||
$this->assertFalse($this->type->isExtension());
|
||||
}
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers PharIo\Manifest\License
|
||||
*
|
||||
* @uses PharIo\Manifest\Url
|
||||
*/
|
||||
class LicenseTest extends TestCase {
|
||||
/**
|
||||
* @var License
|
||||
*/
|
||||
private $license;
|
||||
|
||||
protected function setUp() {
|
||||
$this->license = new License('BSD-3-Clause', new Url('https://github.com/sebastianbergmann/phpunit/blob/master/LICENSE'));
|
||||
}
|
||||
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(License::class, $this->license);
|
||||
}
|
||||
|
||||
public function testNameCanBeRetrieved() {
|
||||
$this->assertEquals('BSD-3-Clause', $this->license->getName());
|
||||
}
|
||||
|
||||
public function testUrlCanBeRetrieved() {
|
||||
$this->assertEquals('https://github.com/sebastianbergmann/phpunit/blob/master/LICENSE', $this->license->getUrl());
|
||||
}
|
||||
}
|
@@ -1,187 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\Version;
|
||||
use PharIo\Version\AnyVersionConstraint;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \PharIo\Manifest\Manifest
|
||||
*
|
||||
* @uses \PharIo\Manifest\ApplicationName
|
||||
* @uses \PharIo\Manifest\Author
|
||||
* @uses \PharIo\Manifest\AuthorCollection
|
||||
* @uses \PharIo\Manifest\BundledComponent
|
||||
* @uses \PharIo\Manifest\BundledComponentCollection
|
||||
* @uses \PharIo\Manifest\CopyrightInformation
|
||||
* @uses \PharIo\Manifest\Email
|
||||
* @uses \PharIo\Manifest\License
|
||||
* @uses \PharIo\Manifest\RequirementCollection
|
||||
* @uses \PharIo\Manifest\PhpVersionRequirement
|
||||
* @uses \PharIo\Manifest\Type
|
||||
* @uses \PharIo\Manifest\Application
|
||||
* @uses \PharIo\Manifest\Url
|
||||
* @uses \PharIo\Version\Version
|
||||
* @uses \PharIo\Version\VersionConstraint
|
||||
*/
|
||||
class ManifestTest extends TestCase {
|
||||
/**
|
||||
* @var ApplicationName
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var Version
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* @var Type
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var CopyrightInformation
|
||||
*/
|
||||
private $copyrightInformation;
|
||||
|
||||
/**
|
||||
* @var RequirementCollection
|
||||
*/
|
||||
private $requirements;
|
||||
|
||||
/**
|
||||
* @var BundledComponentCollection
|
||||
*/
|
||||
private $bundledComponents;
|
||||
|
||||
/**
|
||||
* @var Manifest
|
||||
*/
|
||||
private $manifest;
|
||||
|
||||
protected function setUp() {
|
||||
$this->version = new Version('5.6.5');
|
||||
|
||||
$this->type = Type::application();
|
||||
|
||||
$author = new Author('Joe Developer', new Email('user@example.com'));
|
||||
$license = new License('BSD-3-Clause', new Url('https://github.com/sebastianbergmann/phpunit/blob/master/LICENSE'));
|
||||
|
||||
$authors = new AuthorCollection;
|
||||
$authors->add($author);
|
||||
|
||||
$this->copyrightInformation = new CopyrightInformation($authors, $license);
|
||||
|
||||
$this->requirements = new RequirementCollection;
|
||||
$this->requirements->add(new PhpVersionRequirement(new AnyVersionConstraint));
|
||||
|
||||
$this->bundledComponents = new BundledComponentCollection;
|
||||
$this->bundledComponents->add(new BundledComponent('phpunit/php-code-coverage', new Version('4.0.2')));
|
||||
|
||||
$this->name = new ApplicationName('phpunit/phpunit');
|
||||
|
||||
$this->manifest = new Manifest(
|
||||
$this->name,
|
||||
$this->version,
|
||||
$this->type,
|
||||
$this->copyrightInformation,
|
||||
$this->requirements,
|
||||
$this->bundledComponents
|
||||
);
|
||||
}
|
||||
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(Manifest::class, $this->manifest);
|
||||
}
|
||||
|
||||
public function testNameCanBeRetrieved() {
|
||||
$this->assertEquals($this->name, $this->manifest->getName());
|
||||
}
|
||||
|
||||
public function testVersionCanBeRetrieved() {
|
||||
$this->assertEquals($this->version, $this->manifest->getVersion());
|
||||
}
|
||||
|
||||
public function testTypeCanBeRetrieved() {
|
||||
$this->assertEquals($this->type, $this->manifest->getType());
|
||||
}
|
||||
|
||||
public function testTypeCanBeQueried() {
|
||||
$this->assertTrue($this->manifest->isApplication());
|
||||
$this->assertFalse($this->manifest->isLibrary());
|
||||
$this->assertFalse($this->manifest->isExtension());
|
||||
}
|
||||
|
||||
public function testCopyrightInformationCanBeRetrieved() {
|
||||
$this->assertEquals($this->copyrightInformation, $this->manifest->getCopyrightInformation());
|
||||
}
|
||||
|
||||
public function testRequirementsCanBeRetrieved() {
|
||||
$this->assertEquals($this->requirements, $this->manifest->getRequirements());
|
||||
}
|
||||
|
||||
public function testBundledComponentsCanBeRetrieved() {
|
||||
$this->assertEquals($this->bundledComponents, $this->manifest->getBundledComponents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \PharIo\Manifest\Extension
|
||||
*/
|
||||
public function testExtendedApplicationCanBeQueriedForExtension()
|
||||
{
|
||||
$appName = new ApplicationName('foo/bar');
|
||||
$manifest = new Manifest(
|
||||
new ApplicationName('foo/foo'),
|
||||
new Version('1.0.0'),
|
||||
Type::extension($appName, new AnyVersionConstraint),
|
||||
$this->copyrightInformation,
|
||||
new RequirementCollection,
|
||||
new BundledComponentCollection
|
||||
);
|
||||
|
||||
$this->assertTrue($manifest->isExtensionFor($appName));
|
||||
}
|
||||
|
||||
public function testNonExtensionReturnsFalseWhenQueriesForExtension() {
|
||||
$appName = new ApplicationName('foo/bar');
|
||||
$manifest = new Manifest(
|
||||
new ApplicationName('foo/foo'),
|
||||
new Version('1.0.0'),
|
||||
Type::library(),
|
||||
$this->copyrightInformation,
|
||||
new RequirementCollection,
|
||||
new BundledComponentCollection
|
||||
);
|
||||
|
||||
$this->assertFalse($manifest->isExtensionFor($appName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @uses \PharIo\Manifest\Extension
|
||||
*/
|
||||
public function testExtendedApplicationCanBeQueriedForExtensionWithVersion()
|
||||
{
|
||||
$appName = new ApplicationName('foo/bar');
|
||||
$manifest = new Manifest(
|
||||
new ApplicationName('foo/foo'),
|
||||
new Version('1.0.0'),
|
||||
Type::extension($appName, new AnyVersionConstraint),
|
||||
$this->copyrightInformation,
|
||||
new RequirementCollection,
|
||||
new BundledComponentCollection
|
||||
);
|
||||
|
||||
$this->assertTrue($manifest->isExtensionFor($appName, new Version('1.2.3')));
|
||||
}
|
||||
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers PharIo\Manifest\PhpExtensionRequirement
|
||||
*/
|
||||
class PhpExtensionRequirementTest extends TestCase {
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(PhpExtensionRequirement::class, new PhpExtensionRequirement('dom'));
|
||||
}
|
||||
|
||||
public function testCanBeUsedAsString() {
|
||||
$this->assertEquals('dom', new PhpExtensionRequirement('dom'));
|
||||
}
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\ExactVersionConstraint;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers PharIo\Manifest\PhpVersionRequirement
|
||||
*
|
||||
* @uses \PharIo\Version\VersionConstraint
|
||||
*/
|
||||
class PhpVersionRequirementTest extends TestCase {
|
||||
/**
|
||||
* @var PhpVersionRequirement
|
||||
*/
|
||||
private $requirement;
|
||||
|
||||
protected function setUp() {
|
||||
$this->requirement = new PhpVersionRequirement(new ExactVersionConstraint('7.1.0'));
|
||||
}
|
||||
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(PhpVersionRequirement::class, $this->requirement);
|
||||
}
|
||||
|
||||
public function testVersionConstraintCanBeRetrieved() {
|
||||
$this->assertEquals('7.1.0', $this->requirement->getVersionConstraint()->asString());
|
||||
}
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PharIo\Version\ExactVersionConstraint;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \PharIo\Manifest\RequirementCollection
|
||||
* @covers \PharIo\Manifest\RequirementCollectionIterator
|
||||
*
|
||||
* @uses \PharIo\Manifest\PhpVersionRequirement
|
||||
* @uses \PharIo\Version\VersionConstraint
|
||||
*/
|
||||
class RequirementCollectionTest extends TestCase {
|
||||
/**
|
||||
* @var RequirementCollection
|
||||
*/
|
||||
private $collection;
|
||||
|
||||
/**
|
||||
* @var Requirement
|
||||
*/
|
||||
private $item;
|
||||
|
||||
protected function setUp() {
|
||||
$this->collection = new RequirementCollection;
|
||||
$this->item = new PhpVersionRequirement(new ExactVersionConstraint('7.1.0'));
|
||||
}
|
||||
|
||||
public function testCanBeCreated() {
|
||||
$this->assertInstanceOf(RequirementCollection::class, $this->collection);
|
||||
}
|
||||
|
||||
public function testCanBeCounted() {
|
||||
$this->collection->add($this->item);
|
||||
|
||||
$this->assertCount(1, $this->collection);
|
||||
}
|
||||
|
||||
public function testCanBeIterated() {
|
||||
$this->collection->add(new PhpVersionRequirement(new ExactVersionConstraint('5.6.0')));
|
||||
$this->collection->add($this->item);
|
||||
|
||||
$this->assertContains($this->item, $this->collection);
|
||||
}
|
||||
|
||||
public function testKeyPositionCanBeRetreived() {
|
||||
$this->collection->add($this->item);
|
||||
foreach($this->collection as $key => $item) {
|
||||
$this->assertEquals(0, $key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
35
vendor/phar-io/manifest/tests/values/UrlTest.php
vendored
35
vendor/phar-io/manifest/tests/values/UrlTest.php
vendored
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PharIo\Manifest.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers PharIo\Manifest\Url
|
||||
*/
|
||||
class UrlTest extends TestCase {
|
||||
public function testCanBeCreatedForValidUrl() {
|
||||
$this->assertInstanceOf(Url::class, new Url('https://phar.io/'));
|
||||
}
|
||||
|
||||
public function testCanBeUsedAsString() {
|
||||
$this->assertEquals('https://phar.io/', new Url('https://phar.io/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PharIo\Manifest\InvalidUrlException
|
||||
*/
|
||||
public function testCannotBeCreatedForInvalidUrl() {
|
||||
$this->expectException(InvalidUrlException::class);
|
||||
|
||||
new Url('invalid');
|
||||
}
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use DOMDocument;
|
||||
|
||||
class AuthorElementCollectionTest extends \PHPUnit\Framework\TestCase {
|
||||
public function testAuthorElementCanBeRetrievedFromCollection() {
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML('<?xml version="1.0" ?><author xmlns="https://phar.io/xml/manifest/1.0" name="Reiner Zufall" email="reiner@zufall.de" />');
|
||||
$collection = new AuthorElementCollection($dom->childNodes);
|
||||
|
||||
foreach($collection as $authorElement) {
|
||||
$this->assertInstanceOf(AuthorElement::class, $authorElement);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class AuthorElementTest extends \PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* @var AuthorElement
|
||||
*/
|
||||
private $author;
|
||||
|
||||
protected function setUp() {
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadXML('<?xml version="1.0" ?><author xmlns="https://phar.io/xml/manifest/1.0" name="Reiner Zufall" email="reiner@zufall.de" />');
|
||||
$this->author = new AuthorElement($dom->documentElement);
|
||||
}
|
||||
|
||||
public function testNameCanBeRetrieved() {
|
||||
$this->assertEquals('Reiner Zufall', $this->author->getName());
|
||||
}
|
||||
|
||||
public function testEmailCanBeRetrieved() {
|
||||
$this->assertEquals('reiner@zufall.de', $this->author->getEmail());
|
||||
}
|
||||
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use DOMDocument;
|
||||
|
||||
class BundlesElementTest extends \PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* @var DOMDocument
|
||||
*/
|
||||
private $dom;
|
||||
|
||||
/**
|
||||
* @var BundlesElement
|
||||
*/
|
||||
private $bundles;
|
||||
|
||||
protected function setUp() {
|
||||
$this->dom = new DOMDocument();
|
||||
$this->dom->loadXML('<?xml version="1.0" ?><bundles xmlns="https://phar.io/xml/manifest/1.0" />');
|
||||
$this->bundles = new BundlesElement($this->dom->documentElement);
|
||||
}
|
||||
|
||||
public function testThrowsExceptionWhenGetComponentElementsIsCalledButNodesAreMissing() {
|
||||
$this->expectException(ManifestElementException::class);
|
||||
$this->bundles->getComponentElements();
|
||||
}
|
||||
|
||||
public function testGetComponentElementsReturnsComponentElementCollection() {
|
||||
$this->addComponent();
|
||||
$this->assertInstanceOf(
|
||||
ComponentElementCollection::class, $this->bundles->getComponentElements()
|
||||
);
|
||||
}
|
||||
|
||||
private function addComponent() {
|
||||
$this->dom->documentElement->appendChild(
|
||||
$this->dom->createElementNS('https://phar.io/xml/manifest/1.0', 'component')
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use DOMDocument;
|
||||
|
||||
class ComponentElementCollectionTest extends \PHPUnit\Framework\TestCase {
|
||||
public function testComponentElementCanBeRetrievedFromCollection() {
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML('<?xml version="1.0" ?><component xmlns="https://phar.io/xml/manifest/1.0" />');
|
||||
$collection = new ComponentElementCollection($dom->childNodes);
|
||||
|
||||
foreach($collection as $componentElement) {
|
||||
$this->assertInstanceOf(ComponentElement::class, $componentElement);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ComponentElementTest extends \PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* @var ComponentElement
|
||||
*/
|
||||
private $component;
|
||||
|
||||
protected function setUp() {
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadXML('<?xml version="1.0" ?><component xmlns="https://phar.io/xml/manifest/1.0" name="phar-io/phive" version="0.6.0" />');
|
||||
$this->component = new ComponentElement($dom->documentElement);
|
||||
}
|
||||
|
||||
public function testNameCanBeRetrieved() {
|
||||
$this->assertEquals('phar-io/phive', $this->component->getName());
|
||||
}
|
||||
|
||||
public function testEmailCanBeRetrieved() {
|
||||
$this->assertEquals('0.6.0', $this->component->getVersion());
|
||||
}
|
||||
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
|
||||
class ContainsElementTest extends \PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* @var DOMElement
|
||||
*/
|
||||
private $domElement;
|
||||
|
||||
/**
|
||||
* @var ContainsElement
|
||||
*/
|
||||
private $contains;
|
||||
|
||||
protected function setUp() {
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML('<?xml version="1.0" ?><php xmlns="https://phar.io/xml/manifest/1.0" name="phpunit/phpunit" version="5.6.5" type="application" />');
|
||||
$this->domElement = $dom->documentElement;
|
||||
$this->contains = new ContainsElement($this->domElement);
|
||||
}
|
||||
|
||||
public function testVersionCanBeRetrieved() {
|
||||
$this->assertEquals('5.6.5', $this->contains->getVersion());
|
||||
}
|
||||
|
||||
public function testThrowsExceptionWhenVersionAttributeIsMissing() {
|
||||
$this->domElement->removeAttribute('version');
|
||||
$this->expectException(ManifestElementException::class);
|
||||
$this->contains->getVersion();
|
||||
}
|
||||
|
||||
public function testNameCanBeRetrieved() {
|
||||
$this->assertEquals('phpunit/phpunit', $this->contains->getName());
|
||||
}
|
||||
|
||||
public function testThrowsExceptionWhenNameAttributeIsMissing() {
|
||||
$this->domElement->removeAttribute('name');
|
||||
$this->expectException(ManifestElementException::class);
|
||||
$this->contains->getName();
|
||||
}
|
||||
|
||||
public function testTypeCanBeRetrieved() {
|
||||
$this->assertEquals('application', $this->contains->getType());
|
||||
}
|
||||
|
||||
public function testThrowsExceptionWhenTypeAttributeIsMissing() {
|
||||
$this->domElement->removeAttribute('type');
|
||||
$this->expectException(ManifestElementException::class);
|
||||
$this->contains->getType();
|
||||
}
|
||||
|
||||
public function testGetExtensionElementReturnsExtensionElement() {
|
||||
$this->domElement->appendChild(
|
||||
$this->domElement->ownerDocument->createElementNS('https://phar.io/xml/manifest/1.0', 'extension')
|
||||
);
|
||||
$this->assertInstanceOf(ExtensionElement::class, $this->contains->getExtensionElement());
|
||||
}
|
||||
|
||||
}
|
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use DOMDocument;
|
||||
|
||||
class CopyrightElementTest extends \PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* @var DOMDocument
|
||||
*/
|
||||
private $dom;
|
||||
|
||||
/**
|
||||
* @var CopyrightElement
|
||||
*/
|
||||
private $copyright;
|
||||
|
||||
protected function setUp() {
|
||||
$this->dom = new DOMDocument();
|
||||
$this->dom->loadXML('<?xml version="1.0" ?><copyright xmlns="https://phar.io/xml/manifest/1.0" />');
|
||||
$this->copyright = new CopyrightElement($this->dom->documentElement);
|
||||
}
|
||||
|
||||
public function testThrowsExceptionWhenGetAuthroElementsIsCalledButNodesAreMissing() {
|
||||
$this->expectException(ManifestElementException::class);
|
||||
$this->copyright->getAuthorElements();
|
||||
}
|
||||
|
||||
public function testThrowsExceptionWhenGetLicenseElementIsCalledButNodeIsMissing() {
|
||||
$this->expectException(ManifestElementException::class);
|
||||
$this->copyright->getLicenseElement();
|
||||
}
|
||||
|
||||
public function testGetAuthorElementsReturnsAuthorElementCollection() {
|
||||
$this->dom->documentElement->appendChild(
|
||||
$this->dom->createElementNS('https://phar.io/xml/manifest/1.0', 'author')
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
AuthorElementCollection::class, $this->copyright->getAuthorElements()
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetLicenseElementReturnsLicenseElement() {
|
||||
$this->dom->documentElement->appendChild(
|
||||
$this->dom->createElementNS('https://phar.io/xml/manifest/1.0', 'license')
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
LicenseElement::class, $this->copyright->getLicenseElement()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
use DOMDocument;
|
||||
|
||||
class ExtElementCollectionTest extends \PHPUnit\Framework\TestCase {
|
||||
public function testComponentElementCanBeRetrievedFromCollection() {
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML('<?xml version="1.0" ?><ext xmlns="https://phar.io/xml/manifest/1.0" />');
|
||||
$collection = new ExtElementCollection($dom->childNodes);
|
||||
|
||||
foreach($collection as $position => $extElement) {
|
||||
$this->assertInstanceOf(ExtElement::class, $extElement);
|
||||
$this->assertEquals(0, $position);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ExtElementTest extends \PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* @var ExtElement
|
||||
*/
|
||||
private $ext;
|
||||
|
||||
protected function setUp() {
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadXML('<?xml version="1.0" ?><ext xmlns="https://phar.io/xml/manifest/1.0" name="dom" />');
|
||||
$this->ext = new ExtElement($dom->documentElement);
|
||||
}
|
||||
|
||||
public function testNameCanBeRetrieved() {
|
||||
$this->assertEquals('dom', $this->ext->getName());
|
||||
}
|
||||
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PharIo\Manifest;
|
||||
|
||||
class ExtensionElementTest extends \PHPUnit\Framework\TestCase {
|
||||
/**
|
||||
* @var ExtensionElement
|
||||
*/
|
||||
private $extension;
|
||||
|
||||
protected function setUp() {
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadXML('<?xml version="1.0" ?><extension xmlns="https://phar.io/xml/manifest/1.0" for="phar-io/phive" compatible="~0.6" />');
|
||||
$this->extension = new ExtensionElement($dom->documentElement);
|
||||
}
|
||||
|
||||
public function testNForCanBeRetrieved() {
|
||||
$this->assertEquals('phar-io/phive', $this->extension->getFor());
|
||||
}
|
||||
|
||||
public function testCompatibleVersionConstraintCanBeRetrieved() {
|
||||
$this->assertEquals('~0.6', $this->extension->getCompatible());
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user