Initial commit: apps.prometeysev.ru

This commit is contained in:
root committed 2026-10-22 00:22:57 +03:00
commit 96ccabcd8b
6561 files changed
+1270349

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
<?php
$header = <<<EOF
This file is part of composer/spdx-licenses.
(c) Composer <https://github.com/composer>
For the full copyright and license information, please view
the LICENSE file that was distributed with this source code.
EOF;
$finder = PhpCsFixer\Finder::create()
->files()
->name('*.php')
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
;
/* fabpot/php-cs-fixer:^2.0-dev */
return PhpCsFixer\Config::create()
->setUsingCache(true)
//->setUsingLinter(false)
->setRiskyAllowed(true)
->setRules(array(
'@PSR2' => true,
'binary_operator_spaces' => true,
'blank_line_before_return' => true,
'cast_spaces' => true,
'header_comment' => array('header' => $header),
'include' => true,
'long_array_syntax' => true,
'method_separation' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_between_uses' => true,
'no_duplicate_semicolons' => true,
'no_extra_consecutive_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unused_imports' => true,
'no_whitespace_in_blank_lines' => true,
'object_operator_without_whitespace' => true,
'phpdoc_align' => true,
'phpdoc_indent' => true,
'phpdoc_no_access' => true,
'phpdoc_no_package' => true,
'phpdoc_order' => true,
'phpdoc_scalar' => true,
'phpdoc_trim' => true,
'phpdoc_type_to_var' => true,
'psr0' => true,
'single_blank_line_before_namespace' => true,
'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
))
->finder($finder)
;
+94
View File
@@ -0,0 +1,94 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [master]
...
## [1.5.2] 2019-07-29
* Changed: updated licenses list to SPDX 3.6
## [1.5.1] 2019-03-26
* Changed: updated licenses list to SPDX 3.4
## [1.5.0] 2018-11-01
* Changed: updated licenses list to SPDX 3.3
## [1.4.0] 2018-05-04
* Changed: updated licenses list to SPDX 3.1
## [1.3.0] 2018-01-31
* Added: `SpdxLicenses::getLicenses` to get the whole list of methods.
* Changed: license identifiers are now case insensitive.
## [1.2.0] 2018-01-03
* Added: deprecation status for all licenses and a `SpdxLicenses::isDeprecatedByIdentifier` method.
* Changed: updated licenses list to SPDX 3.0.
## [1.1.6] 2017-04-03
* Changed: updated licenses list.
## [1.1.5] 2016-09-28
* Changed: updated licenses list.
## [1.1.4] 2016-05-04
* Changed: updated licenses list.
## [1.1.3] 2016-03-25
* Changed: updated licenses list.
* Changed: dropped `test` namespace.
* Changed: tedious small things.
## [1.1.2] 2015-10-05
* Changed: updated licenses list.
## [1.1.1] 2015-09-07
* Changed: improved performance when looking up just one license.
* Changed: updated licenses list.
## [1.1.0] 2015-07-17
* Changed: updater now sorts licenses and exceptions by key.
* Changed: filenames now class constants of SpdxLicenses (`LICENSES_FILE` and `EXCEPTIONS_FILE`).
* Changed: resources directory now available via static method `SpdxLicenses::getResourcesDir()`.
* Changed: updated licenses list.
* Changed: removed json-schema requirement.
## [1.0.0] 2015-07-15
* Break: the following classes and namespaces were renamed:
- Namespace: `Composer\Util` -> `Composer\Spdx`
- Classname: `SpdxLicense` -> `SpdxLicenses`
- Classname: `SpdxLicenseTest` -> `SpdxLicensesTest`
- Classname: `Updater` -> `SpdxLicensesUpdater`
* Changed: validation via regex implementation instead of lexer.
[master]: https://github.com/composer/spdx-licenses/compare/1.5.2...master
[1.5.2]: https://github.com/composer/spdx-licenses/compare/1.5.1...1.5.2
[1.5.1]: https://github.com/composer/spdx-licenses/compare/1.5.0...1.5.1
[1.5.0]: https://github.com/composer/spdx-licenses/compare/1.4.0...1.5.0
[1.4.0]: https://github.com/composer/spdx-licenses/compare/1.3.0...1.4.0
[1.3.0]: https://github.com/composer/spdx-licenses/compare/1.2.0...1.3.0
[1.2.0]: https://github.com/composer/spdx-licenses/compare/1.1.6...1.2.0
[1.1.6]: https://github.com/composer/spdx-licenses/compare/1.1.5...1.1.6
[1.1.5]: https://github.com/composer/spdx-licenses/compare/1.1.4...1.1.5
[1.1.4]: https://github.com/composer/spdx-licenses/compare/1.1.3...1.1.4
[1.1.3]: https://github.com/composer/spdx-licenses/compare/1.1.2...1.1.3
[1.1.2]: https://github.com/composer/spdx-licenses/compare/1.1.1...1.1.2
[1.1.1]: https://github.com/composer/spdx-licenses/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/composer/spdx-licenses/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/composer/spdx-licenses/compare/0281a7fe7820c990db3058844e7d448d7b70e3ac...1.0.0
+19
View File
@@ -0,0 +1,19 @@
Copyright (C) 2015 Composer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+69
View File
@@ -0,0 +1,69 @@
composer/spdx-licenses
======================
SPDX (Software Package Data Exchange) licenses list and validation library.
Originally written as part of [composer/composer](https://github.com/composer/composer),
now extracted and made available as a stand-alone library.
[![Build Status](https://travis-ci.org/composer/spdx-licenses.svg?branch=master)](https://travis-ci.org/composer/spdx-licenses)
Installation
------------
Install the latest version with:
```bash
$ composer require composer/spdx-licenses
```
Basic Usage
-----------
```php
<?php
use Composer\Spdx\SpdxLicenses;
$licenses = new SpdxLicenses();
// get a license by identifier
$licenses->getLicenseByIdentifier('MIT');
// get a license exception by identifier
$licenses->getExceptionByIdentifier('Autoconf-exception-3.0');
// get a license identifier by name
$licenses->getIdentifierByName('MIT License');
// check if a license is OSI approved by identifier
$licenses->isOsiApprovedByIdentifier('MIT');
// check if a license identifier is deprecated
$licenses->isDeprecatedByIdentifier('MIT');
// check if input is a valid SPDX license expression
$licenses->validate($input);
```
> Read the [specifications](https://spdx.org/specifications)
> to find out more about valid license expressions.
Requirements
------------
* PHP 5.3.2 is required but using the latest version of PHP is highly recommended.
License
-------
composer/spdx-licenses is licensed under the MIT License, see the LICENSE file for details.
Source
------
License information is curated by [SPDX](https://spdx.org/). The data is pulled from the
[License List Data](https://github.com/spdx/license-list-data) repository.
* [Licenses](https://spdx.org/licenses/index.html)
* [License Exceptions](https://spdx.org/licenses/exceptions-index.html)
+56
View File
@@ -0,0 +1,56 @@
{
"name": "composer/spdx-licenses",
"description": "SPDX licenses list and validation library.",
"type": "library",
"license": "MIT",
"keywords": [
"spdx",
"license",
"validator"
],
"authors": [
{
"name": "Nils Adermann",
"email": "naderman@naderman.de",
"homepage": "http://www.naderman.de"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com",
"homepage": "http://robbast.nl"
}
],
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/spdx-licenses/issues"
},
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 7"
},
"autoload": {
"psr-4": {
"Composer\\Spdx\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Composer\\Spdx\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"scripts": {
"test": "phpunit"
}
}
+110
View File
@@ -0,0 +1,110 @@
{
"389-exception": [
"389 Directory Server Exception"
],
"Autoconf-exception-2.0": [
"Autoconf exception 2.0"
],
"Autoconf-exception-3.0": [
"Autoconf exception 3.0"
],
"Bison-exception-2.2": [
"Bison exception 2.2"
],
"Bootloader-exception": [
"Bootloader Distribution Exception"
],
"Classpath-exception-2.0": [
"Classpath exception 2.0"
],
"CLISP-exception-2.0": [
"CLISP exception 2.0"
],
"DigiRule-FOSS-exception": [
"DigiRule FOSS License Exception"
],
"eCos-exception-2.0": [
"eCos exception 2.0"
],
"Fawkes-Runtime-exception": [
"Fawkes Runtime Exception"
],
"FLTK-exception": [
"FLTK exception"
],
"Font-exception-2.0": [
"Font exception 2.0"
],
"freertos-exception-2.0": [
"FreeRTOS Exception 2.0"
],
"GCC-exception-2.0": [
"GCC Runtime Library exception 2.0"
],
"GCC-exception-3.1": [
"GCC Runtime Library exception 3.1"
],
"gnu-javamail-exception": [
"GNU JavaMail exception"
],
"GPL-CC-1.0": [
"GPL Cooperation Commitment 1.0"
],
"i2p-gpl-java-exception": [
"i2p GPL+Java Exception"
],
"Libtool-exception": [
"Libtool Exception"
],
"Linux-syscall-note": [
"Linux Syscall Note"
],
"LLVM-exception": [
"LLVM Exception"
],
"LZMA-exception": [
"LZMA exception"
],
"mif-exception": [
"Macros and Inline Functions Exception"
],
"Nokia-Qt-exception-1.1": [
"Nokia Qt LGPL exception 1.1"
],
"OCaml-LGPL-linking-exception": [
"OCaml LGPL Linking Exception"
],
"OCCT-exception-1.0": [
"Open CASCADE Exception 1.0"
],
"OpenJDK-assembly-exception-1.0": [
"OpenJDK Assembly exception 1.0"
],
"openvpn-openssl-exception": [
"OpenVPN OpenSSL Exception"
],
"PS-or-PDF-font-exception-20170817": [
"PS/PDF font exception (2017-08-17)"
],
"Qt-GPL-exception-1.0": [
"Qt GPL exception 1.0"
],
"Qt-LGPL-exception-1.1": [
"Qt LGPL exception 1.1"
],
"Qwt-exception-1.0": [
"Qwt exception 1.0"
],
"Swift-exception": [
"Swift Exception"
],
"u-boot-exception-2.0": [
"U-Boot exception 2.0"
],
"Universal-FOSS-exception-1.0": [
"Universal FOSS Exception, Version 1.0"
],
"WxWindows-exception-3.1": [
"WxWindows Library Exception 3.1"
]
}
File diff suppressed because it is too large. Load diff
+343
View File
@@ -0,0 +1,343 @@
<?php
/*
* This file is part of composer/spdx-licenses.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Spdx;
class SpdxLicenses
{
/** @var string */
const LICENSES_FILE = 'spdx-licenses.json';
/** @var string */
const EXCEPTIONS_FILE = 'spdx-exceptions.json';
/**
* Contains all the licenses.
*
* The array is indexed by license identifiers, which contain
* a numerically indexed array with license details.
*
* [ lowercased license identifier =>
* [ 0 => identifier (string), 1 => full name (string), 2 => osi certified (bool), 3 => deprecated (bool) ]
* , ...
* ]
*
* @var array
*/
private $licenses;
/**
* @var string
*/
private $licensesExpression;
/**
* Contains all the license exceptions.
*
* The array is indexed by license exception identifiers, which contain
* a numerically indexed array with license exception details.
*
* [ lowercased exception identifier =>
* [ 0 => exception identifier (string), 1 => full name (string) ]
* , ...
* ]
*
* @var array
*/
private $exceptions;
/**
* @var string
*/
private $exceptionsExpression;
public function __construct()
{
$this->loadLicenses();
$this->loadExceptions();
}
/**
* Returns license metadata by license identifier.
*
* This function adds a link to the full license text to the license metadata.
* The array returned is in the form of:
*
* [ 0 => full name (string), 1 => osi certified, 2 => link to license text (string), 3 => deprecation status (bool) ]
*
* @param string $identifier
*
* @return array|null
*/
public function getLicenseByIdentifier($identifier)
{
$key = strtolower($identifier);
if (!isset($this->licenses[$key])) {
return;
}
list($identifier, $name, $isOsiApproved, $isDeprecatedLicenseId) = $this->licenses[$key];
return array(
$name,
$isOsiApproved,
'https://spdx.org/licenses/' . $identifier . '.html#licenseText',
$isDeprecatedLicenseId,
);
}
/**
* Returns all licenses information, keyed by the lowercased license identifier.
*
* @return array[] Each item is [ 0 => identifier (string), 1 => full name (string), 2 => osi certified (bool), 3 => deprecated (bool) ]
*/
public function getLicenses()
{
return $this->licenses;
}
/**
* Returns license exception metadata by license exception identifier.
*
* This function adds a link to the full license exception text to the license exception metadata.
* The array returned is in the form of:
*
* [ 0 => full name (string), 1 => link to license text (string) ]
*
* @param string $identifier
*
* @return array|null
*/
public function getExceptionByIdentifier($identifier)
{
$key = strtolower($identifier);
if (!isset($this->exceptions[$key])) {
return;
}
list($identifier, $name) = $this->exceptions[$key];
return array(
$name,
'https://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText',
);
}
/**
* Returns the short identifier of a license (or license exception) by full name.
*
* @param string $name
*
* @return string|null
*/
public function getIdentifierByName($name)
{
foreach ($this->licenses as $licenseData) {
if ($licenseData[1] === $name) {
return $licenseData[0];
}
}
foreach ($this->exceptions as $licenseData) {
if ($licenseData[1] === $name) {
return $licenseData[0];
}
}
}
/**
* Returns the OSI Approved status for a license by identifier.
*
* @param string $identifier
*
* @return bool
*/
public function isOsiApprovedByIdentifier($identifier)
{
return $this->licenses[strtolower($identifier)][2];
}
/**
* Returns the deprecation status for a license by identifier.
*
* @param string $identifier
*
* @return bool
*/
public function isDeprecatedByIdentifier($identifier)
{
return $this->licenses[strtolower($identifier)][3];
}
/**
* @param array|string $license
*
* @throws \InvalidArgumentException
*
* @return bool
*/
public function validate($license)
{
if (is_array($license)) {
$count = count($license);
if ($count !== count(array_filter($license, 'is_string'))) {
throw new \InvalidArgumentException('Array of strings expected.');
}
$license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
}
if (!is_string($license)) {
throw new \InvalidArgumentException(sprintf(
'Array or String expected, %s given.',
gettype($license)
));
}
return $this->isValidLicenseString($license);
}
/**
* @return string
*/
public static function getResourcesDir()
{
return dirname(__DIR__) . '/res';
}
private function loadLicenses()
{
if (null !== $this->licenses) {
return;
}
$json = file_get_contents(self::getResourcesDir() . '/' . self::LICENSES_FILE);
$this->licenses = array();
foreach (json_decode($json, true) as $identifier => $license) {
$this->licenses[strtolower($identifier)] = array($identifier, $license[0], $license[1], $license[2]);
}
}
private function loadExceptions()
{
if (null !== $this->exceptions) {
return;
}
$json = file_get_contents(self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
$this->exceptions = array();
foreach (json_decode($json, true) as $identifier => $exception) {
$this->exceptions[strtolower($identifier)] = array($identifier, $exception[0]);
}
}
/**
* @return string
*/
private function getLicensesExpression()
{
if (null === $this->licensesExpression) {
$licenses = array_map('preg_quote', array_keys($this->licenses));
rsort($licenses);
$licenses = implode('|', $licenses);
$this->licensesExpression = $licenses;
}
return $this->licensesExpression;
}
/**
* @return string
*/
private function getExceptionsExpression()
{
if (null === $this->exceptionsExpression) {
$exceptions = array_map('preg_quote', array_keys($this->exceptions));
rsort($exceptions);
$exceptions = implode('|', $exceptions);
$this->exceptionsExpression = $exceptions;
}
return $this->exceptionsExpression;
}
/**
* @param string $license
*
* @throws \RuntimeException
*
* @return bool
*/
private function isValidLicenseString($license)
{
if (isset($this->licenses[strtolower($license)])) {
return true;
}
$licenses = $this->getLicensesExpression();
$exceptions = $this->getExceptionsExpression();
$regex = <<<REGEX
{
(?(DEFINE)
# idstring: 1*( ALPHA / DIGIT / - / . )
(?<idstring>[\pL\pN.-]{1,})
# license-id: taken from list
(?<licenseid>${licenses})
# license-exception-id: taken from list
(?<licenseexceptionid>${exceptions})
# license-ref: [DocumentRef-1*(idstring):]LicenseRef-1*(idstring)
(?<licenseref>(?:DocumentRef-(?&idstring):)?LicenseRef-(?&idstring))
# simple-expresssion: license-id / license-id+ / license-ref
(?<simple_expression>(?&licenseid)\+? | (?&licenseid) | (?&licenseref))
# compound-expression: 1*(
# simple-expression /
# simple-expression WITH license-exception-id /
# compound-expression AND compound-expression /
# compound-expression OR compound-expression
# ) / ( compound-expression ) )
(?<compound_head>
(?&simple_expression) ( \s+ WITH \s+ (?&licenseexceptionid))?
| \( \s* (?&compound_expression) \s* \)
)
(?<compound_expression>
(?&compound_head) (?: \s+ (?:AND|OR) \s+ (?&compound_expression))?
)
# license-expression: 1*1(simple-expression / compound-expression)
(?<license_expression>(?&compound_expression) | (?&simple_expression))
) # end of define
^(NONE | NOASSERTION | (?&license_expression))$
}xi
REGEX;
$match = preg_match($regex, $license);
if (0 === $match) {
return false;
}
if (false === $match) {
throw new \RuntimeException('Regex failed to compile/run.');
}
return true;
}
}