Repository: phar-io/manifest
Branch: master
Commit: c581d4941e19
Files: 112
Total size: 159.4 KB
Directory structure:
gitextract_flwa4hbi/
├── .gitattributes
├── .github/
│ ├── FUNDING.yml
│ └── workflows/
│ └── ci.yml
├── .gitignore
├── .php-cs-fixer.dist.php
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.xml
├── composer.json
├── examples/
│ ├── example-01.php
│ └── example-02.php
├── manifest.xsd
├── phive.xml
├── phpunit.xml
├── psalm.xml
├── src/
│ ├── ManifestDocumentMapper.php
│ ├── ManifestLoader.php
│ ├── ManifestSerializer.php
│ ├── exceptions/
│ │ ├── ElementCollectionException.php
│ │ ├── Exception.php
│ │ ├── InvalidApplicationNameException.php
│ │ ├── InvalidEmailException.php
│ │ ├── InvalidUrlException.php
│ │ ├── ManifestDocumentException.php
│ │ ├── ManifestDocumentLoadingException.php
│ │ ├── ManifestDocumentMapperException.php
│ │ ├── ManifestElementException.php
│ │ ├── ManifestLoaderException.php
│ │ └── NoEmailAddressException.php
│ ├── values/
│ │ ├── Application.php
│ │ ├── ApplicationName.php
│ │ ├── Author.php
│ │ ├── AuthorCollection.php
│ │ ├── AuthorCollectionIterator.php
│ │ ├── BundledComponent.php
│ │ ├── BundledComponentCollection.php
│ │ ├── BundledComponentCollectionIterator.php
│ │ ├── CopyrightInformation.php
│ │ ├── Email.php
│ │ ├── Extension.php
│ │ ├── Library.php
│ │ ├── License.php
│ │ ├── Manifest.php
│ │ ├── PhpExtensionRequirement.php
│ │ ├── PhpVersionRequirement.php
│ │ ├── Requirement.php
│ │ ├── RequirementCollection.php
│ │ ├── RequirementCollectionIterator.php
│ │ ├── Type.php
│ │ └── Url.php
│ └── xml/
│ ├── AuthorElement.php
│ ├── AuthorElementCollection.php
│ ├── BundlesElement.php
│ ├── ComponentElement.php
│ ├── ComponentElementCollection.php
│ ├── ContainsElement.php
│ ├── CopyrightElement.php
│ ├── ElementCollection.php
│ ├── ExtElement.php
│ ├── ExtElementCollection.php
│ ├── ExtensionElement.php
│ ├── LicenseElement.php
│ ├── ManifestDocument.php
│ ├── ManifestElement.php
│ ├── PhpElement.php
│ └── RequiresElement.php
└── tests/
├── ManifestDocumentMapperTest.php
├── ManifestLoaderTest.php
├── ManifestSerializerTest.php
├── _fixture/
│ ├── custom.xml
│ ├── extension-invalidcompatible.xml
│ ├── extension.xml
│ ├── invalidversion.xml
│ ├── invalidversionconstraint.xml
│ ├── library.xml
│ ├── manifest.xml
│ ├── noemailauthor.xml
│ ├── phpunit-5.6.5.xml
│ └── test.phar
├── exceptions/
│ └── ManifestDocumentLoadingExceptionTest.php
├── values/
│ ├── ApplicationNameTest.php
│ ├── ApplicationTest.php
│ ├── AuthorCollectionTest.php
│ ├── AuthorTest.php
│ ├── BundledComponentCollectionTest.php
│ ├── BundledComponentTest.php
│ ├── CopyrightInformationTest.php
│ ├── EmailTest.php
│ ├── ExtensionTest.php
│ ├── LibraryTest.php
│ ├── LicenseTest.php
│ ├── ManifestTest.php
│ ├── PhpExtensionRequirementTest.php
│ ├── PhpVersionRequirementTest.php
│ ├── RequirementCollectionTest.php
│ └── UrlTest.php
└── xml/
├── AuthorElementCollectionTest.php
├── AuthorElementTest.php
├── BundlesElementTest.php
├── ComponentElementCollectionTest.php
├── ComponentElementTest.php
├── ContainsElementTest.php
├── CopyrightElementTest.php
├── ElementCollectionTest.php
├── ExtElementCollectionTest.php
├── ExtElementTest.php
├── ExtensionElementTest.php
├── LicenseElementTest.php
├── ManifestDocumentTest.php
├── PhpElementTest.php
└── RequiresElementTest.php
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
/.github export-ignore
/build export-ignore
/examples export-ignore
/tests export-ignore
/tools export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs.dist.php export-ignore
/build.xml export-ignore
/phive.xml export-ignore
/phpunit.xml export-ignore
/psalm.xml export-ignore
================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
github: [theseer]
================================================
FILE: .github/workflows/ci.yml
================================================
name: "CI"
on:
push:
branches:
- "master"
pull_request: null
jobs:
qa:
name: "QA"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v3.5.2"
- name: "Set up PHP"
uses: "shivammathur/setup-php@2.25.1"
with:
coverage: "none"
php-version: "8.0"
tools: "phive"
- name: "Install dependencies with composer"
run: "composer install --no-interaction --optimize-autoloader --prefer-dist"
- name: "Install dependencies with phive"
env:
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: "ant install-tools"
- name: "Run php-cs-fixer"
run: "ant php-cs-fixer"
- name: "Run psalm"
run: "ant psalm"
tests:
name: "Tests"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
php-versions:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"
steps:
- name: "Checkout"
uses: "actions/checkout@v3.5.2"
- name: "Set up PHP"
uses: "shivammathur/setup-php@2.25.1"
env:
COMPOSER_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
coverage: "pcov"
extensions: "${{ env.extensions }}"
ini-values: "display_errors=On, error_reporting=-1, memory_limit=2G"
php-version: "${{ matrix.php-versions }}"
tools: "phive"
- name: "Install dependencies with composer"
run: "composer install --no-interaction --optimize-autoloader --prefer-dist"
- name: "Install dependencies with phive"
env:
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: "ant install-tools"
- name: "Run PHPUnit"
run: "tools/phpunit --coverage-clover build/logs/clover.xml"
- name: "Send code coverage report to codecov.io"
uses: "codecov/codecov-action@v3.1.4"
with:
files: "build/logs/clover.xml"
================================================
FILE: .gitignore
================================================
/.idea
/.php_cs.cache
/src/autoload.php
/tools
/vendor
/build
.phpunit.result.cache
.php-cs-fixer.cache
================================================
FILE: .php-cs-fixer.dist.php
================================================
<?php
require __DIR__ . '/tools/php-cs-fixer.d/PhpdocSingleLineVarFixer.php';
$header = file_get_contents(__DIR__ . '/tools/php-cs-fixer.d/header.txt');
return (new PhpCsFixer\Config())
->registerCustomFixers([
new \PharIo\CSFixer\PhpdocSingleLineVarFixer()
])
->setRiskyAllowed(true)
->setRules(
[
'PharIo/phpdoc_single_line_var_fixer' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'operators' => [
'=' => 'align',
'=>' => 'align',
],
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => false,
'blank_line_before_statement' => [
'statements' => [
'break',
'continue',
'declare',
'do',
'for',
'foreach',
'if',
'include',
'include_once',
'require',
'require_once',
'return',
'switch',
'throw',
'try',
'while',
'yield',
],
],
'braces' => [
'allow_single_line_closure' => false,
'position_after_anonymous_constructs' => 'same',
'position_after_control_structures' => 'same',
'position_after_functions_and_oop_constructs' => 'same'
],
'cast_spaces' => ['space' => 'none'],
// This fixer removes the blank line at class start, no way to disable that, so we disable the fixer :(
//'class_attributes_separation' => ['elements' => ['const', 'method', 'property']],
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'compact_nullable_typehint' => true,
'concat_space' => ['spacing' => 'one'],
'date_time_immutable' => true,
'declare_equal_normalize' => ['space' => 'single'],
'declare_strict_types' => true,
'dir_constant' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'fully_qualified_strict_types' => true,
'function_declaration' => [
'closure_function_spacing' => 'one'
],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'header_comment' => ['header' => $header, 'separate' => 'none'],
'indentation_type' => true,
'is_null' => true,
'line_ending' => true,
'list_syntax' => ['syntax' => 'short'],
'logical_operators' => true,
'lowercase_cast' => true,
'constant_case' => ['case' => 'lower'],
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => true,
'new_with_braces' => false,
'no_alias_functions' => true,
'no_alternative_syntax' => true,
'no_blank_lines_after_class_opening' => false,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_homoglyph_names' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => ['use' => 'print'],
'no_multiline_whitespace_around_double_arrow' => true,
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'echo_tag_syntax' => ['format' => 'long'],
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_inside_parenthesis' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => false,
'no_unneeded_curly_braces' => false,
'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_on_property' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'non_printable_character' => true,
'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'property_public_static',
'property_protected_static',
'property_private_static',
'property_public',
'property_protected',
'property_private',
'method_public_static',
'construct',
'destruct',
'magic',
'phpunit',
'method_public',
'method_protected',
'method_private',
'method_protected_static',
'method_private_static',
],
],
'ordered_imports' => [
'imports_order' => [
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CLASS,
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CONST,
PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_FUNCTION,
]
],
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_no_access' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => ['groups' => ['simple', 'meta']],
'phpdoc_types_order' => true,
'phpdoc_to_return_type' => true,
'phpdoc_var_without_name' => true,
'pow_to_exponentiation' => true,
'protected_to_private' => true,
'return_assignment' => true,
'return_type_declaration' => ['space_before' => 'none'],
'self_accessor' => false,
'semicolon_after_instruction' => true,
'set_type_to_cast' => true,
'short_scalar_cast' => true,
'simplified_null_return' => true,
'single_blank_line_at_eof' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'standardize_not_equals' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => false,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => [
'const',
'method',
'property',
],
],
'void_return' => true,
'whitespace_after_comma_in_array' => true,
'yoda_style' => false
]
)
->setFinder(
PhpCsFixer\Finder::create()
->files()
->in(__DIR__ . '/build')
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->notName('autoload.php')
);
================================================
FILE: CHANGELOG.md
================================================
# Changelog
All notable changes to phar-io/manifest are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [2.0.4] - 03-03-2024
### Changed
- Make `EMail` an optional attribute for author
- Stick with PHP 7.2 compatibilty
- Do not use implict nullable type (thanks @sebastianbergmann), this should make things work on PHP 8.4
## [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.1.0...HEAD
[2.1.0]: https://github.com/phar-io/manifest/compare/2.0.3...2.1.0
[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
================================================
FILE: LICENSE
================================================
Phar.io - Manifest
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,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Arne Blankerts nor the names of contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
================================================
FILE: README.md
================================================
# Manifest
Component for reading [phar.io](https://phar.io/) manifest information from a [PHP Archive (PHAR)](http://php.net/phar).
## Installation
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
composer require phar-io/manifest
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
composer require --dev phar-io/manifest
## Usage Examples
### Read from `manifest.xml`
```php
use PharIo\Manifest\ManifestLoader;
use PharIo\Manifest\ManifestSerializer;
$manifest = ManifestLoader::fromFile('manifest.xml');
var_dump($manifest);
echo (new ManifestSerializer)->serializeToString($manifest);
```
<details>
<summary>Output</summary>
```shell
object(PharIo\Manifest\Manifest)#14 (6) {
["name":"PharIo\Manifest\Manifest":private]=>
object(PharIo\Manifest\ApplicationName)#10 (1) {
["name":"PharIo\Manifest\ApplicationName":private]=>
string(12) "some/library"
}
["version":"PharIo\Manifest\Manifest":private]=>
object(PharIo\Version\Version)#12 (5) {
["originalVersionString":"PharIo\Version\Version":private]=>
string(5) "1.0.0"
["major":"PharIo\Version\Version":private]=>
object(PharIo\Version\VersionNumber)#13 (1) {
["value":"PharIo\Version\VersionNumber":private]=>
int(1)
}
["minor":"PharIo\Version\Version":private]=>
object(PharIo\Version\VersionNumber)#23 (1) {
["value":"PharIo\Version\VersionNumber":private]=>
int(0)
}
["patch":"PharIo\Version\Version":private]=>
object(PharIo\Version\VersionNumber)#22 (1) {
["value":"PharIo\Version\VersionNumber":private]=>
int(0)
}
["preReleaseSuffix":"PharIo\Version\Version":private]=>
NULL
}
["type":"PharIo\Manifest\Manifest":private]=>
object(PharIo\Manifest\Library)#6 (0) {
}
["copyrightInformation":"PharIo\Manifest\Manifest":private]=>
object(PharIo\Manifest\CopyrightInformation)#19 (2) {
["authors":"PharIo\Manifest\CopyrightInformation":private]=>
object(PharIo\Manifest\AuthorCollection)#9 (1) {
["authors":"PharIo\Manifest\AuthorCollection":private]=>
array(1) {
[0]=>
object(PharIo\Manifest\Author)#15 (2) {
["name":"PharIo\Manifest\Author":private]=>
string(13) "Reiner Zufall"
["email":"PharIo\Manifest\Author":private]=>
object(PharIo\Manifest\Email)#16 (1) {
["email":"PharIo\Manifest\Email":private]=>
string(16) "reiner@zufall.de"
}
}
}
}
["license":"PharIo\Manifest\CopyrightInformation":private]=>
object(PharIo\Manifest\License)#11 (2) {
["name":"PharIo\Manifest\License":private]=>
string(12) "BSD-3-Clause"
["url":"PharIo\Manifest\License":private]=>
object(PharIo\Manifest\Url)#18 (1) {
["url":"PharIo\Manifest\Url":private]=>
string(26) "https://domain.tld/LICENSE"
}
}
}
["requirements":"PharIo\Manifest\Manifest":private]=>
object(PharIo\Manifest\RequirementCollection)#17 (1) {
["requirements":"PharIo\Manifest\RequirementCollection":private]=>
array(1) {
[0]=>
object(PharIo\Manifest\PhpVersionRequirement)#20 (1) {
["versionConstraint":"PharIo\Manifest\PhpVersionRequirement":private]=>
object(PharIo\Version\SpecificMajorAndMinorVersionConstraint)#24 (3) {
["originalValue":"PharIo\Version\AbstractVersionConstraint":private]=>
string(3) "7.0"
["major":"PharIo\Version\SpecificMajorAndMinorVersionConstraint":private]=>
int(7)
["minor":"PharIo\Version\SpecificMajorAndMinorVersionConstraint":private]=>
int(0)
}
}
}
}
["bundledComponents":"PharIo\Manifest\Manifest":private]=>
object(PharIo\Manifest\BundledComponentCollection)#8 (1) {
["bundledComponents":"PharIo\Manifest\BundledComponentCollection":private]=>
array(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>
```
</details>
### Create via API
```php
$bundled = new \PharIo\Manifest\BundledComponentCollection();
$bundled->add(
new \PharIo\Manifest\BundledComponent('vendor/packageA', new \PharIo\Version\Version('1.2.3-dev')
)
);
$manifest = new PharIo\Manifest\Manifest(
new \PharIo\Manifest\ApplicationName('vendor/package'),
new \PharIo\Version\Version('1.0.0'),
new \PharIo\Manifest\Library(),
new \PharIo\Manifest\CopyrightInformation(
new \PharIo\Manifest\AuthorCollection(),
new \PharIo\Manifest\License(
'BSD-3-Clause',
new \PharIo\Manifest\Url('https://spdx.org/licenses/BSD-3-Clause.html')
)
),
new \PharIo\Manifest\RequirementCollection(),
$bundled
);
echo (new ManifestSerializer)->serializeToString($manifest);
```
<details>
<summary>Output</summary>
```xml
<?xml version="1.0" encoding="UTF-8"?>
<phar xmlns="https://phar.io/xml/manifest/1.0">
<contains name="vendor/package" version="1.0.0" type="library"/>
<copyright>
<license type="BSD-3-Clause" url="https://spdx.org/licenses/BSD-3-Clause.html"/>
</copyright>
<requires>
<php version="*"/>
</requires>
<bundles>
<component name="vendor/packageA" version="1.2.3-dev"/>
</bundles>
</phar>
```
</details>
================================================
FILE: build.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project name="manifest" default="setup">
<property name="phive.bin" value="phive" />
<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" description="Install dependencies with Composer">
<exec executable="${basedir}/tools/composer" taskname="composer">
<env key="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
<arg value="install"/>
<arg value="--no-interaction"/>
<arg value="--no-progress"/>
<arg value="--no-ansi"/>
<arg value="--optimize-autoloader"/>
</exec>
</target>
<target name="install-tools" unless="tools-installed" depends="-tools-installed" description="Install tools with Phive">
<exec executable="${phive.bin}" taskname="phive" failonerror="true">
<arg value="--no-progress" />
<arg value="install"/>
<arg value="--copy" />
<arg value="--trust-gpg-keys" />
<!-- phpab, phpunit, phpstan, psaml, php-cs-fixer, composer -->
<arg value="4AA394086372C20A,2A8299CE842DD38C,CF1A108D0E7AE720,12CE0F1D262429A5,E82B2FB314E9906E,CBB3D576F2A0946F" />
</exec>
</target>
<target name="php-cs-fixer" depends="install-tools" description="Dry run php csfixer">
<exec executable="${basedir}/tools/php-cs-fixer" failonerror="true">
<arg value="fix" />
<arg value="--dry-run" />
</exec>
</target>
<target name="psalm" depends="install-tools,install-dependencies" description="Run psalm">
<exec executable="${basedir}/tools/psalm" taskname="psalm-cache-clear">
<arg value="--config=psalm.xml" />
<arg value="--clear-cache" />
</exec>
<exec executable="${basedir}/tools/psalm" taskname="psalm" failonerror="true">
<arg value="--config=psalm.xml" />
<arg value="--show-info=true" />
<arg value="--stats" />
</exec>
</target>
<target name="psalm-baseline" depends="install-tools,install-dependencies" description="Run psalm">
<exec executable="${basedir}/tools/psalm" taskname="psalm-cache-clear">
<arg value="--config=psalm.xml" />
<arg value="--clear-cache" />
</exec>
<exec executable="${basedir}/tools/psalm" taskname="psalm-baseline">
<arg value="--config=psalm.xml" />
<arg value="--set-baseline=build/psalm-baseline.xml" />
<arg value="--show-info=false" />
</exec>
</target>
<target name="test" depends="install-tools,install-dependencies" description="Run tests">
<exec executable="${basedir}/tools/phpunit" taskname="phpunit"/>
</target>
<target name="phpunit-ci">
<condition property="phpunit" value="phpunit.bat" else="phpunit">
<os family="windows" />
</condition>
<exec executable="${basedir}/tools/${phpunit}" taskname="phpunit">
<arg value="--coverage-clover build/logs/clover.xml" />
</exec>
</target>
<target name="-tools-installed">
<available file="${basedir}/tools/phpunit" property="tools-installed" type="file"/>
</target>
</project>
================================================
FILE: composer.json
================================================
{
"name": "phar-io/manifest",
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Arne Blankerts",
"email": "arne@blankerts.de",
"role": "Developer"
},
{
"name": "Sebastian Heuer",
"email": "sebastian@phpeople.de",
"role": "Developer"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "Developer"
}
],
"support": {
"issues": "https://github.com/phar-io/manifest/issues"
},
"require": {
"php": "^7.2 || ^8.0",
"ext-dom": "*",
"ext-phar": "*",
"ext-libxml": "*",
"ext-xmlwriter": "*",
"phar-io/version": "^3.0.1"
},
"autoload": {
"classmap": [
"src/"
]
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
}
}
================================================
FILE: examples/example-01.php
================================================
<?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()->asString(),
$manifest->getVersion()->getVersionString()
);
echo (new ManifestSerializer)->serializeToString($manifest);
================================================
FILE: examples/example-02.php
================================================
<?php declare(strict_types = 1);
/**
* Thanks to @llaville for this example
*/
use PharIo\Manifest\ManifestSerializer;
require __DIR__ . '/../vendor/autoload.php';
$bundledComponentCollection = new \PharIo\Manifest\BundledComponentCollection();
$bundledComponentCollection->add(
new \PharIo\Manifest\BundledComponent(
'vendor/packageA',
new \PharIo\Version\Version('0.0.0-dev')
)
);
$manifest = new PharIo\Manifest\Manifest(
new \PharIo\Manifest\ApplicationName('vendor/package'),
new \PharIo\Version\Version('1.0.0'),
new \PharIo\Manifest\Library(),
new \PharIo\Manifest\CopyrightInformation(
new \PharIo\Manifest\AuthorCollection(),
new \PharIo\Manifest\License(
'BSD-3-Clause',
new \PharIo\Manifest\Url('https://spdx.org/licenses/BSD-3-Clause.html')
)
),
new \PharIo\Manifest\RequirementCollection(),
$bundledComponentCollection
);
echo (new ManifestSerializer)->serializeToString($manifest);
/*
* Output produced
*
<?xml version="1.0" encoding="UTF-8"?>
<phar xmlns="https://phar.io/xml/manifest/1.0">
<contains name="vendor/package" version="1.0.0" type="library"/>
<copyright>
<license type="BSD-3-Clause" url="https://spdx.org/licenses/BSD-3-Clause.html"/>
</copyright>
<requires>
<php version="*"/>
</requires>
<bundles>
<component name="vendor/packageA" version="0.0.0-dev"/>
</bundles>
</phar>
*/
================================================
FILE: manifest.xsd
================================================
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="https://phar.io/xml/manifest/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns="https://phar.io/xml/manifest/1.0">
<xs:element name="phar">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns:contains" maxOccurs="1" />
<xs:element ref="ns:copyright" maxOccurs="1" />
<xs:element ref="ns:requires" maxOccurs="1" />
<xs:element ref="ns:bundles" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="contains">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" use="required" name="name"/>
<xs:attribute type="xs:string" use="required" name="version"/>
<xs:attribute use="required" name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="application"/>
<xs:enumeration value="extension"/>
<xs:enumeration value="library"/>
<xs:enumeration value="stub"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="copyright">
<xs:complexType>
<xs:sequence>
<xs:choice maxOccurs="unbounded">
<xs:element ref="ns:author" minOccurs="1" maxOccurs="unbounded" />
</xs:choice>
<xs:element ref="ns:license" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="author">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" use="required" name="name"/>
<xs:attribute type="xs:string" use="optional" name="email"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="license">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" use="required" name="type"/>
<xs:attribute type="xs:string" use="required" name="url"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="requires">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns:php" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="php">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns:ext" maxOccurs="unbounded" minOccurs="0" />
</xs:sequence>
<xs:attribute type="xs:string" use="required" name="version"/>
</xs:complexType>
</xs:element>
<xs:element name="ext">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="name" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="bundles">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns:component" maxOccurs="unbounded" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="component">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="name" use="required"/>
<xs:attribute type="xs:string" name="version" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
================================================
FILE: phive.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^3.17.0" installed="3.17.0" location="./tools/php-cs-fixer" copy="true"/>
<phar name="psalm" version="^5.0" installed="5.12.0" location="./tools/psalm" copy="true"/>
<phar name="phpunit" version="^9.6" installed="9.6.8" location="./tools/phpunit" copy="true"/>
<phar name="composer" version="^2.5.5" installed="2.5.7" location="./tools/composer" copy="true"/>
</phive>
================================================
FILE: phpunit.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" backupGlobals="false" beStrictAboutCoversAnnotation="true" beStrictAboutOutputDuringTests="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutTodoAnnotatedTests="true" verbose="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuite name="phar.io manifest">
<directory suffix="Test.php">tests</directory>
</testsuite>
</phpunit>
================================================
FILE: psalm.xml
================================================
<?xml version="1.0"?>
<psalm xmlns="https://getpsalm.org/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="build/psalm-baseline.xml"
errorLevel="1"
findUnusedVariablesAndParams="true"
resolveFromConfigFile="true"
strictBinaryOperands="true"
findUnusedBaselineEntry="true"
findUnusedCode="true"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
================================================
FILE: src/ManifestDocumentMapper.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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\Exception as VersionException;
use PharIo\Version\Version;
use PharIo\Version\VersionConstraintParser;
use Throwable;
use function sprintf;
class ManifestDocumentMapper {
public function map(ManifestDocument $document): Manifest {
try {
$contains = $document->getContainsElement();
$type = $this->mapType($contains);
$copyright = $this->mapCopyright($document->getCopyrightElement());
$requirements = $this->mapRequirements($document->getRequiresElement());
$bundledComponents = $this->mapBundledComponents($document);
return new Manifest(
new ApplicationName($contains->getName()),
new Version($contains->getVersion()),
$type,
$copyright,
$requirements,
$bundledComponents
);
} catch (Throwable $e) {
throw new ManifestDocumentMapperException($e->getMessage(), (int)$e->getCode(), $e);
}
}
private function mapType(ContainsElement $contains): Type {
switch ($contains->getType()) {
case 'application':
return Type::application();
case 'library':
return Type::library();
case 'extension':
return $this->mapExtension($contains->getExtensionElement());
}
throw new ManifestDocumentMapperException(
sprintf('Unsupported type %s', $contains->getType())
);
}
private function mapCopyright(CopyrightElement $copyright): CopyrightInformation {
$authors = new AuthorCollection();
foreach ($copyright->getAuthorElements() as $authorElement) {
$authors->add(
new Author(
$authorElement->getName(),
$authorElement->hasEMail() ? new Email($authorElement->getEmail()) : null
)
);
}
$licenseElement = $copyright->getLicenseElement();
$license = new License(
$licenseElement->getType(),
new Url($licenseElement->getUrl())
);
return new CopyrightInformation(
$authors,
$license
);
}
private function mapRequirements(RequiresElement $requires): RequirementCollection {
$collection = new RequirementCollection();
$phpElement = $requires->getPHPElement();
$parser = new VersionConstraintParser;
try {
$versionConstraint = $parser->parse($phpElement->getVersion());
} catch (VersionException $e) {
throw new ManifestDocumentMapperException(
sprintf('Unsupported version constraint - %s', $e->getMessage()),
(int)$e->getCode(),
$e
);
}
$collection->add(
new PhpVersionRequirement(
$versionConstraint
)
);
if (!$phpElement->hasExtElements()) {
return $collection;
}
foreach ($phpElement->getExtElements() as $extElement) {
$collection->add(
new PhpExtensionRequirement($extElement->getName())
);
}
return $collection;
}
private function mapBundledComponents(ManifestDocument $document): BundledComponentCollection {
$collection = new BundledComponentCollection();
if (!$document->hasBundlesElement()) {
return $collection;
}
foreach ($document->getBundlesElement()->getComponentElements() as $componentElement) {
$collection->add(
new BundledComponent(
$componentElement->getName(),
new Version(
$componentElement->getVersion()
)
)
);
}
return $collection;
}
private function mapExtension(ExtensionElement $extension): Extension {
try {
$versionConstraint = (new VersionConstraintParser)->parse($extension->getCompatible());
return Type::extension(
new ApplicationName($extension->getFor()),
$versionConstraint
);
} catch (VersionException $e) {
throw new ManifestDocumentMapperException(
sprintf('Unsupported version constraint - %s', $e->getMessage()),
(int)$e->getCode(),
$e
);
}
}
}
================================================
FILE: src/ManifestLoader.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use function sprintf;
class ManifestLoader {
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),
(int)$e->getCode(),
$e
);
}
}
public static function fromPhar(string $filename): Manifest {
return self::fromFile('phar://' . $filename . '/manifest.xml');
}
public static function fromString(string $manifest): Manifest {
try {
return (new ManifestDocumentMapper())->map(
ManifestDocument::fromString($manifest)
);
} catch (Exception $e) {
throw new ManifestLoaderException(
'Processing string failed',
(int)$e->getCode(),
$e
);
}
}
}
================================================
FILE: src/ManifestSerializer.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 XMLWriter;
use function count;
use function file_put_contents;
use function str_repeat;
/** @psalm-suppress MissingConstructor */
class ManifestSerializer {
/** @var XMLWriter */
private $xmlWriter;
public function serializeToFile(Manifest $manifest, string $filename): void {
file_put_contents(
$filename,
$this->serializeToString($manifest)
);
}
public function serializeToString(Manifest $manifest): string {
$this->startDocument();
$this->addContains($manifest->getName(), $manifest->getVersion(), $manifest->getType());
$this->addCopyright($manifest->getCopyrightInformation());
$this->addRequirements($manifest->getRequirements());
$this->addBundles($manifest->getBundledComponents());
return $this->finishDocument();
}
private function startDocument(): void {
$xmlWriter = new XMLWriter();
$xmlWriter->openMemory();
$xmlWriter->setIndent(true);
$xmlWriter->setIndentString(str_repeat(' ', 4));
$xmlWriter->startDocument('1.0', 'UTF-8');
$xmlWriter->startElement('phar');
$xmlWriter->writeAttribute('xmlns', 'https://phar.io/xml/manifest/1.0');
$this->xmlWriter = $xmlWriter;
}
private function finishDocument(): string {
$this->xmlWriter->endElement();
$this->xmlWriter->endDocument();
return $this->xmlWriter->outputMemory();
}
private function addContains(ApplicationName $name, Version $version, Type $type): void {
$this->xmlWriter->startElement('contains');
$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(): {
$this->xmlWriter->writeAttribute('type', 'extension');
/* @var $type Extension */
$this->addExtension(
$type->getApplicationName(),
$type->getVersionConstraint()
);
break;
}
default: {
$this->xmlWriter->writeAttribute('type', 'custom');
}
}
$this->xmlWriter->endElement();
}
private function addCopyright(CopyrightInformation $copyrightInformation): void {
$this->xmlWriter->startElement('copyright');
foreach ($copyrightInformation->getAuthors() as $author) {
$this->xmlWriter->startElement('author');
$this->xmlWriter->writeAttribute('name', $author->getName());
$this->xmlWriter->writeAttribute('email', $author->getEmail()->asString());
$this->xmlWriter->endElement();
}
$license = $copyrightInformation->getLicense();
$this->xmlWriter->startElement('license');
$this->xmlWriter->writeAttribute('type', $license->getName());
$this->xmlWriter->writeAttribute('url', $license->getUrl()->asString());
$this->xmlWriter->endElement();
$this->xmlWriter->endElement();
}
private function addRequirements(RequirementCollection $requirementCollection): void {
$phpRequirement = new AnyVersionConstraint();
$extensions = [];
foreach ($requirementCollection as $requirement) {
if ($requirement instanceof PhpVersionRequirement) {
$phpRequirement = $requirement->getVersionConstraint();
continue;
}
if ($requirement instanceof PhpExtensionRequirement) {
$extensions[] = $requirement->asString();
}
}
$this->xmlWriter->startElement('requires');
$this->xmlWriter->startElement('php');
$this->xmlWriter->writeAttribute('version', $phpRequirement->asString());
foreach ($extensions as $extension) {
$this->xmlWriter->startElement('ext');
$this->xmlWriter->writeAttribute('name', $extension);
$this->xmlWriter->endElement();
}
$this->xmlWriter->endElement();
$this->xmlWriter->endElement();
}
private function addBundles(BundledComponentCollection $bundledComponentCollection): void {
if (count($bundledComponentCollection) === 0) {
return;
}
$this->xmlWriter->startElement('bundles');
foreach ($bundledComponentCollection as $bundledComponent) {
$this->xmlWriter->startElement('component');
$this->xmlWriter->writeAttribute('name', $bundledComponent->getName());
$this->xmlWriter->writeAttribute('version', $bundledComponent->getVersion()->getVersionString());
$this->xmlWriter->endElement();
}
$this->xmlWriter->endElement();
}
private function addExtension(ApplicationName $applicationName, VersionConstraint $versionConstraint): void {
$this->xmlWriter->startElement('extension');
$this->xmlWriter->writeAttribute('for', $applicationName->asString());
$this->xmlWriter->writeAttribute('compatible', $versionConstraint->asString());
$this->xmlWriter->endElement();
}
}
================================================
FILE: src/exceptions/ElementCollectionException.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use InvalidArgumentException;
class ElementCollectionException extends InvalidArgumentException implements Exception {
}
================================================
FILE: src/exceptions/Exception.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use Throwable;
interface Exception extends Throwable {
}
================================================
FILE: src/exceptions/InvalidApplicationNameException.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use InvalidArgumentException;
class InvalidApplicationNameException extends InvalidArgumentException implements Exception {
public const InvalidFormat = 2;
}
================================================
FILE: src/exceptions/InvalidEmailException.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use InvalidArgumentException;
class InvalidEmailException extends InvalidArgumentException implements Exception {
}
================================================
FILE: src/exceptions/InvalidUrlException.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use InvalidArgumentException;
class InvalidUrlException extends InvalidArgumentException implements Exception {
}
================================================
FILE: src/exceptions/ManifestDocumentException.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use RuntimeException;
class ManifestDocumentException extends RuntimeException implements Exception {
}
================================================
FILE: src/exceptions/ManifestDocumentLoadingException.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use LibXMLError;
use function sprintf;
class ManifestDocumentLoadingException extends \Exception implements Exception {
/** @var LibXMLError[] */
private $libxmlErrors;
/**
* ManifestDocumentLoadingException constructor.
*
* @param LibXMLError[] $libxmlErrors
*/
public function __construct(array $libxmlErrors) {
$this->libxmlErrors = $libxmlErrors;
$first = $this->libxmlErrors[0];
parent::__construct(
sprintf(
'%s (Line: %d / Column: %d / File: %s)',
$first->message,
$first->line,
$first->column,
$first->file
),
$first->code
);
}
/**
* @return LibXMLError[]
*/
public function getLibxmlErrors(): array {
return $this->libxmlErrors;
}
}
================================================
FILE: src/exceptions/ManifestDocumentMapperException.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use RuntimeException;
class ManifestDocumentMapperException extends RuntimeException implements Exception {
}
================================================
FILE: src/exceptions/ManifestElementException.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use RuntimeException;
class ManifestElementException extends RuntimeException implements Exception {
}
================================================
FILE: src/exceptions/ManifestLoaderException.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
class ManifestLoaderException extends \Exception implements Exception {
}
================================================
FILE: src/exceptions/NoEmailAddressException.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use InvalidArgumentException;
class NoEmailAddressException extends InvalidArgumentException implements Exception {
}
================================================
FILE: src/values/Application.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 {
public function isApplication(): bool {
return true;
}
}
================================================
FILE: src/values/ApplicationName.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use function preg_match;
use function sprintf;
class ApplicationName {
/** @var string */
private $name;
public function __construct(string $name) {
$this->ensureValidFormat($name);
$this->name = $name;
}
public function asString(): string {
return $this->name;
}
public function isEqual(ApplicationName $name): bool {
return $this->name === $name->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),
InvalidApplicationNameException::InvalidFormat
);
}
}
}
================================================
FILE: src/values/Author.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use function sprintf;
class Author {
/** @var string */
private $name;
/** @var null|Email */
private $email;
public function __construct(string $name, ?Email $email = null) {
$this->name = $name;
$this->email = $email;
}
public function asString(): string {
if (!$this->hasEmail()) {
return $this->name;
}
return sprintf(
'%s <%s>',
$this->name,
$this->email->asString()
);
}
public function getName(): string {
return $this->name;
}
/**
* @psalm-assert-if-true Email $this->email
*/
public function hasEmail(): bool {
return $this->email !== null;
}
public function getEmail(): Email {
if (!$this->hasEmail()) {
throw new NoEmailAddressException();
}
return $this->email;
}
}
================================================
FILE: src/values/AuthorCollection.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use Countable;
use IteratorAggregate;
use function count;
/** @template-implements IteratorAggregate<int,Author> */
class AuthorCollection implements Countable, IteratorAggregate {
/** @var Author[] */
private $authors = [];
public function add(Author $author): void {
$this->authors[] = $author;
}
/**
* @return Author[]
*/
public function getAuthors(): array {
return $this->authors;
}
public function count(): int {
return count($this->authors);
}
public function getIterator(): AuthorCollectionIterator {
return new AuthorCollectionIterator($this);
}
}
================================================
FILE: src/values/AuthorCollectionIterator.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use Iterator;
use function count;
/** @template-implements Iterator<int,Author> */
class AuthorCollectionIterator implements Iterator {
/** @var Author[] */
private $authors;
/** @var int */
private $position = 0;
public function __construct(AuthorCollection $authors) {
$this->authors = $authors->getAuthors();
}
public function rewind(): void {
$this->position = 0;
}
public function valid(): bool {
return $this->position < count($this->authors);
}
public function key(): int {
return $this->position;
}
public function current(): Author {
return $this->authors[$this->position];
}
public function next(): void {
$this->position++;
}
}
================================================
FILE: src/values/BundledComponent.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 */
private $name;
/** @var Version */
private $version;
public function __construct(string $name, Version $version) {
$this->name = $name;
$this->version = $version;
}
public function getName(): string {
return $this->name;
}
public function getVersion(): Version {
return $this->version;
}
}
================================================
FILE: src/values/BundledComponentCollection.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use Countable;
use IteratorAggregate;
use function count;
/** @template-implements IteratorAggregate<int,BundledComponent> */
class BundledComponentCollection implements Countable, IteratorAggregate {
/** @var BundledComponent[] */
private $bundledComponents = [];
public function add(BundledComponent $bundledComponent): void {
$this->bundledComponents[] = $bundledComponent;
}
/**
* @return BundledComponent[]
*/
public function getBundledComponents(): array {
return $this->bundledComponents;
}
public function count(): int {
return count($this->bundledComponents);
}
public function getIterator(): BundledComponentCollectionIterator {
return new BundledComponentCollectionIterator($this);
}
}
================================================
FILE: src/values/BundledComponentCollectionIterator.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use Iterator;
use function count;
/** @template-implements Iterator<int,BundledComponent> */
class BundledComponentCollectionIterator implements Iterator {
/** @var BundledComponent[] */
private $bundledComponents;
/** @var int */
private $position = 0;
public function __construct(BundledComponentCollection $bundledComponents) {
$this->bundledComponents = $bundledComponents->getBundledComponents();
}
public function rewind(): void {
$this->position = 0;
}
public function valid(): bool {
return $this->position < count($this->bundledComponents);
}
public function key(): int {
return $this->position;
}
public function current(): BundledComponent {
return $this->bundledComponents[$this->position];
}
public function next(): void {
$this->position++;
}
}
================================================
FILE: src/values/CopyrightInformation.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 */
private $authors;
/** @var License */
private $license;
public function __construct(AuthorCollection $authors, License $license) {
$this->authors = $authors;
$this->license = $license;
}
public function getAuthors(): AuthorCollection {
return $this->authors;
}
public function getLicense(): License {
return $this->license;
}
}
================================================
FILE: src/values/Email.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use const FILTER_VALIDATE_EMAIL;
use function filter_var;
class Email {
/** @var string */
private $email;
public function __construct(string $email) {
$this->ensureEmailIsValid($email);
$this->email = $email;
}
public function asString(): string {
return $this->email;
}
private function ensureEmailIsValid(string $url): void {
if (filter_var($url, FILTER_VALIDATE_EMAIL) === false) {
throw new InvalidEmailException;
}
}
}
================================================
FILE: src/values/Extension.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 */
private $application;
/** @var VersionConstraint */
private $versionConstraint;
public function __construct(ApplicationName $application, VersionConstraint $versionConstraint) {
$this->application = $application;
$this->versionConstraint = $versionConstraint;
}
public function getApplicationName(): ApplicationName {
return $this->application;
}
public function getVersionConstraint(): VersionConstraint {
return $this->versionConstraint;
}
public function isExtension(): bool {
return true;
}
public function isExtensionFor(ApplicationName $name): bool {
return $this->application->isEqual($name);
}
public function isCompatibleWith(ApplicationName $name, Version $version): bool {
return $this->isExtensionFor($name) && $this->versionConstraint->complies($version);
}
}
================================================
FILE: src/values/Library.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 {
public function isLibrary(): bool {
return true;
}
}
================================================
FILE: src/values/License.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 */
private $name;
/** @var Url */
private $url;
public function __construct(string $name, Url $url) {
$this->name = $name;
$this->url = $url;
}
public function getName(): string {
return $this->name;
}
public function getUrl(): Url {
return $this->url;
}
}
================================================
FILE: src/values/Manifest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 */
private $name;
/** @var Version */
private $version;
/** @var Type */
private $type;
/** @var CopyrightInformation */
private $copyrightInformation;
/** @var RequirementCollection */
private $requirements;
/** @var BundledComponentCollection */
private $bundledComponents;
public function __construct(ApplicationName $name, Version $version, Type $type, CopyrightInformation $copyrightInformation, RequirementCollection $requirements, BundledComponentCollection $bundledComponents) {
$this->name = $name;
$this->version = $version;
$this->type = $type;
$this->copyrightInformation = $copyrightInformation;
$this->requirements = $requirements;
$this->bundledComponents = $bundledComponents;
}
public function getName(): ApplicationName {
return $this->name;
}
public function getVersion(): Version {
return $this->version;
}
public function getType(): Type {
return $this->type;
}
public function getCopyrightInformation(): CopyrightInformation {
return $this->copyrightInformation;
}
public function getRequirements(): RequirementCollection {
return $this->requirements;
}
public function getBundledComponents(): BundledComponentCollection {
return $this->bundledComponents;
}
public function isApplication(): bool {
return $this->type->isApplication();
}
public function isLibrary(): bool {
return $this->type->isLibrary();
}
public function isExtension(): bool {
return $this->type->isExtension();
}
public function isExtensionFor(ApplicationName $application, ?Version $version = null): bool {
if (!$this->isExtension()) {
return false;
}
/** @var Extension $type */
$type = $this->type;
if ($version !== null) {
return $type->isCompatibleWith($application, $version);
}
return $type->isExtensionFor($application);
}
}
================================================
FILE: src/values/PhpExtensionRequirement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 */
private $extension;
public function __construct(string $extension) {
$this->extension = $extension;
}
public function asString(): string {
return $this->extension;
}
}
================================================
FILE: src/values/PhpVersionRequirement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 */
private $versionConstraint;
public function __construct(VersionConstraint $versionConstraint) {
$this->versionConstraint = $versionConstraint;
}
public function getVersionConstraint(): VersionConstraint {
return $this->versionConstraint;
}
}
================================================
FILE: src/values/Requirement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
interface Requirement {
}
================================================
FILE: src/values/RequirementCollection.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use Countable;
use IteratorAggregate;
use function count;
/** @template-implements IteratorAggregate<int,Requirement> */
class RequirementCollection implements Countable, IteratorAggregate {
/** @var Requirement[] */
private $requirements = [];
public function add(Requirement $requirement): void {
$this->requirements[] = $requirement;
}
/**
* @return Requirement[]
*/
public function getRequirements(): array {
return $this->requirements;
}
public function count(): int {
return count($this->requirements);
}
public function getIterator(): RequirementCollectionIterator {
return new RequirementCollectionIterator($this);
}
}
================================================
FILE: src/values/RequirementCollectionIterator.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use Iterator;
use function count;
/** @template-implements Iterator<int,Requirement> */
class RequirementCollectionIterator implements Iterator {
/** @var Requirement[] */
private $requirements;
/** @var int */
private $position = 0;
public function __construct(RequirementCollection $requirements) {
$this->requirements = $requirements->getRequirements();
}
public function rewind(): void {
$this->position = 0;
}
public function valid(): bool {
return $this->position < count($this->requirements);
}
public function key(): int {
return $this->position;
}
public function current(): Requirement {
return $this->requirements[$this->position];
}
public function next(): void {
$this->position++;
}
}
================================================
FILE: src/values/Type.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 {
public static function application(): Application {
return new Application;
}
public static function library(): Library {
return new Library;
}
public static function extension(ApplicationName $application, VersionConstraint $versionConstraint): Extension {
return new Extension($application, $versionConstraint);
}
/** @psalm-assert-if-true Application $this */
public function isApplication(): bool {
return false;
}
/** @psalm-assert-if-true Library $this */
public function isLibrary(): bool {
return false;
}
/** @psalm-assert-if-true Extension $this */
public function isExtension(): bool {
return false;
}
}
================================================
FILE: src/values/Url.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use const FILTER_VALIDATE_URL;
use function filter_var;
class Url {
/** @var string */
private $url;
public function __construct(string $url) {
$this->ensureUrlIsValid($url);
$this->url = $url;
}
public function asString(): string {
return $this->url;
}
/**
* @throws InvalidUrlException
*/
private function ensureUrlIsValid(string $url): void {
if (filter_var($url, FILTER_VALIDATE_URL) === false) {
throw new InvalidUrlException;
}
}
}
================================================
FILE: src/xml/AuthorElement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): string {
return $this->getAttributeValue('name');
}
public function getEmail(): string {
return $this->getAttributeValue('email');
}
public function hasEMail(): bool {
return $this->hasAttribute('email');
}
}
================================================
FILE: src/xml/AuthorElementCollection.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): AuthorElement {
return new AuthorElement(
$this->getCurrentElement()
);
}
}
================================================
FILE: src/xml/BundlesElement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): ComponentElementCollection {
return new ComponentElementCollection(
$this->getChildrenByName('component')
);
}
}
================================================
FILE: src/xml/ComponentElement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): string {
return $this->getAttributeValue('name');
}
public function getVersion(): string {
return $this->getAttributeValue('version');
}
}
================================================
FILE: src/xml/ComponentElementCollection.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): ComponentElement {
return new ComponentElement(
$this->getCurrentElement()
);
}
}
================================================
FILE: src/xml/ContainsElement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): string {
return $this->getAttributeValue('name');
}
public function getVersion(): string {
return $this->getAttributeValue('version');
}
public function getType(): string {
return $this->getAttributeValue('type');
}
public function getExtensionElement(): ExtensionElement {
return new ExtensionElement(
$this->getChildByName('extension')
);
}
}
================================================
FILE: src/xml/CopyrightElement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): AuthorElementCollection {
return new AuthorElementCollection(
$this->getChildrenByName('author')
);
}
public function getLicenseElement(): LicenseElement {
return new LicenseElement(
$this->getChildByName('license')
);
}
}
================================================
FILE: src/xml/ElementCollection.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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;
use Iterator;
use ReturnTypeWillChange;
use function count;
use function get_class;
use function sprintf;
/** @template-implements Iterator<int,DOMElement> */
abstract class ElementCollection implements Iterator {
/** @var DOMElement[] */
private $nodes = [];
/** @var int */
private $position;
public function __construct(DOMNodeList $nodeList) {
$this->position = 0;
$this->importNodes($nodeList);
}
#[ReturnTypeWillChange]
abstract public function current();
public function next(): void {
$this->position++;
}
public function key(): int {
return $this->position;
}
public function valid(): bool {
return $this->position < count($this->nodes);
}
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;
}
}
}
================================================
FILE: src/xml/ExtElement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): string {
return $this->getAttributeValue('name');
}
}
================================================
FILE: src/xml/ExtElementCollection.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): ExtElement {
return new ExtElement(
$this->getCurrentElement()
);
}
}
================================================
FILE: src/xml/ExtensionElement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): string {
return $this->getAttributeValue('for');
}
public function getCompatible(): string {
return $this->getAttributeValue('compatible');
}
}
================================================
FILE: src/xml/LicenseElement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): string {
return $this->getAttributeValue('type');
}
public function getUrl(): string {
return $this->getAttributeValue('url');
}
}
================================================
FILE: src/xml/ManifestDocument.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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;
use Throwable;
use function count;
use function file_get_contents;
use function is_file;
use function libxml_clear_errors;
use function libxml_get_errors;
use function libxml_use_internal_errors;
use function sprintf;
class ManifestDocument {
public const XMLNS = 'https://phar.io/xml/manifest/1.0';
/** @var DOMDocument */
private $dom;
public static function fromFile(string $filename): ManifestDocument {
if (!is_file($filename)) {
throw new ManifestDocumentException(
sprintf('File "%s" not found', $filename)
);
}
return self::fromString(
file_get_contents($filename)
);
}
public static function fromString(string $xmlString): ManifestDocument {
$prev = libxml_use_internal_errors(true);
libxml_clear_errors();
try {
$dom = new DOMDocument();
$dom->loadXML($xmlString);
$errors = libxml_get_errors();
libxml_use_internal_errors($prev);
} catch (Throwable $t) {
throw new ManifestDocumentException($t->getMessage(), 0, $t);
}
if (count($errors) !== 0) {
throw new ManifestDocumentLoadingException($errors);
}
return new self($dom);
}
private function __construct(DOMDocument $dom) {
$this->ensureCorrectDocumentType($dom);
$this->dom = $dom;
}
public function getContainsElement(): ContainsElement {
return new ContainsElement(
$this->fetchElementByName('contains')
);
}
public function getCopyrightElement(): CopyrightElement {
return new CopyrightElement(
$this->fetchElementByName('copyright')
);
}
public function getRequiresElement(): RequiresElement {
return new RequiresElement(
$this->fetchElementByName('requires')
);
}
public function hasBundlesElement(): bool {
return $this->dom->getElementsByTagNameNS(self::XMLNS, 'bundles')->length === 1;
}
public function getBundlesElement(): BundlesElement {
return new BundlesElement(
$this->fetchElementByName('bundles')
);
}
private function ensureCorrectDocumentType(DOMDocument $dom): void {
$root = $dom->documentElement;
if ($root->localName !== 'phar' || $root->namespaceURI !== self::XMLNS) {
throw new ManifestDocumentException('Not a phar.io manifest document');
}
}
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)
);
}
return $element;
}
}
================================================
FILE: src/xml/ManifestElement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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;
use function sprintf;
class ManifestElement {
public const XMLNS = 'https://phar.io/xml/manifest/1.0';
/** @var DOMElement */
private $element;
public function __construct(DOMElement $element) {
$this->element = $element;
}
protected function getAttributeValue(string $name): string {
if (!$this->element->hasAttribute($name)) {
throw new ManifestElementException(
sprintf(
'Attribute %s not set on element %s',
$name,
$this->element->localName
)
);
}
return $this->element->getAttribute($name);
}
protected function hasAttribute(string $name): bool {
return $this->element->hasAttribute($name);
}
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)
);
}
return $element;
}
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)
);
}
return $elementList;
}
protected function hasChild(string $elementName): bool {
return $this->element->getElementsByTagNameNS(self::XMLNS, $elementName)->length !== 0;
}
}
================================================
FILE: src/xml/PhpElement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): string {
return $this->getAttributeValue('version');
}
public function hasExtElements(): bool {
return $this->hasChild('ext');
}
public function getExtElements(): ExtElementCollection {
return new ExtElementCollection(
$this->getChildrenByName('ext')
);
}
}
================================================
FILE: src/xml/RequiresElement.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): PhpElement {
return new PhpElement(
$this->getChildByName('php')
);
}
}
================================================
FILE: tests/ManifestDocumentMapperTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
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
*
* @uses \PharIo\Manifest\Application
* @uses \PharIo\Manifest\ApplicationName
* @uses \PharIo\Manifest\Library
* @uses \PharIo\Manifest\Extension
* @uses \PharIo\Manifest\ExtensionElement
*/
public function testCanSerializeToString($expected): void {
$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'],
'noemailauthor' => [__DIR__ . '/_fixture/noemailauthor.xml']
];
}
public function testThrowsExceptionOnUnsupportedType(): void {
$manifestDocument = ManifestDocument::fromFile(__DIR__ . '/_fixture/custom.xml');
$mapper = new ManifestDocumentMapper();
$this->expectException(ManifestDocumentMapperException::class);
$mapper->map($manifestDocument);
}
public function testInvalidVersionInformationThrowsException(): void {
$manifestDocument = ManifestDocument::fromFile(__DIR__ . '/_fixture/invalidversion.xml');
$mapper = new ManifestDocumentMapper();
$this->expectException(ManifestDocumentMapperException::class);
$mapper->map($manifestDocument);
}
public function testInvalidVersionConstraintThrowsException(): void {
$manifestDocument = ManifestDocument::fromFile(__DIR__ . '/_fixture/invalidversionconstraint.xml');
$mapper = new ManifestDocumentMapper();
$this->expectException(ManifestDocumentMapperException::class);
$mapper->map($manifestDocument);
}
/**
* @uses \PharIo\Manifest\ExtensionElement
*/
public function testInvalidCompatibleConstraintThrowsException(): void {
$manifestDocument = ManifestDocument::fromFile(__DIR__ . '/_fixture/extension-invalidcompatible.xml');
$mapper = new ManifestDocumentMapper();
$this->expectException(ManifestDocumentMapperException::class);
$mapper->map($manifestDocument);
}
}
================================================
FILE: tests/ManifestLoaderTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use function file_get_contents;
/**
* @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(): void {
$this->assertInstanceOf(
Manifest::class,
ManifestLoader::fromFile(__DIR__ . '/_fixture/library.xml')
);
}
public function testCanBeLoadedFromString(): void {
$this->assertInstanceOf(
Manifest::class,
ManifestLoader::fromString(
file_get_contents(__DIR__ . '/_fixture/library.xml')
)
);
}
public function testCanBeLoadedFromPhar(): void {
$this->assertInstanceOf(
Manifest::class,
ManifestLoader::fromPhar(__DIR__ . '/_fixture/test.phar')
);
}
public function testLoadingNonExistingFileThrowsException(): void {
$this->expectException(ManifestLoaderException::class);
ManifestLoader::fromFile('/not/existing');
}
/**
* @uses \PharIo\Manifest\ManifestDocumentLoadingException
*/
public function testLoadingInvalidXmlThrowsException(): void {
$this->expectException(ManifestLoaderException::class);
ManifestLoader::fromString('<?xml version="1.0" ?><broken>');
}
}
================================================
FILE: tests/ManifestSerializerTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 function file_get_contents;
use function sys_get_temp_dir;
use function uniqid;
use function unlink;
/**
* @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
*
* @uses \PharIo\Manifest\Application
* @uses \PharIo\Manifest\Library
* @uses \PharIo\Manifest\Extension
* @uses \PharIo\Manifest\ExtensionElement
*/
public function testCanSerializeToString($expected): void {
$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(): void {
$src = __DIR__ . '/_fixture/library.xml';
$dest = sys_get_temp_dir() . '/' . 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(): void {
$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)
);
}
}
================================================
FILE: tests/_fixture/custom.xml
================================================
<?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>
================================================
FILE: tests/_fixture/extension-invalidcompatible.xml
================================================
<?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>
================================================
FILE: tests/_fixture/extension.xml
================================================
<?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>
================================================
FILE: tests/_fixture/invalidversion.xml
================================================
<?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>
================================================
FILE: tests/_fixture/invalidversionconstraint.xml
================================================
<?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>
================================================
FILE: tests/_fixture/library.xml
================================================
<?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>
================================================
FILE: tests/_fixture/manifest.xml
================================================
<?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>
================================================
FILE: tests/_fixture/noemailauthor.xml
================================================
<?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" />
<license type="BSD-3-Clause" url="https://domain.tld/LICENSE"/>
</copyright>
<requires>
<php version="7.0"/>
</requires>
</phar>
================================================
FILE: tests/_fixture/phpunit-5.6.5.xml
================================================
<?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.0"/>
<component name="phpdocumentor/reflection-docblock" version="3.1.1"/>
<component name="phpdocumentor/type-resolver" version="0.2.0"/>
<component name="phpspec/prophecy" version="1.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="3.1.7"/>
<component name="webmozart/assert" version="1.1.0"/>
</bundles>
</phar>
================================================
FILE: tests/exceptions/ManifestDocumentLoadingExceptionTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 LibXMLError;
use function libxml_get_errors;
use function libxml_use_internal_errors;
class ManifestDocumentLoadingExceptionTest extends \PHPUnit\Framework\TestCase {
public function testXMLErrorsCanBeRetrieved(): void {
$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());
}
}
================================================
FILE: tests/values/ApplicationNameTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->assertInstanceOf(
ApplicationName::class,
new ApplicationName('foo/bar')
);
}
public function testUsingInvalidFormatForNameThrowsException(): void {
$this->expectException(InvalidApplicationNameException::class);
$this->expectExceptionCode(InvalidApplicationNameException::InvalidFormat);
new ApplicationName('foo');
}
public function testReturnsTrueForEqualNamesWhenCompared(): void {
$app = new ApplicationName('foo/bar');
$this->assertTrue(
$app->isEqual($app)
);
}
public function testReturnsFalseForNonEqualNamesWhenCompared(): void {
$app1 = new ApplicationName('foo/bar');
$app2 = new ApplicationName('foo/foo');
$this->assertFalse(
$app1->isEqual($app2)
);
}
public function testCanBeConvertedToString(): void {
$this->assertEquals(
'foo/bar',
(new ApplicationName('foo/bar'))->asString()
);
}
}
================================================
FILE: tests/values/ApplicationTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->type = Type::application();
}
public function testCanBeCreated(): void {
$this->assertInstanceOf(Application::class, $this->type);
}
public function testIsApplication(): void {
$this->assertTrue($this->type->isApplication());
}
public function testIsNotLibrary(): void {
$this->assertFalse($this->type->isLibrary());
}
public function testIsNotExtension(): void {
$this->assertFalse($this->type->isExtension());
}
}
================================================
FILE: tests/values/AuthorCollectionTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->collection = new AuthorCollection;
$this->item = new Author('Joe Developer', new Email('user@example.com'));
}
public function testCanBeCreated(): void {
$this->assertInstanceOf(AuthorCollection::class, $this->collection);
}
public function testCanBeCounted(): void {
$this->collection->add($this->item);
$this->assertCount(1, $this->collection);
}
public function testCanBeIterated(): void {
$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 testKeyPositionCanBeRetrieved(): void {
$this->collection->add($this->item);
foreach ($this->collection as $key => $item) {
$this->assertEquals(0, $key);
}
}
}
================================================
FILE: tests/values/AuthorTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->author = new Author('Joe Developer', new Email('user@example.com'));
}
public function testCanBeCreated(): void {
$this->assertInstanceOf(Author::class, $this->author);
}
public function testNameCanBeRetrieved(): void {
$this->assertEquals('Joe Developer', $this->author->getName());
}
public function testEmailCanBeRetrieved(): void {
$email = $this->author->getEmail();
$this->assertEquals('user@example.com', $email->asString());
}
public function testCanBeUsedAsString(): void {
$this->assertEquals('Joe Developer <user@example.com>', $this->author->asString());
}
public function testCanBeCreatedWithoutEmail(): void {
$this->assertInstanceOf(Author::class, new Author('Joe Developer'));
}
public function testHasEmailReturnsTrueWhenEMailIsSet(): void {
$this->assertTrue($this->author->hasEmail());
}
public function testHasEmailReturnsFalseOnMissingEMail(): void {
$this->assertFalse((new Author('Joe Developer'))->hasEmail());
}
public function testThrowsExceptionWhenMissingEmailAddressIsQueried(): void {
$author = new Author('Joe Developer');
$this->expectException(NoEmailAddressException::class);
$author->getEmail();
}
}
================================================
FILE: tests/values/BundledComponentCollectionTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->collection = new BundledComponentCollection;
$this->item = new BundledComponent('phpunit/php-code-coverage', new Version('4.0.2'));
}
public function testCanBeCreated(): void {
$this->assertInstanceOf(BundledComponentCollection::class, $this->collection);
}
public function testCanBeCounted(): void {
$this->collection->add($this->item);
$this->assertCount(1, $this->collection);
}
public function testCanBeIterated(): void {
$this->collection->add($this->createMock(BundledComponent::class));
$this->collection->add($this->item);
$this->assertContains($this->item, $this->collection);
}
public function testKeyPositionCanBeRetrieved(): void {
$this->collection->add($this->item);
foreach ($this->collection as $key => $item) {
$this->assertEquals(0, $key);
}
}
}
================================================
FILE: tests/values/BundledComponentTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->bundledComponent = new BundledComponent('phpunit/php-code-coverage', new Version('4.0.2'));
}
public function testCanBeCreated(): void {
$this->assertInstanceOf(BundledComponent::class, $this->bundledComponent);
}
public function testNameCanBeRetrieved(): void {
$this->assertEquals('phpunit/php-code-coverage', $this->bundledComponent->getName());
}
public function testVersionCanBeRetrieved(): void {
$this->assertEquals('4.0.2', $this->bundledComponent->getVersion()->getVersionString());
}
}
================================================
FILE: tests/values/CopyrightInformationTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$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(): void {
$this->assertInstanceOf(CopyrightInformation::class, $this->copyrightInformation);
}
public function testAuthorsCanBeRetrieved(): void {
$this->assertContains($this->author, $this->copyrightInformation->getAuthors());
}
public function testLicenseCanBeRetrieved(): void {
$this->assertEquals($this->license, $this->copyrightInformation->getLicense());
}
}
================================================
FILE: tests/values/EmailTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->assertInstanceOf(Email::class, new Email('user@example.com'));
}
public function testCanBeRequestedAsString(): void {
$this->assertEquals('user@example.com', (new Email('user@example.com'))->asString());
}
/**
* @covers \PharIo\Manifest\InvalidEmailException
*/
public function testCannotBeCreatedForInvalidEmail(): void {
$this->expectException(InvalidEmailException::class);
new Email('invalid');
}
}
================================================
FILE: tests/values/ExtensionTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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;
use PHPUnit_Framework_MockObject_MockObject;
/**
* @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(): void {
$this->name = $this->createMock(ApplicationName::class);
$this->type = Type::extension($this->name, new AnyVersionConstraint);
}
public function testCanBeCreated(): void {
$this->assertInstanceOf(Extension::class, $this->type);
}
public function testIsNotApplication(): void {
$this->assertFalse($this->type->isApplication());
}
public function testIsNotLibrary(): void {
$this->assertFalse($this->type->isLibrary());
}
public function testIsExtension(): void {
$this->assertTrue($this->type->isExtension());
}
public function testApplicationCanBeRetrieved(): void {
$this->assertInstanceOf(ApplicationName::class, $this->type->getApplicationName());
}
public function testVersionConstraintCanBeRetrieved(): void {
$this->assertInstanceOf(
VersionConstraint::class,
$this->type->getVersionConstraint()
);
}
public function testApplicationCanBeQueried(): void {
$this->name->method('isEqual')->willReturn(true);
$this->assertTrue(
$this->type->isExtensionFor($this->createMock(ApplicationName::class))
);
}
public function testCompatibleWithReturnsTrueForMatchingVersionConstraintAndApplication(): void {
$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(): void {
$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(): void {
$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)
);
}
}
================================================
FILE: tests/values/LibraryTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->type = Type::library();
}
public function testCanBeCreated(): void {
$this->assertInstanceOf(Library::class, $this->type);
}
public function testIsNotApplication(): void {
$this->assertFalse($this->type->isApplication());
}
public function testIsLibrary(): void {
$this->assertTrue($this->type->isLibrary());
}
public function testIsNotExtension(): void {
$this->assertFalse($this->type->isExtension());
}
}
================================================
FILE: tests/values/LicenseTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->license = new License('BSD-3-Clause', new Url('https://github.com/sebastianbergmann/phpunit/blob/master/LICENSE'));
}
public function testCanBeCreated(): void {
$this->assertInstanceOf(License::class, $this->license);
}
public function testNameCanBeRetrieved(): void {
$this->assertEquals('BSD-3-Clause', $this->license->getName());
}
public function testUrlCanBeRetrieved(): void {
$this->assertEquals(
'https://github.com/sebastianbergmann/phpunit/blob/master/LICENSE',
$this->license->getUrl()->asString()
);
}
}
================================================
FILE: tests/values/ManifestTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 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(): void {
$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(): void {
$this->assertInstanceOf(Manifest::class, $this->manifest);
}
public function testNameCanBeRetrieved(): void {
$this->assertEquals($this->name, $this->manifest->getName());
}
public function testVersionCanBeRetrieved(): void {
$this->assertEquals($this->version, $this->manifest->getVersion());
}
public function testTypeCanBeRetrieved(): void {
$this->assertEquals($this->type, $this->manifest->getType());
}
public function testTypeCanBeQueried(): void {
$this->assertTrue($this->manifest->isApplication());
$this->assertFalse($this->manifest->isLibrary());
$this->assertFalse($this->manifest->isExtension());
}
public function testCopyrightInformationCanBeRetrieved(): void {
$this->assertEquals($this->copyrightInformation, $this->manifest->getCopyrightInformation());
}
public function testRequirementsCanBeRetrieved(): void {
$this->assertEquals($this->requirements, $this->manifest->getRequirements());
}
public function testBundledComponentsCanBeRetrieved(): void {
$this->assertEquals($this->bundledComponents, $this->manifest->getBundledComponents());
}
/**
* @uses \PharIo\Manifest\Extension
*/
public function testExtendedApplicationCanBeQueriedForExtension(): void {
$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(): void {
$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(): void {
$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')));
}
}
================================================
FILE: tests/values/PhpExtensionRequirementTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->assertInstanceOf(PhpExtensionRequirement::class, new PhpExtensionRequirement('dom'));
}
public function testCanBeConvertedToString(): void {
$this->assertEquals('dom', (new PhpExtensionRequirement('dom'))->asString());
}
}
================================================
FILE: tests/values/PhpVersionRequirementTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->requirement = new PhpVersionRequirement(new ExactVersionConstraint('7.1.0'));
}
public function testCanBeCreated(): void {
$this->assertInstanceOf(PhpVersionRequirement::class, $this->requirement);
}
public function testVersionConstraintCanBeRetrieved(): void {
$this->assertEquals('7.1.0', $this->requirement->getVersionConstraint()->asString());
}
}
================================================
FILE: tests/values/RequirementCollectionTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->collection = new RequirementCollection;
$this->item = new PhpVersionRequirement(new ExactVersionConstraint('7.1.0'));
}
public function testCanBeCreated(): void {
$this->assertInstanceOf(RequirementCollection::class, $this->collection);
}
public function testCanBeCounted(): void {
$this->collection->add($this->item);
$this->assertCount(1, $this->collection);
}
public function testCanBeIterated(): void {
$this->collection->add(new PhpVersionRequirement(new ExactVersionConstraint('5.6.0')));
$this->collection->add($this->item);
$this->assertContains($this->item, $this->collection);
}
public function testKeyPositionCanBeRetrieved(): void {
$this->collection->add($this->item);
foreach ($this->collection as $key => $item) {
$this->assertEquals(0, $key);
}
}
}
================================================
FILE: tests/values/UrlTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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(): void {
$this->assertInstanceOf(Url::class, new Url('https://phar.io/'));
}
public function testCanBeConvertedToString(): void {
$this->assertEquals('https://phar.io/', (new Url('https://phar.io/'))->asString());
}
/**
* @covers PharIo\Manifest\InvalidUrlException
*/
public function testCannotBeCreatedForInvalidUrl(): void {
$this->expectException(InvalidUrlException::class);
new Url('invalid');
}
}
================================================
FILE: tests/xml/AuthorElementCollectionTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
class AuthorElementCollectionTest extends \PHPUnit\Framework\TestCase {
public function testAuthorElementCanBeRetrievedFromCollection(): void {
$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);
}
}
}
================================================
FILE: tests/xml/AuthorElementTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
class AuthorElementTest extends \PHPUnit\Framework\TestCase {
/** @var AuthorElement */
private $author;
protected function setUp(): void {
$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(): void {
$this->assertEquals('Reiner Zufall', $this->author->getName());
}
public function testEmailCanBeRetrieved(): void {
$this->assertEquals('reiner@zufall.de', $this->author->getEmail());
}
public function testHasEmailReturnsTrueWhenEMailIsSet(): void {
$this->assertTrue($this->author->hasEmail());
}
public function testHasEMailReturnsFalseWhenNoEMailAddressIsSet(): void {
$dom = new DOMDocument();
$dom->loadXML('<?xml version="1.0" ?><author xmlns="https://phar.io/xml/manifest/1.0" name="Reiner Zufall" />');
$this->assertFalse((new AuthorElement($dom->documentElement))->hasEMail());
}
}
================================================
FILE: tests/xml/BundlesElementTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
class BundlesElementTest extends \PHPUnit\Framework\TestCase {
/** @var DOMDocument */
private $dom;
/** @var BundlesElement */
private $bundles;
protected function setUp(): void {
$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(): void {
$this->expectException(ManifestElementException::class);
$this->bundles->getComponentElements();
}
public function testGetComponentElementsReturnsComponentElementCollection(): void {
$this->addComponent();
$this->assertInstanceOf(
ComponentElement::class,
$this->bundles->getComponentElements()->current()
);
}
private function addComponent(): void {
$this->dom->documentElement->appendChild(
$this->dom->createElementNS('https://phar.io/xml/manifest/1.0', 'component')
);
}
}
================================================
FILE: tests/xml/ComponentElementCollectionTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
class ComponentElementCollectionTest extends \PHPUnit\Framework\TestCase {
public function testComponentElementCanBeRetrievedFromCollection(): void {
$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);
}
}
}
================================================
FILE: tests/xml/ComponentElementTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
class ComponentElementTest extends \PHPUnit\Framework\TestCase {
/** @var ComponentElement */
private $component;
protected function setUp(): void {
$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(): void {
$this->assertEquals('phar-io/phive', $this->component->getName());
}
public function testEmailCanBeRetrieved(): void {
$this->assertEquals('0.6.0', $this->component->getVersion());
}
}
================================================
FILE: tests/xml/ContainsElementTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 ContainsElementTest extends \PHPUnit\Framework\TestCase {
/** @var DOMElement */
private $domElement;
/** @var ContainsElement */
private $contains;
protected function setUp(): void {
$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(): void {
$this->assertEquals('5.6.5', $this->contains->getVersion());
}
public function testThrowsExceptionWhenVersionAttributeIsMissing(): void {
$this->domElement->removeAttribute('version');
$this->expectException(ManifestElementException::class);
$this->contains->getVersion();
}
public function testNameCanBeRetrieved(): void {
$this->assertEquals('phpunit/phpunit', $this->contains->getName());
}
public function testThrowsExceptionWhenNameAttributeIsMissing(): void {
$this->domElement->removeAttribute('name');
$this->expectException(ManifestElementException::class);
$this->contains->getName();
}
public function testTypeCanBeRetrieved(): void {
$this->assertEquals('application', $this->contains->getType());
}
public function testThrowsExceptionWhenTypeAttributeIsMissing(): void {
$this->domElement->removeAttribute('type');
$this->expectException(ManifestElementException::class);
$this->contains->getType();
}
public function testGetExtensionElementReturnsExtensionElement(): void {
$this->domElement->appendChild(
$this->domElement->ownerDocument->createElementNS('https://phar.io/xml/manifest/1.0', 'extension')
);
$this->assertInstanceOf(ExtensionElement::class, $this->contains->getExtensionElement());
}
}
================================================
FILE: tests/xml/CopyrightElementTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
class CopyrightElementTest extends \PHPUnit\Framework\TestCase {
/** @var DOMDocument */
private $dom;
/** @var CopyrightElement */
private $copyright;
protected function setUp(): void {
$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(): void {
$this->expectException(ManifestElementException::class);
$this->copyright->getAuthorElements();
}
public function testThrowsExceptionWhenGetLicenseElementIsCalledButNodeIsMissing(): void {
$this->expectException(ManifestElementException::class);
$this->copyright->getLicenseElement();
}
public function testGetAuthorElementsReturnsAuthorElementCollection(): void {
$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(): void {
$this->dom->documentElement->appendChild(
$this->dom->createElementNS('https://phar.io/xml/manifest/1.0', 'license')
);
$this->assertInstanceOf(
LicenseElement::class,
$this->copyright->getLicenseElement()
);
}
}
================================================
FILE: tests/xml/ElementCollectionTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* 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 PHPUnit\Framework\TestCase;
class ElementCollectionTest extends TestCase {
public function testEnforcesDOMElementsOnly(): void {
$dom = new DOMDocument();
$dom->loadXML('<?xml version="1.0"?><root>text</root>');
$this->expectException(ElementCollectionException::class);
new class($dom->documentElement->childNodes) extends ElementCollection {
public function current(): void {
}
};
}
}
================================================
FILE: tests/xml/ExtElementCollectionTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
class ExtElementCollectionTest extends \PHPUnit\Framework\TestCase {
public function testComponentElementCanBeRetrievedFromCollection(): void {
$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);
}
}
}
================================================
FILE: tests/xml/ExtElementTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
class ExtElementTest extends \PHPUnit\Framework\TestCase {
/** @var ExtElement */
private $ext;
protected function setUp(): void {
$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(): void {
$this->assertEquals('dom', $this->ext->getName());
}
}
================================================
FILE: tests/xml/ExtensionElementTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
class ExtensionElementTest extends \PHPUnit\Framework\TestCase {
/** @var ExtensionElement */
private $extension;
protected function setUp(): void {
$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(): void {
$this->assertEquals('phar-io/phive', $this->extension->getFor());
}
public function testCompatibleVersionConstraintCanBeRetrieved(): void {
$this->assertEquals('~0.6', $this->extension->getCompatible());
}
}
================================================
FILE: tests/xml/LicenseElementTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
class LicenseElementTest extends \PHPUnit\Framework\TestCase {
/** @var LicenseElement */
private $license;
protected function setUp(): void {
$dom = new DOMDocument();
$dom->loadXML('<?xml version="1.0" ?><license xmlns="https://phar.io/xml/manifest/1.0" type="BSD-3" url="https://some.tld/LICENSE" />');
$this->license = new LicenseElement($dom->documentElement);
}
public function testTypeCanBeRetrieved(): void {
$this->assertEquals('BSD-3', $this->license->getType());
}
public function testUrlCanBeRetrieved(): void {
$this->assertEquals('https://some.tld/LICENSE', $this->license->getUrl());
}
}
================================================
FILE: tests/xml/ManifestDocumentTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use function file_get_contents;
class ManifestDocumentTest extends \PHPUnit\Framework\TestCase {
public function testThrowsExceptionWhenFileDoesNotExist(): void {
$this->expectException(ManifestDocumentException::class);
ManifestDocument::fromFile('/does/not/exist');
}
public function testCanBeCreatedFromFile(): void {
$this->assertInstanceOf(
ManifestDocument::class,
ManifestDocument::fromFile(__DIR__ . '/../_fixture/phpunit-5.6.5.xml')
);
}
public function testFromStringThrowsExceptionOnEmptyString(): void {
$this->expectException(ManifestDocumentException::class);
ManifestDocument::fromString('');
}
public function testCanBeConstructedFromString(): void {
$content = file_get_contents(__DIR__ . '/../_fixture/phpunit-5.6.5.xml');
$this->assertInstanceOf(
ManifestDocument::class,
ManifestDocument::fromString($content)
);
}
public function testThrowsExceptionOnInvalidXML(): void {
$this->expectException(ManifestDocumentLoadingException::class);
ManifestDocument::fromString('<?xml version="1.0" ?><root>');
}
public function testLoadingDocumentWithWrongRootNameThrowsException(): void {
$this->expectException(ManifestDocumentException::class);
ManifestDocument::fromString('<?xml version="1.0" ?><root />');
}
public function testLoadingDocumentWithWrongNamespaceThrowsException(): void {
$this->expectException(ManifestDocumentException::class);
ManifestDocument::fromString('<?xml version="1.0" ?><phar xmlns="foo:bar" />');
}
public function testContainsElementCanBeRetrieved(): void {
$this->assertInstanceOf(
ContainsElement::class,
$this->loadFixture()->getContainsElement()
);
}
public function testRequiresElementCanBeRetrieved(): void {
$this->assertInstanceOf(
RequiresElement::class,
$this->loadFixture()->getRequiresElement()
);
}
public function testCopyrightElementCanBeRetrieved(): void {
$this->assertInstanceOf(
CopyrightElement::class,
$this->loadFixture()->getCopyrightElement()
);
}
public function testBundlesElementCanBeRetrieved(): void {
$this->assertInstanceOf(
BundlesElement::class,
$this->loadFixture()->getBundlesElement()
);
}
public function testThrowsExceptionWhenContainsIsMissing(): void {
$this->expectException(ManifestDocumentException::class);
$this->loadEmptyFixture()->getContainsElement();
}
public function testThrowsExceptionWhenCopyirhgtIsMissing(): void {
$this->expectException(ManifestDocumentException::class);
$this->loadEmptyFixture()->getCopyrightElement();
}
public function testThrowsExceptionWhenRequiresIsMissing(): void {
$this->expectException(ManifestDocumentException::class);
$this->loadEmptyFixture()->getRequiresElement();
}
public function testThrowsExceptionWhenBundlesIsMissing(): void {
$this->expectException(ManifestDocumentException::class);
$this->loadEmptyFixture()->getBundlesElement();
}
public function testHasBundlesReturnsTrueWhenBundlesNodeIsPresent(): void {
$this->assertTrue(
$this->loadFixture()->hasBundlesElement()
);
}
public function testHasBundlesReturnsFalseWhenBundlesNoNodeIsPresent(): void {
$this->assertFalse(
$this->loadEmptyFixture()->hasBundlesElement()
);
}
private function loadFixture() {
return ManifestDocument::fromFile(__DIR__ . '/../_fixture/phpunit-5.6.5.xml');
}
private function loadEmptyFixture() {
return ManifestDocument::fromString(
'<?xml version="1.0" ?><phar xmlns="https://phar.io/xml/manifest/1.0" />'
);
}
}
================================================
FILE: tests/xml/PhpElementTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
class PhpElementTest extends \PHPUnit\Framework\TestCase {
/** @var DOMDocument */
private $dom;
/** @var PhpElement */
private $php;
protected function setUp(): void {
$this->dom = new DOMDocument();
$this->dom->loadXML('<?xml version="1.0" ?><php xmlns="https://phar.io/xml/manifest/1.0" version="^5.6 || ^7.0" />');
$this->php = new PhpElement($this->dom->documentElement);
}
public function testVersionConstraintCanBeRetrieved(): void {
$this->assertEquals('^5.6 || ^7.0', $this->php->getVersion());
}
public function testHasExtElementsReturnsFalseWhenNoExtensionsAreRequired(): void {
$this->assertFalse($this->php->hasExtElements());
}
public function testHasExtElementsReturnsTrueWhenExtensionsAreRequired(): void {
$this->addExtElement();
$this->assertTrue($this->php->hasExtElements());
}
public function testGetExtElementsReturnsExtElementCollection(): void {
$this->addExtElement();
$this->assertInstanceOf(ExtElementCollection::class, $this->php->getExtElements());
}
private function addExtElement(): void {
$this->dom->documentElement->appendChild(
$this->dom->createElementNS('https://phar.io/xml/manifest/1.0', 'ext')
);
}
}
================================================
FILE: tests/xml/RequiresElementTest.php
================================================
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Manifest.
*
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
class RequiresElementTest extends \PHPUnit\Framework\TestCase {
/** @var DOMDocument */
private $dom;
/** @var RequiresElement */
private $requires;
protected function setUp(): void {
$this->dom = new DOMDocument();
$this->dom->loadXML('<?xml version="1.0" ?><requires xmlns="https://phar.io/xml/manifest/1.0" />');
$this->requires = new RequiresElement($this->dom->documentElement);
}
public function testThrowsExceptionWhenGetPhpElementIsCalledButElementIsMissing(): void {
$this->expectException(ManifestElementException::class);
$this->requires->getPHPElement();
}
public function testHasExtElementsReturnsTrueWhenExtensionsAreRequired(): void {
$this->dom->documentElement->appendChild(
$this->dom->createElementNS('https://phar.io/xml/manifest/1.0', 'php')
);
$this->assertInstanceOf(PhpElement::class, $this->requires->getPHPElement());
}
}
gitextract_flwa4hbi/
├── .gitattributes
├── .github/
│ ├── FUNDING.yml
│ └── workflows/
│ └── ci.yml
├── .gitignore
├── .php-cs-fixer.dist.php
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.xml
├── composer.json
├── examples/
│ ├── example-01.php
│ └── example-02.php
├── manifest.xsd
├── phive.xml
├── phpunit.xml
├── psalm.xml
├── src/
│ ├── ManifestDocumentMapper.php
│ ├── ManifestLoader.php
│ ├── ManifestSerializer.php
│ ├── exceptions/
│ │ ├── ElementCollectionException.php
│ │ ├── Exception.php
│ │ ├── InvalidApplicationNameException.php
│ │ ├── InvalidEmailException.php
│ │ ├── InvalidUrlException.php
│ │ ├── ManifestDocumentException.php
│ │ ├── ManifestDocumentLoadingException.php
│ │ ├── ManifestDocumentMapperException.php
│ │ ├── ManifestElementException.php
│ │ ├── ManifestLoaderException.php
│ │ └── NoEmailAddressException.php
│ ├── values/
│ │ ├── Application.php
│ │ ├── ApplicationName.php
│ │ ├── Author.php
│ │ ├── AuthorCollection.php
│ │ ├── AuthorCollectionIterator.php
│ │ ├── BundledComponent.php
│ │ ├── BundledComponentCollection.php
│ │ ├── BundledComponentCollectionIterator.php
│ │ ├── CopyrightInformation.php
│ │ ├── Email.php
│ │ ├── Extension.php
│ │ ├── Library.php
│ │ ├── License.php
│ │ ├── Manifest.php
│ │ ├── PhpExtensionRequirement.php
│ │ ├── PhpVersionRequirement.php
│ │ ├── Requirement.php
│ │ ├── RequirementCollection.php
│ │ ├── RequirementCollectionIterator.php
│ │ ├── Type.php
│ │ └── Url.php
│ └── xml/
│ ├── AuthorElement.php
│ ├── AuthorElementCollection.php
│ ├── BundlesElement.php
│ ├── ComponentElement.php
│ ├── ComponentElementCollection.php
│ ├── ContainsElement.php
│ ├── CopyrightElement.php
│ ├── ElementCollection.php
│ ├── ExtElement.php
│ ├── ExtElementCollection.php
│ ├── ExtensionElement.php
│ ├── LicenseElement.php
│ ├── ManifestDocument.php
│ ├── ManifestElement.php
│ ├── PhpElement.php
│ └── RequiresElement.php
└── tests/
├── ManifestDocumentMapperTest.php
├── ManifestLoaderTest.php
├── ManifestSerializerTest.php
├── _fixture/
│ ├── custom.xml
│ ├── extension-invalidcompatible.xml
│ ├── extension.xml
│ ├── invalidversion.xml
│ ├── invalidversionconstraint.xml
│ ├── library.xml
│ ├── manifest.xml
│ ├── noemailauthor.xml
│ ├── phpunit-5.6.5.xml
│ └── test.phar
├── exceptions/
│ └── ManifestDocumentLoadingExceptionTest.php
├── values/
│ ├── ApplicationNameTest.php
│ ├── ApplicationTest.php
│ ├── AuthorCollectionTest.php
│ ├── AuthorTest.php
│ ├── BundledComponentCollectionTest.php
│ ├── BundledComponentTest.php
│ ├── CopyrightInformationTest.php
│ ├── EmailTest.php
│ ├── ExtensionTest.php
│ ├── LibraryTest.php
│ ├── LicenseTest.php
│ ├── ManifestTest.php
│ ├── PhpExtensionRequirementTest.php
│ ├── PhpVersionRequirementTest.php
│ ├── RequirementCollectionTest.php
│ └── UrlTest.php
└── xml/
├── AuthorElementCollectionTest.php
├── AuthorElementTest.php
├── BundlesElementTest.php
├── ComponentElementCollectionTest.php
├── ComponentElementTest.php
├── ContainsElementTest.php
├── CopyrightElementTest.php
├── ElementCollectionTest.php
├── ExtElementCollectionTest.php
├── ExtElementTest.php
├── ExtensionElementTest.php
├── LicenseElementTest.php
├── ManifestDocumentTest.php
├── PhpElementTest.php
└── RequiresElementTest.php
SYMBOL INDEX (403 symbols across 86 files)
FILE: src/ManifestDocumentMapper.php
class ManifestDocumentMapper (line 19) | class ManifestDocumentMapper {
method map (line 20) | public function map(ManifestDocument $document): Manifest {
method mapType (line 41) | private function mapType(ContainsElement $contains): Type {
method mapCopyright (line 56) | private function mapCopyright(CopyrightElement $copyright): CopyrightI...
method mapRequirements (line 80) | private function mapRequirements(RequiresElement $requires): Requireme...
method mapBundledComponents (line 114) | private function mapBundledComponents(ManifestDocument $document): Bun...
method mapExtension (line 135) | private function mapExtension(ExtensionElement $extension): Extension {
FILE: src/ManifestLoader.php
class ManifestLoader (line 15) | class ManifestLoader {
method fromFile (line 16) | public static function fromFile(string $filename): Manifest {
method fromPhar (line 30) | public static function fromPhar(string $filename): Manifest {
method fromString (line 34) | public static function fromString(string $manifest): Manifest {
FILE: src/ManifestSerializer.php
class ManifestSerializer (line 22) | class ManifestSerializer {
method serializeToFile (line 26) | public function serializeToFile(Manifest $manifest, string $filename):...
method serializeToString (line 33) | public function serializeToString(Manifest $manifest): string {
method startDocument (line 44) | private function startDocument(): void {
method finishDocument (line 56) | private function finishDocument(): string {
method addContains (line 63) | private function addContains(ApplicationName $name, Version $version, ...
method addCopyright (line 100) | private function addCopyright(CopyrightInformation $copyrightInformati...
method addRequirements (line 120) | private function addRequirements(RequirementCollection $requirementCol...
method addBundles (line 150) | private function addBundles(BundledComponentCollection $bundledCompone...
method addExtension (line 166) | private function addExtension(ApplicationName $applicationName, Versio...
FILE: src/exceptions/ElementCollectionException.php
class ElementCollectionException (line 15) | class ElementCollectionException extends InvalidArgumentException implem...
FILE: src/exceptions/Exception.php
type Exception (line 15) | interface Exception extends Throwable {
FILE: src/exceptions/InvalidApplicationNameException.php
class InvalidApplicationNameException (line 15) | class InvalidApplicationNameException extends InvalidArgumentException i...
FILE: src/exceptions/InvalidEmailException.php
class InvalidEmailException (line 15) | class InvalidEmailException extends InvalidArgumentException implements ...
FILE: src/exceptions/InvalidUrlException.php
class InvalidUrlException (line 15) | class InvalidUrlException extends InvalidArgumentException implements Ex...
FILE: src/exceptions/ManifestDocumentException.php
class ManifestDocumentException (line 15) | class ManifestDocumentException extends RuntimeException implements Exce...
FILE: src/exceptions/ManifestDocumentLoadingException.php
class ManifestDocumentLoadingException (line 16) | class ManifestDocumentLoadingException extends \Exception implements Exc...
method __construct (line 25) | public function __construct(array $libxmlErrors) {
method getLibxmlErrors (line 44) | public function getLibxmlErrors(): array {
FILE: src/exceptions/ManifestDocumentMapperException.php
class ManifestDocumentMapperException (line 15) | class ManifestDocumentMapperException extends RuntimeException implement...
FILE: src/exceptions/ManifestElementException.php
class ManifestElementException (line 15) | class ManifestElementException extends RuntimeException implements Excep...
FILE: src/exceptions/ManifestLoaderException.php
class ManifestLoaderException (line 13) | class ManifestLoaderException extends \Exception implements Exception {
FILE: src/exceptions/NoEmailAddressException.php
class NoEmailAddressException (line 15) | class NoEmailAddressException extends InvalidArgumentException implement...
FILE: src/values/Application.php
class Application (line 13) | class Application extends Type {
method isApplication (line 14) | public function isApplication(): bool {
FILE: src/values/ApplicationName.php
class ApplicationName (line 16) | class ApplicationName {
method __construct (line 20) | public function __construct(string $name) {
method asString (line 25) | public function asString(): string {
method isEqual (line 29) | public function isEqual(ApplicationName $name): bool {
method ensureValidFormat (line 33) | private function ensureValidFormat(string $name): void {
FILE: src/values/Author.php
class Author (line 15) | class Author {
method __construct (line 22) | public function __construct(string $name, ?Email $email = null) {
method asString (line 27) | public function asString(): string {
method getName (line 39) | public function getName(): string {
method hasEmail (line 46) | public function hasEmail(): bool {
method getEmail (line 50) | public function getEmail(): Email {
FILE: src/values/AuthorCollection.php
class AuthorCollection (line 18) | class AuthorCollection implements Countable, IteratorAggregate {
method add (line 22) | public function add(Author $author): void {
method getAuthors (line 29) | public function getAuthors(): array {
method count (line 33) | public function count(): int {
method getIterator (line 37) | public function getIterator(): AuthorCollectionIterator {
FILE: src/values/AuthorCollectionIterator.php
class AuthorCollectionIterator (line 17) | class AuthorCollectionIterator implements Iterator {
method __construct (line 24) | public function __construct(AuthorCollection $authors) {
method rewind (line 28) | public function rewind(): void {
method valid (line 32) | public function valid(): bool {
method key (line 36) | public function key(): int {
method current (line 40) | public function current(): Author {
method next (line 44) | public function next(): void {
FILE: src/values/BundledComponent.php
class BundledComponent (line 15) | class BundledComponent {
method __construct (line 22) | public function __construct(string $name, Version $version) {
method getName (line 27) | public function getName(): string {
method getVersion (line 31) | public function getVersion(): Version {
FILE: src/values/BundledComponentCollection.php
class BundledComponentCollection (line 18) | class BundledComponentCollection implements Countable, IteratorAggregate {
method add (line 22) | public function add(BundledComponent $bundledComponent): void {
method getBundledComponents (line 29) | public function getBundledComponents(): array {
method count (line 33) | public function count(): int {
method getIterator (line 37) | public function getIterator(): BundledComponentCollectionIterator {
FILE: src/values/BundledComponentCollectionIterator.php
class BundledComponentCollectionIterator (line 17) | class BundledComponentCollectionIterator implements Iterator {
method __construct (line 24) | public function __construct(BundledComponentCollection $bundledCompone...
method rewind (line 28) | public function rewind(): void {
method valid (line 32) | public function valid(): bool {
method key (line 36) | public function key(): int {
method current (line 40) | public function current(): BundledComponent {
method next (line 44) | public function next(): void {
FILE: src/values/CopyrightInformation.php
class CopyrightInformation (line 13) | class CopyrightInformation {
method __construct (line 20) | public function __construct(AuthorCollection $authors, License $licens...
method getAuthors (line 25) | public function getAuthors(): AuthorCollection {
method getLicense (line 29) | public function getLicense(): License {
FILE: src/values/Email.php
class Email (line 16) | class Email {
method __construct (line 20) | public function __construct(string $email) {
method asString (line 26) | public function asString(): string {
method ensureEmailIsValid (line 30) | private function ensureEmailIsValid(string $url): void {
FILE: src/values/Extension.php
class Extension (line 16) | class Extension extends Type {
method __construct (line 23) | public function __construct(ApplicationName $application, VersionConst...
method getApplicationName (line 28) | public function getApplicationName(): ApplicationName {
method getVersionConstraint (line 32) | public function getVersionConstraint(): VersionConstraint {
method isExtension (line 36) | public function isExtension(): bool {
method isExtensionFor (line 40) | public function isExtensionFor(ApplicationName $name): bool {
method isCompatibleWith (line 44) | public function isCompatibleWith(ApplicationName $name, Version $versi...
FILE: src/values/Library.php
class Library (line 13) | class Library extends Type {
method isLibrary (line 14) | public function isLibrary(): bool {
FILE: src/values/License.php
class License (line 13) | class License {
method __construct (line 20) | public function __construct(string $name, Url $url) {
method getName (line 25) | public function getName(): string {
method getUrl (line 29) | public function getUrl(): Url {
FILE: src/values/Manifest.php
class Manifest (line 15) | class Manifest {
method __construct (line 34) | public function __construct(ApplicationName $name, Version $version, T...
method getName (line 43) | public function getName(): ApplicationName {
method getVersion (line 47) | public function getVersion(): Version {
method getType (line 51) | public function getType(): Type {
method getCopyrightInformation (line 55) | public function getCopyrightInformation(): CopyrightInformation {
method getRequirements (line 59) | public function getRequirements(): RequirementCollection {
method getBundledComponents (line 63) | public function getBundledComponents(): BundledComponentCollection {
method isApplication (line 67) | public function isApplication(): bool {
method isLibrary (line 71) | public function isLibrary(): bool {
method isExtension (line 75) | public function isExtension(): bool {
method isExtensionFor (line 79) | public function isExtensionFor(ApplicationName $application, ?Version ...
FILE: src/values/PhpExtensionRequirement.php
class PhpExtensionRequirement (line 13) | class PhpExtensionRequirement implements Requirement {
method __construct (line 17) | public function __construct(string $extension) {
method asString (line 21) | public function asString(): string {
FILE: src/values/PhpVersionRequirement.php
class PhpVersionRequirement (line 15) | class PhpVersionRequirement implements Requirement {
method __construct (line 19) | public function __construct(VersionConstraint $versionConstraint) {
method getVersionConstraint (line 23) | public function getVersionConstraint(): VersionConstraint {
FILE: src/values/Requirement.php
type Requirement (line 13) | interface Requirement {
FILE: src/values/RequirementCollection.php
class RequirementCollection (line 18) | class RequirementCollection implements Countable, IteratorAggregate {
method add (line 22) | public function add(Requirement $requirement): void {
method getRequirements (line 29) | public function getRequirements(): array {
method count (line 33) | public function count(): int {
method getIterator (line 37) | public function getIterator(): RequirementCollectionIterator {
FILE: src/values/RequirementCollectionIterator.php
class RequirementCollectionIterator (line 17) | class RequirementCollectionIterator implements Iterator {
method __construct (line 24) | public function __construct(RequirementCollection $requirements) {
method rewind (line 28) | public function rewind(): void {
method valid (line 32) | public function valid(): bool {
method key (line 36) | public function key(): int {
method current (line 40) | public function current(): Requirement {
method next (line 44) | public function next(): void {
FILE: src/values/Type.php
class Type (line 15) | abstract class Type {
method application (line 16) | public static function application(): Application {
method library (line 20) | public static function library(): Library {
method extension (line 24) | public static function extension(ApplicationName $application, Version...
method isApplication (line 29) | public function isApplication(): bool {
method isLibrary (line 34) | public function isLibrary(): bool {
method isExtension (line 39) | public function isExtension(): bool {
FILE: src/values/Url.php
class Url (line 16) | class Url {
method __construct (line 20) | public function __construct(string $url) {
method asString (line 26) | public function asString(): string {
method ensureUrlIsValid (line 33) | private function ensureUrlIsValid(string $url): void {
FILE: src/xml/AuthorElement.php
class AuthorElement (line 13) | class AuthorElement extends ManifestElement {
method getName (line 14) | public function getName(): string {
method getEmail (line 18) | public function getEmail(): string {
method hasEMail (line 22) | public function hasEMail(): bool {
FILE: src/xml/AuthorElementCollection.php
class AuthorElementCollection (line 13) | class AuthorElementCollection extends ElementCollection {
method current (line 14) | public function current(): AuthorElement {
FILE: src/xml/BundlesElement.php
class BundlesElement (line 13) | class BundlesElement extends ManifestElement {
method getComponentElements (line 14) | public function getComponentElements(): ComponentElementCollection {
FILE: src/xml/ComponentElement.php
class ComponentElement (line 13) | class ComponentElement extends ManifestElement {
method getName (line 14) | public function getName(): string {
method getVersion (line 18) | public function getVersion(): string {
FILE: src/xml/ComponentElementCollection.php
class ComponentElementCollection (line 13) | class ComponentElementCollection extends ElementCollection {
method current (line 14) | public function current(): ComponentElement {
FILE: src/xml/ContainsElement.php
class ContainsElement (line 13) | class ContainsElement extends ManifestElement {
method getName (line 14) | public function getName(): string {
method getVersion (line 18) | public function getVersion(): string {
method getType (line 22) | public function getType(): string {
method getExtensionElement (line 26) | public function getExtensionElement(): ExtensionElement {
FILE: src/xml/CopyrightElement.php
class CopyrightElement (line 13) | class CopyrightElement extends ManifestElement {
method getAuthorElements (line 14) | public function getAuthorElements(): AuthorElementCollection {
method getLicenseElement (line 20) | public function getLicenseElement(): LicenseElement {
FILE: src/xml/ElementCollection.php
class ElementCollection (line 22) | abstract class ElementCollection implements Iterator {
method __construct (line 29) | public function __construct(DOMNodeList $nodeList) {
method current (line 34) | #[ReturnTypeWillChange]
method next (line 37) | public function next(): void {
method key (line 41) | public function key(): int {
method valid (line 45) | public function valid(): bool {
method rewind (line 49) | public function rewind(): void {
method getCurrentElement (line 53) | protected function getCurrentElement(): DOMElement {
method importNodes (line 57) | private function importNodes(DOMNodeList $nodeList): void {
FILE: src/xml/ExtElement.php
class ExtElement (line 13) | class ExtElement extends ManifestElement {
method getName (line 14) | public function getName(): string {
FILE: src/xml/ExtElementCollection.php
class ExtElementCollection (line 13) | class ExtElementCollection extends ElementCollection {
method current (line 14) | public function current(): ExtElement {
FILE: src/xml/ExtensionElement.php
class ExtensionElement (line 13) | class ExtensionElement extends ManifestElement {
method getFor (line 14) | public function getFor(): string {
method getCompatible (line 18) | public function getCompatible(): string {
FILE: src/xml/LicenseElement.php
class LicenseElement (line 13) | class LicenseElement extends ManifestElement {
method getType (line 14) | public function getType(): string {
method getUrl (line 18) | public function getUrl(): string {
FILE: src/xml/ManifestDocument.php
class ManifestDocument (line 24) | class ManifestDocument {
method fromFile (line 30) | public static function fromFile(string $filename): ManifestDocument {
method fromString (line 42) | public static function fromString(string $xmlString): ManifestDocument {
method __construct (line 62) | private function __construct(DOMDocument $dom) {
method getContainsElement (line 68) | public function getContainsElement(): ContainsElement {
method getCopyrightElement (line 74) | public function getCopyrightElement(): CopyrightElement {
method getRequiresElement (line 80) | public function getRequiresElement(): RequiresElement {
method hasBundlesElement (line 86) | public function hasBundlesElement(): bool {
method getBundlesElement (line 90) | public function getBundlesElement(): BundlesElement {
method ensureCorrectDocumentType (line 96) | private function ensureCorrectDocumentType(DOMDocument $dom): void {
method fetchElementByName (line 104) | private function fetchElementByName(string $elementName): DOMElement {
FILE: src/xml/ManifestElement.php
class ManifestElement (line 17) | class ManifestElement {
method __construct (line 23) | public function __construct(DOMElement $element) {
method getAttributeValue (line 27) | protected function getAttributeValue(string $name): string {
method hasAttribute (line 41) | protected function hasAttribute(string $name): bool {
method getChildByName (line 45) | protected function getChildByName(string $elementName): DOMElement {
method getChildrenByName (line 57) | protected function getChildrenByName(string $elementName): DOMNodeList {
method hasChild (line 69) | protected function hasChild(string $elementName): bool {
FILE: src/xml/PhpElement.php
class PhpElement (line 13) | class PhpElement extends ManifestElement {
method getVersion (line 14) | public function getVersion(): string {
method hasExtElements (line 18) | public function hasExtElements(): bool {
method getExtElements (line 22) | public function getExtElements(): ExtElementCollection {
FILE: src/xml/RequiresElement.php
class RequiresElement (line 13) | class RequiresElement extends ManifestElement {
method getPHPElement (line 14) | public function getPHPElement(): PhpElement {
FILE: tests/ManifestDocumentMapperTest.php
class ManifestDocumentMapperTest (line 53) | class ManifestDocumentMapperTest extends \PHPUnit\Framework\TestCase {
method testCanSerializeToString (line 63) | public function testCanSerializeToString($expected): void {
method dataProvider (line 73) | public function dataProvider() {
method testThrowsExceptionOnUnsupportedType (line 82) | public function testThrowsExceptionOnUnsupportedType(): void {
method testInvalidVersionInformationThrowsException (line 90) | public function testInvalidVersionInformationThrowsException(): void {
method testInvalidVersionConstraintThrowsException (line 98) | public function testInvalidVersionConstraintThrowsException(): void {
method testInvalidCompatibleConstraintThrowsException (line 109) | public function testInvalidCompatibleConstraintThrowsException(): void {
FILE: tests/ManifestLoaderTest.php
class ManifestLoaderTest (line 55) | class ManifestLoaderTest extends \PHPUnit\Framework\TestCase {
method testCanBeLoadedFromFile (line 56) | public function testCanBeLoadedFromFile(): void {
method testCanBeLoadedFromString (line 63) | public function testCanBeLoadedFromString(): void {
method testCanBeLoadedFromPhar (line 72) | public function testCanBeLoadedFromPhar(): void {
method testLoadingNonExistingFileThrowsException (line 79) | public function testLoadingNonExistingFileThrowsException(): void {
method testLoadingInvalidXmlThrowsException (line 87) | public function testLoadingInvalidXmlThrowsException(): void {
FILE: tests/ManifestSerializerTest.php
class ManifestSerializerTest (line 59) | class ManifestSerializerTest extends \PHPUnit\Framework\TestCase {
method testCanSerializeToString (line 68) | public function testCanSerializeToString($expected): void {
method dataProvider (line 79) | public function dataProvider() {
method testCanSerializeToFile (line 91) | public function testCanSerializeToFile(): void {
method testCanHandleUnknownType (line 104) | public function testCanHandleUnknownType(): void {
FILE: tests/exceptions/ManifestDocumentLoadingExceptionTest.php
class ManifestDocumentLoadingExceptionTest (line 18) | class ManifestDocumentLoadingExceptionTest extends \PHPUnit\Framework\Te...
method testXMLErrorsCanBeRetrieved (line 19) | public function testXMLErrorsCanBeRetrieved(): void {
FILE: tests/values/ApplicationNameTest.php
class ApplicationNameTest (line 15) | class ApplicationNameTest extends TestCase {
method testCanBeCreatedWithValidName (line 16) | public function testCanBeCreatedWithValidName(): void {
method testUsingInvalidFormatForNameThrowsException (line 23) | public function testUsingInvalidFormatForNameThrowsException(): void {
method testReturnsTrueForEqualNamesWhenCompared (line 29) | public function testReturnsTrueForEqualNamesWhenCompared(): void {
method testReturnsFalseForNonEqualNamesWhenCompared (line 36) | public function testReturnsFalseForNonEqualNamesWhenCompared(): void {
method testCanBeConvertedToString (line 44) | public function testCanBeConvertedToString(): void {
FILE: tests/values/ApplicationTest.php
class ApplicationTest (line 19) | class ApplicationTest extends TestCase {
method setUp (line 23) | protected function setUp(): void {
method testCanBeCreated (line 27) | public function testCanBeCreated(): void {
method testIsApplication (line 31) | public function testIsApplication(): void {
method testIsNotLibrary (line 35) | public function testIsNotLibrary(): void {
method testIsNotExtension (line 39) | public function testIsNotExtension(): void {
FILE: tests/values/AuthorCollectionTest.php
class AuthorCollectionTest (line 22) | class AuthorCollectionTest extends TestCase {
method setUp (line 29) | protected function setUp(): void {
method testCanBeCreated (line 34) | public function testCanBeCreated(): void {
method testCanBeCounted (line 38) | public function testCanBeCounted(): void {
method testCanBeIterated (line 44) | public function testCanBeIterated(): void {
method testKeyPositionCanBeRetrieved (line 52) | public function testKeyPositionCanBeRetrieved(): void {
FILE: tests/values/AuthorTest.php
class AuthorTest (line 20) | class AuthorTest extends TestCase {
method setUp (line 24) | protected function setUp(): void {
method testCanBeCreated (line 28) | public function testCanBeCreated(): void {
method testNameCanBeRetrieved (line 32) | public function testNameCanBeRetrieved(): void {
method testEmailCanBeRetrieved (line 36) | public function testEmailCanBeRetrieved(): void {
method testCanBeUsedAsString (line 41) | public function testCanBeUsedAsString(): void {
method testCanBeCreatedWithoutEmail (line 45) | public function testCanBeCreatedWithoutEmail(): void {
method testHasEmailReturnsTrueWhenEMailIsSet (line 49) | public function testHasEmailReturnsTrueWhenEMailIsSet(): void {
method testHasEmailReturnsFalseOnMissingEMail (line 53) | public function testHasEmailReturnsFalseOnMissingEMail(): void {
method testThrowsExceptionWhenMissingEmailAddressIsQueried (line 57) | public function testThrowsExceptionWhenMissingEmailAddressIsQueried():...
FILE: tests/values/BundledComponentCollectionTest.php
class BundledComponentCollectionTest (line 23) | class BundledComponentCollectionTest extends TestCase {
method setUp (line 30) | protected function setUp(): void {
method testCanBeCreated (line 35) | public function testCanBeCreated(): void {
method testCanBeCounted (line 39) | public function testCanBeCounted(): void {
method testCanBeIterated (line 45) | public function testCanBeIterated(): void {
method testKeyPositionCanBeRetrieved (line 52) | public function testKeyPositionCanBeRetrieved(): void {
FILE: tests/values/BundledComponentTest.php
class BundledComponentTest (line 21) | class BundledComponentTest extends TestCase {
method setUp (line 25) | protected function setUp(): void {
method testCanBeCreated (line 29) | public function testCanBeCreated(): void {
method testNameCanBeRetrieved (line 33) | public function testNameCanBeRetrieved(): void {
method testVersionCanBeRetrieved (line 37) | public function testVersionCanBeRetrieved(): void {
FILE: tests/values/CopyrightInformationTest.php
class CopyrightInformationTest (line 25) | class CopyrightInformationTest extends TestCase {
method setUp (line 35) | protected function setUp(): void {
method testCanBeCreated (line 45) | public function testCanBeCreated(): void {
method testAuthorsCanBeRetrieved (line 49) | public function testAuthorsCanBeRetrieved(): void {
method testLicenseCanBeRetrieved (line 53) | public function testLicenseCanBeRetrieved(): void {
FILE: tests/values/EmailTest.php
class EmailTest (line 18) | class EmailTest extends TestCase {
method testCanBeCreatedForValidEmail (line 19) | public function testCanBeCreatedForValidEmail(): void {
method testCanBeRequestedAsString (line 23) | public function testCanBeRequestedAsString(): void {
method testCannotBeCreatedForInvalidEmail (line 30) | public function testCannotBeCreatedForInvalidEmail(): void {
FILE: tests/values/ExtensionTest.php
class ExtensionTest (line 27) | class ExtensionTest extends TestCase {
method setUp (line 34) | protected function setUp(): void {
method testCanBeCreated (line 39) | public function testCanBeCreated(): void {
method testIsNotApplication (line 43) | public function testIsNotApplication(): void {
method testIsNotLibrary (line 47) | public function testIsNotLibrary(): void {
method testIsExtension (line 51) | public function testIsExtension(): void {
method testApplicationCanBeRetrieved (line 55) | public function testApplicationCanBeRetrieved(): void {
method testVersionConstraintCanBeRetrieved (line 59) | public function testVersionConstraintCanBeRetrieved(): void {
method testApplicationCanBeQueried (line 66) | public function testApplicationCanBeQueried(): void {
method testCompatibleWithReturnsTrueForMatchingVersionConstraintAndApplication (line 73) | public function testCompatibleWithReturnsTrueForMatchingVersionConstra...
method testCompatibleWithReturnsFalseForNotMatchingVersionConstraint (line 83) | public function testCompatibleWithReturnsFalseForNotMatchingVersionCon...
method testCompatibleWithReturnsFalseForNotMatchingApplication (line 93) | public function testCompatibleWithReturnsFalseForNotMatchingApplicatio...
FILE: tests/values/LibraryTest.php
class LibraryTest (line 19) | class LibraryTest extends TestCase {
method setUp (line 23) | protected function setUp(): void {
method testCanBeCreated (line 27) | public function testCanBeCreated(): void {
method testIsNotApplication (line 31) | public function testIsNotApplication(): void {
method testIsLibrary (line 35) | public function testIsLibrary(): void {
method testIsNotExtension (line 39) | public function testIsNotExtension(): void {
FILE: tests/values/LicenseTest.php
class LicenseTest (line 20) | class LicenseTest extends TestCase {
method setUp (line 24) | protected function setUp(): void {
method testCanBeCreated (line 28) | public function testCanBeCreated(): void {
method testNameCanBeRetrieved (line 32) | public function testNameCanBeRetrieved(): void {
method testUrlCanBeRetrieved (line 36) | public function testUrlCanBeRetrieved(): void {
FILE: tests/values/ManifestTest.php
class ManifestTest (line 36) | class ManifestTest extends TestCase {
method setUp (line 58) | protected function setUp(): void {
method testCanBeCreated (line 89) | public function testCanBeCreated(): void {
method testNameCanBeRetrieved (line 93) | public function testNameCanBeRetrieved(): void {
method testVersionCanBeRetrieved (line 97) | public function testVersionCanBeRetrieved(): void {
method testTypeCanBeRetrieved (line 101) | public function testTypeCanBeRetrieved(): void {
method testTypeCanBeQueried (line 105) | public function testTypeCanBeQueried(): void {
method testCopyrightInformationCanBeRetrieved (line 111) | public function testCopyrightInformationCanBeRetrieved(): void {
method testRequirementsCanBeRetrieved (line 115) | public function testRequirementsCanBeRetrieved(): void {
method testBundledComponentsCanBeRetrieved (line 119) | public function testBundledComponentsCanBeRetrieved(): void {
method testExtendedApplicationCanBeQueriedForExtension (line 126) | public function testExtendedApplicationCanBeQueriedForExtension(): void {
method testNonExtensionReturnsFalseWhenQueriesForExtension (line 140) | public function testNonExtensionReturnsFalseWhenQueriesForExtension():...
method testExtendedApplicationCanBeQueriedForExtensionWithVersion (line 157) | public function testExtendedApplicationCanBeQueriedForExtensionWithVer...
FILE: tests/values/PhpExtensionRequirementTest.php
class PhpExtensionRequirementTest (line 18) | class PhpExtensionRequirementTest extends TestCase {
method testCanBeCreated (line 19) | public function testCanBeCreated(): void {
method testCanBeConvertedToString (line 23) | public function testCanBeConvertedToString(): void {
FILE: tests/values/PhpVersionRequirementTest.php
class PhpVersionRequirementTest (line 21) | class PhpVersionRequirementTest extends TestCase {
method setUp (line 25) | protected function setUp(): void {
method testCanBeCreated (line 29) | public function testCanBeCreated(): void {
method testVersionConstraintCanBeRetrieved (line 33) | public function testVersionConstraintCanBeRetrieved(): void {
FILE: tests/values/RequirementCollectionTest.php
class RequirementCollectionTest (line 23) | class RequirementCollectionTest extends TestCase {
method setUp (line 30) | protected function setUp(): void {
method testCanBeCreated (line 35) | public function testCanBeCreated(): void {
method testCanBeCounted (line 39) | public function testCanBeCounted(): void {
method testCanBeIterated (line 45) | public function testCanBeIterated(): void {
method testKeyPositionCanBeRetrieved (line 52) | public function testKeyPositionCanBeRetrieved(): void {
FILE: tests/values/UrlTest.php
class UrlTest (line 18) | class UrlTest extends TestCase {
method testCanBeCreatedForValidUrl (line 19) | public function testCanBeCreatedForValidUrl(): void {
method testCanBeConvertedToString (line 23) | public function testCanBeConvertedToString(): void {
method testCannotBeCreatedForInvalidUrl (line 30) | public function testCannotBeCreatedForInvalidUrl(): void {
FILE: tests/xml/AuthorElementCollectionTest.php
class AuthorElementCollectionTest (line 15) | class AuthorElementCollectionTest extends \PHPUnit\Framework\TestCase {
method testAuthorElementCanBeRetrievedFromCollection (line 16) | public function testAuthorElementCanBeRetrievedFromCollection(): void {
FILE: tests/xml/AuthorElementTest.php
class AuthorElementTest (line 15) | class AuthorElementTest extends \PHPUnit\Framework\TestCase {
method setUp (line 19) | protected function setUp(): void {
method testNameCanBeRetrieved (line 25) | public function testNameCanBeRetrieved(): void {
method testEmailCanBeRetrieved (line 29) | public function testEmailCanBeRetrieved(): void {
method testHasEmailReturnsTrueWhenEMailIsSet (line 33) | public function testHasEmailReturnsTrueWhenEMailIsSet(): void {
method testHasEMailReturnsFalseWhenNoEMailAddressIsSet (line 37) | public function testHasEMailReturnsFalseWhenNoEMailAddressIsSet(): void {
FILE: tests/xml/BundlesElementTest.php
class BundlesElementTest (line 15) | class BundlesElementTest extends \PHPUnit\Framework\TestCase {
method setUp (line 22) | protected function setUp(): void {
method testThrowsExceptionWhenGetComponentElementsIsCalledButNodesAreMissing (line 28) | public function testThrowsExceptionWhenGetComponentElementsIsCalledBut...
method testGetComponentElementsReturnsComponentElementCollection (line 33) | public function testGetComponentElementsReturnsComponentElementCollect...
method addComponent (line 41) | private function addComponent(): void {
FILE: tests/xml/ComponentElementCollectionTest.php
class ComponentElementCollectionTest (line 15) | class ComponentElementCollectionTest extends \PHPUnit\Framework\TestCase {
method testComponentElementCanBeRetrievedFromCollection (line 16) | public function testComponentElementCanBeRetrievedFromCollection(): vo...
FILE: tests/xml/ComponentElementTest.php
class ComponentElementTest (line 15) | class ComponentElementTest extends \PHPUnit\Framework\TestCase {
method setUp (line 19) | protected function setUp(): void {
method testNameCanBeRetrieved (line 25) | public function testNameCanBeRetrieved(): void {
method testEmailCanBeRetrieved (line 29) | public function testEmailCanBeRetrieved(): void {
FILE: tests/xml/ContainsElementTest.php
class ContainsElementTest (line 16) | class ContainsElementTest extends \PHPUnit\Framework\TestCase {
method setUp (line 23) | protected function setUp(): void {
method testVersionCanBeRetrieved (line 30) | public function testVersionCanBeRetrieved(): void {
method testThrowsExceptionWhenVersionAttributeIsMissing (line 34) | public function testThrowsExceptionWhenVersionAttributeIsMissing(): vo...
method testNameCanBeRetrieved (line 40) | public function testNameCanBeRetrieved(): void {
method testThrowsExceptionWhenNameAttributeIsMissing (line 44) | public function testThrowsExceptionWhenNameAttributeIsMissing(): void {
method testTypeCanBeRetrieved (line 50) | public function testTypeCanBeRetrieved(): void {
method testThrowsExceptionWhenTypeAttributeIsMissing (line 54) | public function testThrowsExceptionWhenTypeAttributeIsMissing(): void {
method testGetExtensionElementReturnsExtensionElement (line 60) | public function testGetExtensionElementReturnsExtensionElement(): void {
FILE: tests/xml/CopyrightElementTest.php
class CopyrightElementTest (line 15) | class CopyrightElementTest extends \PHPUnit\Framework\TestCase {
method setUp (line 22) | protected function setUp(): void {
method testThrowsExceptionWhenGetAuthroElementsIsCalledButNodesAreMissing (line 28) | public function testThrowsExceptionWhenGetAuthroElementsIsCalledButNod...
method testThrowsExceptionWhenGetLicenseElementIsCalledButNodeIsMissing (line 33) | public function testThrowsExceptionWhenGetLicenseElementIsCalledButNod...
method testGetAuthorElementsReturnsAuthorElementCollection (line 38) | public function testGetAuthorElementsReturnsAuthorElementCollection():...
method testGetLicenseElementReturnsLicenseElement (line 48) | public function testGetLicenseElementReturnsLicenseElement(): void {
FILE: tests/xml/ElementCollectionTest.php
class ElementCollectionTest (line 16) | class ElementCollectionTest extends TestCase {
method testEnforcesDOMElementsOnly (line 17) | public function testEnforcesDOMElementsOnly(): void {
FILE: tests/xml/ExtElementCollectionTest.php
class ExtElementCollectionTest (line 15) | class ExtElementCollectionTest extends \PHPUnit\Framework\TestCase {
method testComponentElementCanBeRetrievedFromCollection (line 16) | public function testComponentElementCanBeRetrievedFromCollection(): vo...
FILE: tests/xml/ExtElementTest.php
class ExtElementTest (line 15) | class ExtElementTest extends \PHPUnit\Framework\TestCase {
method setUp (line 19) | protected function setUp(): void {
method testNameCanBeRetrieved (line 25) | public function testNameCanBeRetrieved(): void {
FILE: tests/xml/ExtensionElementTest.php
class ExtensionElementTest (line 15) | class ExtensionElementTest extends \PHPUnit\Framework\TestCase {
method setUp (line 19) | protected function setUp(): void {
method testNForCanBeRetrieved (line 25) | public function testNForCanBeRetrieved(): void {
method testCompatibleVersionConstraintCanBeRetrieved (line 29) | public function testCompatibleVersionConstraintCanBeRetrieved(): void {
FILE: tests/xml/LicenseElementTest.php
class LicenseElementTest (line 15) | class LicenseElementTest extends \PHPUnit\Framework\TestCase {
method setUp (line 19) | protected function setUp(): void {
method testTypeCanBeRetrieved (line 25) | public function testTypeCanBeRetrieved(): void {
method testUrlCanBeRetrieved (line 29) | public function testUrlCanBeRetrieved(): void {
FILE: tests/xml/ManifestDocumentTest.php
class ManifestDocumentTest (line 15) | class ManifestDocumentTest extends \PHPUnit\Framework\TestCase {
method testThrowsExceptionWhenFileDoesNotExist (line 16) | public function testThrowsExceptionWhenFileDoesNotExist(): void {
method testCanBeCreatedFromFile (line 21) | public function testCanBeCreatedFromFile(): void {
method testFromStringThrowsExceptionOnEmptyString (line 28) | public function testFromStringThrowsExceptionOnEmptyString(): void {
method testCanBeConstructedFromString (line 33) | public function testCanBeConstructedFromString(): void {
method testThrowsExceptionOnInvalidXML (line 41) | public function testThrowsExceptionOnInvalidXML(): void {
method testLoadingDocumentWithWrongRootNameThrowsException (line 46) | public function testLoadingDocumentWithWrongRootNameThrowsException():...
method testLoadingDocumentWithWrongNamespaceThrowsException (line 51) | public function testLoadingDocumentWithWrongNamespaceThrowsException()...
method testContainsElementCanBeRetrieved (line 56) | public function testContainsElementCanBeRetrieved(): void {
method testRequiresElementCanBeRetrieved (line 63) | public function testRequiresElementCanBeRetrieved(): void {
method testCopyrightElementCanBeRetrieved (line 70) | public function testCopyrightElementCanBeRetrieved(): void {
method testBundlesElementCanBeRetrieved (line 77) | public function testBundlesElementCanBeRetrieved(): void {
method testThrowsExceptionWhenContainsIsMissing (line 84) | public function testThrowsExceptionWhenContainsIsMissing(): void {
method testThrowsExceptionWhenCopyirhgtIsMissing (line 89) | public function testThrowsExceptionWhenCopyirhgtIsMissing(): void {
method testThrowsExceptionWhenRequiresIsMissing (line 94) | public function testThrowsExceptionWhenRequiresIsMissing(): void {
method testThrowsExceptionWhenBundlesIsMissing (line 99) | public function testThrowsExceptionWhenBundlesIsMissing(): void {
method testHasBundlesReturnsTrueWhenBundlesNodeIsPresent (line 104) | public function testHasBundlesReturnsTrueWhenBundlesNodeIsPresent(): v...
method testHasBundlesReturnsFalseWhenBundlesNoNodeIsPresent (line 110) | public function testHasBundlesReturnsFalseWhenBundlesNoNodeIsPresent()...
method loadFixture (line 116) | private function loadFixture() {
method loadEmptyFixture (line 120) | private function loadEmptyFixture() {
FILE: tests/xml/PhpElementTest.php
class PhpElementTest (line 15) | class PhpElementTest extends \PHPUnit\Framework\TestCase {
method setUp (line 22) | protected function setUp(): void {
method testVersionConstraintCanBeRetrieved (line 28) | public function testVersionConstraintCanBeRetrieved(): void {
method testHasExtElementsReturnsFalseWhenNoExtensionsAreRequired (line 32) | public function testHasExtElementsReturnsFalseWhenNoExtensionsAreRequi...
method testHasExtElementsReturnsTrueWhenExtensionsAreRequired (line 36) | public function testHasExtElementsReturnsTrueWhenExtensionsAreRequired...
method testGetExtElementsReturnsExtElementCollection (line 41) | public function testGetExtElementsReturnsExtElementCollection(): void {
method addExtElement (line 46) | private function addExtElement(): void {
FILE: tests/xml/RequiresElementTest.php
class RequiresElementTest (line 15) | class RequiresElementTest extends \PHPUnit\Framework\TestCase {
method setUp (line 22) | protected function setUp(): void {
method testThrowsExceptionWhenGetPhpElementIsCalledButElementIsMissing (line 28) | public function testThrowsExceptionWhenGetPhpElementIsCalledButElement...
method testHasExtElementsReturnsTrueWhenExtensionsAreRequired (line 33) | public function testHasExtElementsReturnsTrueWhenExtensionsAreRequired...
Condensed preview — 112 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (177K chars).
[
{
"path": ".gitattributes",
"chars": 396,
"preview": "/.github export-ignore\n/build export-ignore\n/examples export-ignore\n/tests ex"
},
{
"path": ".github/FUNDING.yml",
"chars": 65,
"preview": "# These are supported funding model platforms\n\ngithub: [theseer]\n"
},
{
"path": ".github/workflows/ci.yml",
"chars": 2072,
"preview": "name: \"CI\"\n\non:\n push:\n branches:\n - \"master\"\n pull_request: null\n\njobs:\n qa:\n name: \"QA\"\n\n runs-on: \"u"
},
{
"path": ".gitignore",
"chars": 105,
"preview": "/.idea\n/.php_cs.cache\n/src/autoload.php\n/tools\n/vendor\n\n/build\n.phpunit.result.cache\n.php-cs-fixer.cache\n"
},
{
"path": ".php-cs-fixer.dist.php",
"chars": 12145,
"preview": "<?php\n\nrequire __DIR__ . '/tools/php-cs-fixer.d/PhpdocSingleLineVarFixer.php';\n\n$header = file_get_contents(__DIR__ . '/"
},
{
"path": "CHANGELOG.md",
"chars": 1513,
"preview": "# Changelog\n\nAll notable changes to phar-io/manifest are documented in this file using the [Keep a CHANGELOG](http://kee"
},
{
"path": "LICENSE",
"chars": 1632,
"preview": "Phar.io - Manifest\n\nCopyright (c) 2016-2019 Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>,"
},
{
"path": "README.md",
"chars": 5759,
"preview": "# Manifest\n\nComponent for reading [phar.io](https://phar.io/) manifest information from a [PHP Archive (PHAR)](http://ph"
},
{
"path": "build.xml",
"chars": 3801,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project name=\"manifest\" default=\"setup\">\n <property name=\"phive.bin\" value=\"p"
},
{
"path": "composer.json",
"chars": 897,
"preview": "{\n \"name\": \"phar-io/manifest\",\n \"description\": \"Component for reading phar.io manifest information from a PHP Archive "
},
{
"path": "examples/example-01.php",
"chars": 724,
"preview": "<?php\n/*\n * This file is part of PharIo\\Manifest.\n *\n * (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebasti"
},
{
"path": "examples/example-02.php",
"chars": 1469,
"preview": "<?php declare(strict_types = 1);\n/**\n * Thanks to @llaville for this example\n */\nuse PharIo\\Manifest\\ManifestSerializer;"
},
{
"path": "manifest.xsd",
"chars": 3708,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xs:schema attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" targ"
},
{
"path": "phive.xml",
"chars": 489,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phive xmlns=\"https://phar.io/phive\">\n <phar name=\"php-cs-fixer\" version=\"^3.17."
},
{
"path": "phpunit.xml",
"chars": 654,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSch"
},
{
"path": "psalm.xml",
"chars": 614,
"preview": "<?xml version=\"1.0\"?>\n<psalm xmlns=\"https://getpsalm.org/schema/config\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-inst"
},
{
"path": "src/ManifestDocumentMapper.php",
"chars": 4992,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/ManifestLoader.php",
"chars": 1440,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/ManifestSerializer.php",
"chars": 6023,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/exceptions/ElementCollectionException.php",
"chars": 520,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/exceptions/Exception.php",
"chars": 456,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/exceptions/InvalidApplicationNameException.php",
"chars": 561,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/exceptions/InvalidEmailException.php",
"chars": 515,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/exceptions/InvalidUrlException.php",
"chars": 513,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/exceptions/ManifestDocumentException.php",
"chars": 503,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/exceptions/ManifestDocumentLoadingException.php",
"chars": 1275,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/exceptions/ManifestDocumentMapperException.php",
"chars": 509,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/exceptions/ManifestElementException.php",
"chars": 502,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/exceptions/ManifestLoaderException.php",
"chars": 472,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/exceptions/NoEmailAddressException.php",
"chars": 517,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/Application.php",
"chars": 504,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/ApplicationName.php",
"chars": 1180,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/Author.php",
"chars": 1304,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/AuthorCollection.php",
"chars": 1046,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/AuthorCollectionIterator.php",
"chars": 1157,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/BundledComponent.php",
"chars": 840,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/BundledComponentCollection.php",
"chars": 1186,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/BundledComponentCollectionIterator.php",
"chars": 1277,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/CopyrightInformation.php",
"chars": 860,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/Email.php",
"chars": 912,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/Extension.php",
"chars": 1430,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/Library.php",
"chars": 496,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/License.php",
"chars": 764,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/Manifest.php",
"chars": 2605,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/PhpExtensionRequirement.php",
"chars": 682,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/PhpVersionRequirement.php",
"chars": 804,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/Requirement.php",
"chars": 424,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/RequirementCollection.php",
"chars": 1116,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/RequirementCollectionIterator.php",
"chars": 1217,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/Type.php",
"chars": 1187,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/values/Url.php",
"chars": 939,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/AuthorElement.php",
"chars": 730,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/AuthorElementCollection.php",
"chars": 595,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/BundlesElement.php",
"chars": 634,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/ComponentElement.php",
"chars": 646,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/ComponentElementCollection.php",
"chars": 604,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/ContainsElement.php",
"chars": 905,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/CopyrightElement.php",
"chars": 780,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/ElementCollection.php",
"chars": 1739,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/ExtElement.php",
"chars": 538,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/ExtElementCollection.php",
"chars": 586,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/ExtensionElement.php",
"chars": 650,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/LicenseElement.php",
"chars": 636,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/ManifestDocument.php",
"chars": 3340,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/ManifestElement.php",
"chars": 2158,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/PhpElement.php",
"chars": 799,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "src/xml/RequiresElement.php",
"chars": 587,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/ManifestDocumentMapperTest.php",
"chars": 4540,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/ManifestLoaderTest.php",
"chars": 3247,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/ManifestSerializerTest.php",
"chars": 4403,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/_fixture/custom.xml",
"chars": 314,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phar xmlns=\"https://phar.io/xml/manifest/1.0\">\n <contains name=\"testvendor/te"
},
{
"path": "tests/_fixture/extension-invalidcompatible.xml",
"chars": 559,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phar xmlns=\"https://phar.io/xml/manifest/1.0\">\n <contains name=\"phpunit/phpun"
},
{
"path": "tests/_fixture/extension.xml",
"chars": 556,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phar xmlns=\"https://phar.io/xml/manifest/1.0\">\n <contains name=\"phpunit/phpun"
},
{
"path": "tests/_fixture/invalidversion.xml",
"chars": 390,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phar xmlns=\"https://phar.io/xml/manifest/1.0\">\n <contains name=\"some/library\""
},
{
"path": "tests/_fixture/invalidversionconstraint.xml",
"chars": 396,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phar xmlns=\"https://phar.io/xml/manifest/1.0\">\n <contains name=\"some/library\""
},
{
"path": "tests/_fixture/library.xml",
"chars": 392,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phar xmlns=\"https://phar.io/xml/manifest/1.0\">\n <contains name=\"some/library\""
},
{
"path": "tests/_fixture/manifest.xml",
"chars": 392,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phar xmlns=\"https://phar.io/xml/manifest/1.0\">\n <contains name=\"some/library\""
},
{
"path": "tests/_fixture/noemailauthor.xml",
"chars": 368,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phar xmlns=\"https://phar.io/xml/manifest/1.0\">\n <contains name=\"some/library\""
},
{
"path": "tests/_fixture/phpunit-5.6.5.xml",
"chars": 2461,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phar xmlns=\"https://phar.io/xml/manifest/1.0\">\n <contains name=\"phpunit/phpun"
},
{
"path": "tests/exceptions/ManifestDocumentLoadingExceptionTest.php",
"chars": 1016,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/ApplicationNameTest.php",
"chars": 1571,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/ApplicationTest.php",
"chars": 1141,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/AuthorCollectionTest.php",
"chars": 1715,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/AuthorTest.php",
"chars": 1941,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/BundledComponentCollectionTest.php",
"chars": 1801,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/BundledComponentTest.php",
"chars": 1263,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/CopyrightInformationTest.php",
"chars": 1804,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/EmailTest.php",
"chars": 1047,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/ExtensionTest.php",
"chars": 3421,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/LibraryTest.php",
"chars": 1121,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/LicenseTest.php",
"chars": 1247,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/ManifestTest.php",
"chars": 5630,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/PhpExtensionRequirementTest.php",
"chars": 849,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/PhpVersionRequirementTest.php",
"chars": 1137,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/RequirementCollectionTest.php",
"chars": 1807,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/values/UrlTest.php",
"chars": 1025,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/AuthorElementCollectionTest.php",
"chars": 957,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/AuthorElementTest.php",
"chars": 1546,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/BundlesElementTest.php",
"chars": 1538,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/ComponentElementCollectionTest.php",
"chars": 932,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/ComponentElementTest.php",
"chars": 1098,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/ContainsElementTest.php",
"chars": 2421,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/CopyrightElementTest.php",
"chars": 2021,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/ElementCollectionTest.php",
"chars": 881,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/ExtElementCollectionTest.php",
"chars": 956,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/ExtElementTest.php",
"chars": 889,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/ExtensionElementTest.php",
"chars": 1122,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/LicenseElementTest.php",
"chars": 1094,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/ManifestDocumentTest.php",
"chars": 4391,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/PhpElementTest.php",
"chars": 1728,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
},
{
"path": "tests/xml/RequiresElementTest.php",
"chars": 1385,
"preview": "<?php declare(strict_types = 1);\n/*\n * This file is part of PharIo\\Manifest.\n *\n * Copyright (c) Arne Blankerts <arne@bl"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the phar-io/manifest GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 112 files (159.4 KB), approximately 41.2k tokens, and a symbol index with 403 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.