update phpstan to 1.8.2

This commit is contained in:
Andrew Dolgov 2022-07-31 13:55:09 +03:00
parent d5c043e846
commit 26c67dba77
No known key found for this signature in database
GPG Key ID: 1A56B4FA25D4AF2A
34 changed files with 1442 additions and 859 deletions

View File

@ -43,7 +43,8 @@ class FeedItem_Atom extends FeedItem_Common {
$links = $this->elem->getElementsByTagName("link");
foreach ($links as $link) {
if ($link && $link->hasAttribute("href") &&
/** @phpstan-ignore-next-line */
if ($link->hasAttribute("href") &&
(!$link->hasAttribute("rel")
|| $link->getAttribute("rel") == "alternate"
|| $link->getAttribute("rel") == "standout")) {
@ -180,7 +181,8 @@ class FeedItem_Atom extends FeedItem_Common {
$encs = [];
foreach ($links as $link) {
if ($link && $link->hasAttribute("href") && $link->hasAttribute("rel")) {
/** @phpstan-ignore-next-line */
if ($link->hasAttribute("href") && $link->hasAttribute("rel")) {
$base = $this->xpath->evaluate("string(ancestor-or-self::*[@xml:base][1]/@xml:base)", $link);
if ($link->getAttribute("rel") == "enclosure") {

View File

@ -248,11 +248,12 @@ class Feeds extends Handler_Protected {
function ($result, $plugin) use (&$line, &$button_doc) {
if ($result && $button_doc->loadXML($result)) {
/** @var DOMElement|null */
/** @var DOMElement|null $child */
$child = $button_doc->firstChild;
if ($child) {
do {
/** @var DOMElement|null $child */
$child->setAttribute('data-plugin-name', get_class($plugin));
} while ($child = $child->nextSibling);
@ -271,11 +272,12 @@ class Feeds extends Handler_Protected {
function ($result, $plugin) use (&$line, &$button_doc) {
if ($result && $button_doc->loadXML($result)) {
/** @var DOMElement|null */
/** @var DOMElement|null $child */
$child = $button_doc->firstChild;
if ($child) {
do {
/** @var DOMElement|null $child */
$child->setAttribute('data-plugin-name', get_class($plugin));
} while ($child = $child->nextSibling);

View File

@ -115,6 +115,7 @@ class Pref_Filters extends Handler_Protected {
$glue = $filter['match_any_rule'] ? " OR " : " AND ";
$scope_qpart = join($glue, $scope_qparts);
/** @phpstan-ignore-next-line */
if (!$scope_qpart) $scope_qpart = "true";
$rv = array();

View File

@ -662,7 +662,7 @@ class RSSUtils {
print_r($item);
}
if (ini_get("max_execution_time") > 0 && time() - $tstart >= ini_get("max_execution_time") * 0.7) {
if (ini_get("max_execution_time") > 0 && time() - $tstart >= ((float)ini_get("max_execution_time") * 0.7)) {
Debug::log("looks like there's too many articles to process at once, breaking out.", Debug::LOG_VERBOSE);
$pdo->commit();
break;

View File

@ -13,7 +13,7 @@
"j4mie/idiorm": "dev-master"
},
"require-dev": {
"phpstan/phpstan": "1.1.2",
"phpstan/phpstan": "1.8.2",
"phpunit/phpunit": "9.5.16"
}
}

49
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "26f1906259c39e542432c57d76f16369",
"content-hash": "6beda4561e770d2f0c7c532c5e3693d3",
"packages": [
{
"name": "beberlei/assert",
@ -75,20 +75,20 @@
},
{
"name": "chillerlan/php-qrcode",
"version": "4.3.3",
"version": "4.3.4",
"source": {
"type": "git",
"url": "https://github.com/chillerlan/php-qrcode.git",
"reference": "6356b246948ac1025882b3f55e7c68ebd4515ae3"
"reference": "2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/6356b246948ac1025882b3f55e7c68ebd4515ae3",
"reference": "6356b246948ac1025882b3f55e7c68ebd4515ae3",
"url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d",
"reference": "2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d",
"shasum": ""
},
"require": {
"chillerlan/php-settings-container": "^2.1",
"chillerlan/php-settings-container": "^2.1.4",
"ext-mbstring": "*",
"php": "^7.4 || ^8.0"
},
@ -137,7 +137,7 @@
],
"support": {
"issues": "https://github.com/chillerlan/php-qrcode/issues",
"source": "https://github.com/chillerlan/php-qrcode/tree/4.3.3"
"source": "https://github.com/chillerlan/php-qrcode/tree/4.3.4"
},
"funding": [
{
@ -149,7 +149,7 @@
"type": "ko_fi"
}
],
"time": "2021-11-25T22:38:09+00:00"
"time": "2022-07-25T09:12:45+00:00"
},
{
"name": "chillerlan/php-settings-container",
@ -467,16 +467,16 @@
},
{
"name": "thecodingmachine/safe",
"version": "v2.2.1",
"version": "v2.2.2",
"source": {
"type": "git",
"url": "https://github.com/thecodingmachine/safe.git",
"reference": "2a8d758fd17763faf86e4aa798193e17b9fac38c"
"reference": "440284f9592c9df402832452a6871a8b3c48d97e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thecodingmachine/safe/zipball/2a8d758fd17763faf86e4aa798193e17b9fac38c",
"reference": "2a8d758fd17763faf86e4aa798193e17b9fac38c",
"url": "https://api.github.com/repos/thecodingmachine/safe/zipball/440284f9592c9df402832452a6871a8b3c48d97e",
"reference": "440284f9592c9df402832452a6871a8b3c48d97e",
"shasum": ""
},
"require": {
@ -599,9 +599,9 @@
"description": "PHP core functions that throw exceptions instead of returning FALSE on error",
"support": {
"issues": "https://github.com/thecodingmachine/safe/issues",
"source": "https://github.com/thecodingmachine/safe/tree/v2.2.1"
"source": "https://github.com/thecodingmachine/safe/tree/v2.2.2"
},
"time": "2022-06-09T15:36:45+00:00"
"time": "2022-07-20T17:46:34+00:00"
}
],
"packages-dev": [
@ -1130,20 +1130,20 @@
},
{
"name": "phpstan/phpstan",
"version": "1.1.2",
"version": "1.8.2",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "bcea0ae85868a89d5789c75f012c93129f842934"
"reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/bcea0ae85868a89d5789c75f012c93129f842934",
"reference": "bcea0ae85868a89d5789c75f012c93129f842934",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c53312ecc575caf07b0e90dee43883fdf90ca67c",
"reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c",
"shasum": ""
},
"require": {
"php": "^7.1|^8.0"
"php": "^7.2|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
@ -1153,11 +1153,6 @@
"phpstan.phar"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"files": [
"bootstrap.php"
@ -1170,7 +1165,7 @@
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.1.2"
"source": "https://github.com/phpstan/phpstan/tree/1.8.2"
},
"funding": [
{
@ -1190,7 +1185,7 @@
"type": "tidelift"
}
],
"time": "2021-11-09T12:41:09+00:00"
"time": "2022-07-20T09:57:31+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -2695,5 +2690,5 @@
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.1.0"
"plugin-api-version": "2.0.0"
}

View File

@ -24,7 +24,7 @@ jobs:
steps:
- name: "Checkout"
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: "Install PHP"
uses: shivammathur/setup-php@v2
@ -62,7 +62,7 @@ jobs:
# run: git config --global core.autocrlf false
- name: "Checkout"
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: "Install PHP with extensions"
uses: shivammathur/setup-php@v2
@ -79,6 +79,4 @@ jobs:
run: php vendor/bin/phpunit --configuration=phpunit.xml
- name: "Send code coverage report to Codecov.io"
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
uses: codecov/codecov-action@v3

View File

@ -3,6 +3,8 @@
A PHP 7.4+ QR Code library based on the [implementation](https://github.com/kazuhikoarase/qrcode-generator) by [Kazuhiko Arase](https://github.com/kazuhikoarase),
namespaced, cleaned up, improved and other stuff.
**Attention:** there is now also a javascript port: [chillerlan/js-qrcode](https://github.com/chillerlan/js-qrcode).
[![PHP Version Support][php-badge]][php]
[![Packagist version][packagist-badge]][packagist]
[![License][license-badge]][license]
@ -13,7 +15,7 @@ namespaced, cleaned up, improved and other stuff.
[php-badge]: https://img.shields.io/packagist/php-v/chillerlan/php-qrcode?logo=php&color=8892BF
[php]: https://www.php.net/supported-versions.php
[packagist-badge]: https://img.shields.io/packagist/v/chillerlan/php-qrcode.svg
[packagist-badge]: https://img.shields.io/packagist/v/chillerlan/php-qrcode.svg?logo=packagist
[packagist]: https://packagist.org/packages/chillerlan/php-qrcode
[license-badge]: https://img.shields.io/github/license/chillerlan/php-qrcode.svg
[license]: https://github.com/chillerlan/php-qrcode/blob/main/LICENSE
@ -21,17 +23,14 @@ namespaced, cleaned up, improved and other stuff.
[coverage]: https://codecov.io/github/chillerlan/php-qrcode
[scrutinizer-badge]: https://img.shields.io/scrutinizer/g/chillerlan/php-qrcode.svg?logo=scrutinizer
[scrutinizer]: https://scrutinizer-ci.com/g/chillerlan/php-qrcode
[downloads-badge]: https://img.shields.io/packagist/dt/chillerlan/php-qrcode.svg
[downloads-badge]: https://img.shields.io/packagist/dt/chillerlan/php-qrcode.svg?logo=packagist
[downloads]: https://packagist.org/packages/chillerlan/php-qrcode/stats
[gh-action-badge]: https://github.com/chillerlan/php-qrcode/workflows/Continuous%20Integration/badge.svg
[gh-action]: https://github.com/chillerlan/php-qrcode/actions?query=workflow%3A%22Continuous+Integration%22+branch%3Av4.3.x
## Documentation
# Documentation
See [the wiki](https://github.com/chillerlan/php-qrcode/wiki) for advanced documentation.
An API documentation created with [phpDocumentor](https://www.phpdoc.org/) can be found at https://chillerlan.github.io/php-qrcode/ (WIP).
### Requirements
## Requirements
- PHP 7.4+
- `ext-mbstring`
- optional:
@ -39,7 +38,7 @@ An API documentation created with [phpDocumentor](https://www.phpdoc.org/) can b
- `ext-imagick` with [ImageMagick](https://imagemagick.org) installed
- [`setasign/fpdf`](https://github.com/setasign/fpdf) for the PDF output module
### Installation
## Installation
**requires [composer](https://getcomposer.org)**
via terminal: `composer require chillerlan/php-qrcode`
@ -48,20 +47,24 @@ via terminal: `composer require chillerlan/php-qrcode`
```json
{
"require": {
"php": "^7.4",
"chillerlan/php-qrcode": "dev-main"
"php": "^7.4 || ^8.0",
"chillerlan/php-qrcode": "v4.3.x-dev"
}
}
```
Note: replace `dev-main` with a [version constraint](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints), e.g. `^3.2` - see [releases](https://github.com/chillerlan/php-qrcode/releases) for valid versions.
Note: replace `v4.3.x-dev` with a [version constraint](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints), e.g. `^4.3` - see [releases](https://github.com/chillerlan/php-qrcode/releases) for valid versions.
For PHP version ...
- 7.4+ use `^4.3`
- 7.2+ use `^3.4.1` (PHP 7.2 is EOL and 7.3 soon! v3.4.1 also supports PHP8 - however, it's no longer supported)
- 7.0+ use `^2.0` (PHP 7.0 and 7.1 are EOL!)
- 7.2+ use `^3.4.1` (v3.4.1 also supports PHP8)
- 7.0+ use `^2.0`
- 5.6+ use `^1.0` (please let PHP 5 die!)
### Quickstart
In case you want to keep using `v4.3.x-dev`, specify the hash of a commit to avoid running into unforseen issues like so: `v4.3.x-dev#c115f7bc51d466ccb24c544e88329804aad8c2a0`
PSA: [PHP 7.0 - 7.3 are EOL](https://www.php.net/supported-versions.php) and therefore the respective `QRCode` versions are also no longer supported!
## Quickstart
We want to encode this URI for a mobile authenticator into a QRcode image:
```php
$data = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net';
@ -71,33 +74,349 @@ echo '<img src="'.(new QRCode)->render($data).'" alt="QR Code" />';
```
<p align="center">
<img alt="QR codes are awesome!" src="https://raw.githubusercontent.com/chillerlan/php-qrcode/main/examples/example_image.png">
<img alt="QR codes are awesome!" src="https://raw.githubusercontent.com/chillerlan/php-qrcode/main/examples/example_svg.png">
<img alt="QR codes are awesome!" src="https://raw.githubusercontent.com/chillerlan/php-qrcode/v4.3.x/examples/example_image.png">
<img alt="QR codes are awesome!" src="https://raw.githubusercontent.com/chillerlan/php-qrcode/v4.3.x/examples/example_svg.png">
</p>
Wait, what was that? Please again, slower! See [Advanced usage](https://github.com/chillerlan/php-qrcode/wiki/Advanced-usage) on the wiki.
Wait, what was that? Please again, slower!
### Framework Integration
- Drupal [Google Authenticator Login `ga_login`](https://www.drupal.org/project/ga_login)
- WordPress [`wp-two-factor-auth`](https://github.com/sjinks/wp-two-factor-auth)
- WordPress [Simple 2FA `simple-2fa`](https://wordpress.org/plugins/simple-2fa/)
- WoltLab Suite [two-step-verification](http://pluginstore.woltlab.com/file/3007-two-step-verification/)
- [Cachet](https://github.com/CachetHQ/Cachet)
## Advanced usage
Ok, step by step. First you'll need a `QRCode` instance, which can be optionally invoked with a `QROptions` (or a [`SettingsContainerInterface`](https://github.com/chillerlan/php-settings-container/blob/master/src/SettingsContainerInterface.php), respectively) object as the only parameter.
```php
$options = new QROptions([
'version' => 5,
'outputType' => QRCode::OUTPUT_MARKUP_SVG,
'eccLevel' => QRCode::ECC_L,
]);
// invoke a fresh QRCode instance
$qrcode = new QRCode($options);
// and dump the output
$qrcode->render($data);
// ...with additional cache file
$qrcode->render($data, '/path/to/file.svg');
```
In case you just want the raw QR code matrix, call `QRCode::getMatrix()` - this method is also called internally from `QRCode::render()`. See also [[Custom output interface]].
```php
$matrix = $qrcode->getMatrix($data);
foreach($matrix->matrix() as $y => $row){
foreach($row as $x => $module){
// get a module's value
$value = $module;
// or via the matrix's getter method
$value = $matrix->get($x, $y);
// boolean check a module
if($matrix->check($x, $y)){ // if($module >> 8 > 0)
// do stuff, the module is dark
}
else{
// do other stuff, the module is light
}
}
}
```
Have a look [in the examples folder](https://github.com/chillerlan/php-qrcode/tree/main/examples) for some more usage examples.
### Notes
The QR encoder, especially the subroutines for mask pattern testing, can cause high CPU load on increased matrix size.
You can avoid a part of this load by choosing a fast output module, like `OUTPUT_IMAGE_*` and maybe setting the mask pattern manually (which may result in unreadable QR Codes).
Oh hey and don't forget to sanitize any user input!
## Custom output interface
Instead of bloating your code you can simply create your own output interface by creating a `QROutputInterface` (i.e. extending `QROutputAbstract`).
```php
class MyCustomOutput extends QROutputAbstract{
// inherited from QROutputAbstract
protected QRMatrix $matrix; // QRMatrix
protected int $moduleCount; // modules QRMatrix::size()
protected QROptions $options; // MyCustomOptions or QROptions
protected int $scale; // scale factor from options
protected int $length; // length of the matrix ($moduleCount * $scale)
// ...check/set default module values (abstract method, called by the constructor)
protected function setModuleValues():void{
// $this->moduleValues = ...
}
// QROutputInterface::dump()
public function dump(string $file = null):string{
$output = '';
for($row = 0; $row < $this->moduleCount; $row++){
for($col = 0; $col < $this->moduleCount; $col++){
$output .= (int)$this->matrix->check($col, $row);
}
}
return $output;
}
}
```
For more examples, have a look at the [built-in output modules](https://github.com/chillerlan/php-qrcode/tree/main/src/Output).
In case you need additional settings for your output module, just extend `QROptions`...
```
class MyCustomOptions extends QROptions{
protected string $myParam = 'defaultValue';
// ...
}
```
...or use the [`SettingsContainerInterface`](https://github.com/chillerlan/php-settings-container/blob/main/src/SettingsContainerInterface.php), which is the more flexible approach.
```php
trait MyCustomOptionsTrait{
protected string $myParam = 'defaultValue';
// ...
}
```
set the options:
```php
$myOptions = [
'version' => 5,
'eccLevel' => QRCode::ECC_L,
'outputType' => QRCode::OUTPUT_CUSTOM,
'outputInterface' => MyCustomOutput::class,
// your custom settings
'myParam' => 'whatever value',
];
// extends QROptions
$myCustomOptions = new MyCustomOptions($myOptions);
// using the SettingsContainerInterface
$myCustomOptions = new class($myOptions) extends SettingsContainerAbstract{
use QROptionsTrait, MyCustomOptionsTrait;
};
```
You can then call `QRCode` with the custom modules...
```php
(new QRCode($myCustomOptions))->render($data);
```
...or invoke the `QROutputInterface` manually.
```php
$qrOutputInterface = new MyCustomOutput($myCustomOptions, (new QRCode($myCustomOptions))->getMatrix($data));
//dump the output, which is equivalent to QRCode::render()
$qrOutputInterface->dump();
```
### Custom module values
You can distinguish between different parts of the matrix, namely the several required patterns from the QR Code specification, and use them in different ways, i.e. to assign different colors for each part of the matrix (see the [image example](https://github.com/chillerlan/php-qrcode/blob/main/examples/image.php)).
The dark value is the module value (light) shifted by 8 bits to the left: `$value = $M_TYPE << ($bool ? 8 : 0);`, where `$M_TYPE` is one of the `QRMatrix::M_*` constants.
You can check the value for a type explicitly like...
```php
// for true (dark)
($value >> 8) === $M_TYPE;
// for false (light)
$value === $M_TYPE;
```
...or you can perform a loose check, ignoring the module value
```php
// for true
($value >> 8) > 0;
// for false
($value >> 8) === 0;
```
See also `QRMatrix::set()`, `QRMatrix::check()` and [`QRMatrix` constants](#qrmatrix-constants).
To map the values and properly render the modules for the given `QROutputInterface`, it's necessary to overwrite the default values:
```php
$options = new QROptions;
// for HTML, SVG and ImageMagick
$options->moduleValues = [
// finder
1536 => '#A71111', // dark (true)
6 => '#FFBFBF', // light (false)
// alignment
2560 => '#A70364',
10 => '#FFC9C9',
// timing
3072 => '#98005D',
12 => '#FFB8E9',
// format
3584 => '#003804',
14 => '#00FB12',
// version
4096 => '#650098',
16 => '#E0B8FF',
// data
1024 => '#4A6000',
4 => '#ECF9BE',
// darkmodule
512 => '#080063',
// separator
8 => '#AFBFBF',
// quietzone
18 => '#FFFFFF',
];
// for the image output types
$options->moduleValues = [
512 => [0, 0, 0],
// ...
];
// for string/text output
$options->moduleValues = [
512 => '#',
// ...
];
```
## Public API
### `QRCode` API
#### Methods
method | return | description
------ | ------ | -----------
`__construct(QROptions $options = null)` | - | see [`SettingsContainerInterface`](https://github.com/chillerlan/php-settings-container/blob/main/src/SettingsContainerInterface.php)
`render(string $data, string $file = null)` | mixed, `QROutputInterface::dump()` | renders a QR Code for the given `$data` and `QROptions`, saves `$file` optional
`getMatrix(string $data)` | `QRMatrix` | returns a `QRMatrix` object for the given `$data` and current `QROptions`
`initDataInterface(string $data)` | `QRDataInterface` | returns a fresh `QRDataInterface` for the given `$data`
`isNumber(string $string)` | bool | checks if a string qualifies for `Number`
`isAlphaNum(string $string)` | bool | checks if a string qualifies for `AlphaNum`
`isKanji(string $string)` | bool | checks if a string qualifies for `Kanji`
`isByte(string $string)` | bool | checks if a string is non-empty
#### Constants
name | description
---- | -----------
`VERSION_AUTO` | `QROptions::$version`
`MASK_PATTERN_AUTO` | `QROptions::$maskPattern`
`OUTPUT_MARKUP_SVG`, `OUTPUT_MARKUP_HTML` | `QROptions::$outputType` markup
`OUTPUT_IMAGE_PNG`, `OUTPUT_IMAGE_JPG`, `OUTPUT_IMAGE_GIF` | `QROptions::$outputType` image
`OUTPUT_STRING_JSON`, `OUTPUT_STRING_TEXT` | `QROptions::$outputType` string
`OUTPUT_IMAGICK` | `QROptions::$outputType` ImageMagick
`OUTPUT_FPDF` | `QROptions::$outputType` PDF, using [FPDF](https://github.com/setasign/fpdf)
`OUTPUT_CUSTOM` | `QROptions::$outputType`, requires `QROptions::$outputInterface`
`ECC_L`, `ECC_M`, `ECC_Q`, `ECC_H`, | ECC-Level: 7%, 15%, 25%, 30% in `QROptions::$eccLevel`
`DATA_NUMBER`, `DATA_ALPHANUM`, `DATA_BYTE`, `DATA_KANJI` | `QRDataInterface::$datamode`
### `QRMatrix` API
#### Methods
method | return | description
------ | ------ | -----------
`__construct(int $version, int $eclevel)` | - | -
`init(int $maskPattern, bool $test = null)` | `QRMatrix` |
`matrix()` | array | the internal matrix representation as a 2 dimensional array
`version()` | int | the current QR Code version
`eccLevel()` | int | current ECC level
`maskPattern()` | int | the used mask pattern
`size()` | int | the absoulute size of the matrix, including quiet zone (if set). `$version * 4 + 17 + 2 * $quietzone`
`get(int $x, int $y)` | int | returns the value of the module
`set(int $x, int $y, bool $value, int $M_TYPE)` | `QRMatrix` | sets the `$M_TYPE` value for the module
`check(int $x, int $y)` | bool | checks whether a module is true (dark) or false (light)
#### Constants
name | light (false) | dark (true) | description
---- | ------------- | ----------- | -----------
`M_NULL` | 0 | - | module not set (should never appear. if so, there's an error)
`M_DARKMODULE` | - | 512 | once per matrix at `$xy = [8, 4 * $version + 9]`
`M_DATA` | 4 | 1024 | the actual encoded data
`M_FINDER` | 6 | 1536 | the 7x7 finder patterns
`M_SEPARATOR` | 8 | - | separator lines around the finder patterns
`M_ALIGNMENT` | 10 | 2560 | the 5x5 alignment patterns
`M_TIMING` | 12 | 3072 | the timing pattern lines
`M_FORMAT` | 14 | 3584 | format information pattern
`M_VERSION` | 16 | 4096 | version information pattern
`M_QUIETZONE` | 18 | - | margin around the QR Code
`M_LOGO` | 20 | - | space for a logo image (not used yet)
`M_TEST` | 255 | 65280 | test value
### `QROptions` API
#### Properties
property | type | default | allowed | description
-------- | ---- | ------- | ------- | -----------
`$version` | int | `QRCode::VERSION_AUTO` | 1...40 | the [QR Code version number](http://www.qrcode.com/en/about/version.html)
`$versionMin` | int | 1 | 1...40 | Minimum QR version (if `$version = QRCode::VERSION_AUTO`)
`$versionMax` | int | 40 | 1...40 | Maximum QR version (if `$version = QRCode::VERSION_AUTO`)
`$eccLevel` | int | `QRCode::ECC_L` | `QRCode::ECC_X` | Error correct level, where X = L (7%), M (15%), Q (25%), H (30%)
`$maskPattern` | int | `QRCode::MASK_PATTERN_AUTO` | 0...7 | Mask Pattern to use
`$addQuietzone` | bool | `true` | - | Add a "quiet zone" (margin) according to the QR code spec
`$quietzoneSize` | int | 4 | clamped to 0 ... `$matrixSize / 2` | Size of the quiet zone
`$dataModeOverride` | string | `null` | `Number`, `AlphaNum`, `Kanji`, `Byte` | allows overriding the data type detection
`$outputType` | string | `QRCode::OUTPUT_IMAGE_PNG` | `QRCode::OUTPUT_*` | built-in output type
`$outputInterface` | string | `null` | * | FQCN of the custom `QROutputInterface` if `QROptions::$outputType` is set to `QRCode::OUTPUT_CUSTOM`
`$cachefile` | string | `null` | * | optional cache file path
`$eol` | string | `PHP_EOL` | * | newline string (HTML, SVG, TEXT)
`$scale` | int | 5 | * | size of a QR code pixel (SVG, IMAGE_*), HTML -> via CSS
`$cssClass` | string | `null` | * | a common css class
`$svgOpacity` | float | 1.0 | 0...1 |
`$svgDefs` | string | * | * | anything between [`<defs>`](https://developer.mozilla.org/docs/Web/SVG/Element/defs)
`$svgViewBoxSize` | int | `null` | * | a positive integer which defines width/height of the [viewBox attribute](https://css-tricks.com/scale-svg/#article-header-id-3)
`$textDark` | string | '🔴' | * | string substitute for dark
`$textLight` | string | '⭕' | * | string substitute for light
`$markupDark` | string | '#000' | * | markup substitute for dark (CSS value)
`$markupLight` | string | '#fff' | * | markup substitute for light (CSS value)
`$imageBase64` | bool | `true` | - | whether to return the image data as base64 or raw like from `file_get_contents()`
`$imageTransparent` | bool | `true` | - | toggle transparency (no jpeg support)
`$imageTransparencyBG` | array | `[255, 255, 255]` | `[R, G, B]` | the RGB values for the transparent color, see [`imagecolortransparent()`](http://php.net/manual/function.imagecolortransparent.php)
`$pngCompression` | int | -1 | -1 ... 9 | `imagepng()` compression level, -1 = auto
`$jpegQuality` | int | 85 | 0 - 100 | `imagejpeg()` quality
`$imagickFormat` | string | 'png' | * | ImageMagick output type, see `Imagick::setType()`
`$imagickBG` | string | `null` | * | ImageMagick background color, see `ImagickPixel::__construct()`
`$moduleValues` | array | `null` | * | Module values map, see [[Custom output interface]] and `QROutputInterface::DEFAULT_MODULE_VALUES`
## Framework Integration
- Drupal:
- [Google Authenticator Login `ga_login`](https://www.drupal.org/project/ga_login)
- Symfony
- [phpqrcode-bundle](https://github.com/jonasarts/phpqrcode-bundle)
- WordPress:
- [`wp-two-factor-auth`](https://github.com/sjinks/wp-two-factor-auth)
- [`simple-2fa`](https://wordpress.org/plugins/simple-2fa/)
- [`wordpress-seo`](https://github.com/Yoast/wordpress-seo)
- [`floating-share-button`](https://github.com/qriouslad/floating-share-button)
- WoltLab Suite
- [two-step-verification](http://pluginstore.woltlab.com/file/3007-two-step-verification/)
- [Appwrite](https://github.com/appwrite/appwrite)
- [Cachet](https://github.com/CachetHQ/Cachet)
- [twill](https://github.com/area17/twill)
- other uses: [dependents](https://github.com/chillerlan/php-qrcode/network/dependents) / [packages](https://github.com/chillerlan/php-qrcode/network/dependents?dependent_type=PACKAGE)
### Shameless advertising
## Shameless advertising
Hi, please check out my other projects that are way cooler than qrcodes!
- [php-oauth-core](https://github.com/chillerlan/php-oauth-core) - an OAuth 1/2 client library along with a bunch of [providers](https://github.com/chillerlan/php-oauth-providers)
- [php-httpinterface](https://github.com/chillerlan/php-httpinterface) - a PSR-7/15/17/18 implemetation
- [php-database](https://github.com/chillerlan/php-database) - a database client & querybuilder for MySQL, Postgres, SQLite, MSSQL, Firebird
### Disclaimer!
## Disclaimer!
I don't take responsibility for molten CPUs, misled applications, failed log-ins etc.. Use at your own risk!
#### Trademark Notice
### Trademark Notice
The word "QR Code" is registered trademark of *DENSO WAVE INCORPORATED*<br>
http://www.denso-wave.com/qrcode/faqpatent-e.html
The word "QR Code" is a registered trademark of *DENSO WAVE INCORPORATED*<br>
https://www.qrcode.com/en/faq.html#patentH2Title

View File

@ -26,7 +26,7 @@
"require": {
"php": "^7.4 || ^8.0",
"ext-mbstring": "*",
"chillerlan/php-settings-container": "^2.1"
"chillerlan/php-settings-container": "^2.1.4"
},
"require-dev": {
"phpunit/phpunit": "^9.5",

View File

@ -307,7 +307,7 @@ class QRCode{
* a dummy
*/
public function isByte(string $data):bool{
return !empty($data);
return $data !== '';
}
}

View File

@ -74,6 +74,7 @@ class QRCodeTest extends TestCase{
public function testIsByte():void{
$this::assertTrue($this->qrcode->isByte("\x01\x02\x03"));
$this::assertTrue($this->qrcode->isByte(' ')); // not empty!
$this::assertTrue($this->qrcode->isByte('0'));
$this::assertFalse($this->qrcode->isByte(''));
}

View File

@ -42,75 +42,30 @@ namespace Composer\Autoload;
*/
class ClassLoader
{
/** @var ?string */
private $vendorDir;
// PSR-4
/**
* @var array[]
* @psalm-var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, array<int, string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* @var array[]
* @psalm-var array<string, array<string, string[]>>
*/
private $prefixesPsr0 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr0 = array();
/** @var bool */
private $useIncludePath = false;
/**
* @var string[]
* @psalm-var array<string, string>
*/
private $classMap = array();
/** @var bool */
private $classMapAuthoritative = false;
/**
* @var bool[]
* @psalm-var array<string, bool>
*/
private $missingClasses = array();
/** @var ?string */
private $apcuPrefix;
/**
* @var self[]
*/
private static $registeredLoaders = array();
/**
* @param ?string $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
}
/**
* @return string[]
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
@ -120,47 +75,28 @@ class ClassLoader
return array();
}
/**
* @return array[]
* @psalm-return array<string, array<int, string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
/**
* @return string[] Array of classname => path
* @psalm-var array<string, string>
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* @param string[] $classMap Class to filename map
* @psalm-param array<string, string> $classMap
*
* @return void
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
@ -176,10 +112,8 @@ class ClassLoader
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 root directories
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
@ -223,12 +157,10 @@ class ClassLoader
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
@ -273,9 +205,7 @@ class ClassLoader
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 base directories
*
* @return void
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
@ -291,11 +221,9 @@ class ClassLoader
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function setPsr4($prefix, $paths)
{
@ -315,8 +243,6 @@ class ClassLoader
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*
* @return void
*/
public function setUseIncludePath($useIncludePath)
{
@ -339,8 +265,6 @@ class ClassLoader
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*
* @return void
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
@ -361,8 +285,6 @@ class ClassLoader
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*
* @return void
*/
public function setApcuPrefix($apcuPrefix)
{
@ -383,18 +305,14 @@ class ClassLoader
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*
* @return void
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
if (null === $this->vendorDir) {
return;
}
if ($prepend) {
//no-op
} elseif ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
@ -404,8 +322,6 @@ class ClassLoader
/**
* Unregisters this instance as an autoloader.
*
* @return void
*/
public function unregister()
{
@ -420,7 +336,7 @@ class ClassLoader
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return true|null True if loaded, null otherwise
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
@ -429,8 +345,6 @@ class ClassLoader
return true;
}
return null;
}
/**
@ -485,11 +399,6 @@ class ClassLoader
return self::$registeredLoaders;
}
/**
* @param string $class
* @param string $ext
* @return string|false
*/
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
@ -561,10 +470,6 @@ class ClassLoader
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
* @private
*/
function includeFile($file)
{

View File

@ -18,27 +18,414 @@ use Composer\Semver\VersionParser;
/**
* This class is copied in every Composer installed project and available to all
*
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
*
* To require its presence, you can require `composer-runtime-api ^2.0`
* To require it's presence, you can require `composer-runtime-api ^2.0`
*/
class InstalledVersions
{
/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
*/
private static $installed;
/**
* @var bool|null
*/
private static $installed = array (
'root' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => 'd5c043e8467881c00b2cd836f2f37b8479cf0b96',
'name' => '__root__',
),
'versions' =>
array (
'__root__' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
),
'reference' => 'd5c043e8467881c00b2cd836f2f37b8479cf0b96',
),
'beberlei/assert' =>
array (
'pretty_version' => 'v3.3.2',
'version' => '3.3.2.0',
'aliases' =>
array (
),
'reference' => 'cb70015c04be1baee6f5f5c953703347c0ac1655',
),
'chillerlan/php-qrcode' =>
array (
'pretty_version' => '4.3.4',
'version' => '4.3.4.0',
'aliases' =>
array (
),
'reference' => '2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d',
),
'chillerlan/php-settings-container' =>
array (
'pretty_version' => '2.1.4',
'version' => '2.1.4.0',
'aliases' =>
array (
),
'reference' => '1beb7df3c14346d4344b0b2e12f6f9a74feabd4a',
),
'doctrine/instantiator' =>
array (
'pretty_version' => '1.4.1',
'version' => '1.4.1.0',
'aliases' =>
array (
),
'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc',
),
'j4mie/idiorm' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'aliases' =>
array (
0 => '9999999-dev',
),
'reference' => 'efc8ea06698f53e2c479c7696f2b154c47c3a3cb',
),
'mervick/material-design-icons' =>
array (
'pretty_version' => '2.2.0',
'version' => '2.2.0.0',
'aliases' =>
array (
),
'reference' => '635435c8d3df3a6da3241648caf8a65d1c07cc1a',
),
'myclabs/deep-copy' =>
array (
'pretty_version' => '1.11.0',
'version' => '1.11.0.0',
'aliases' =>
array (
),
'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614',
),
'nikic/php-parser' =>
array (
'pretty_version' => 'v4.14.0',
'version' => '4.14.0.0',
'aliases' =>
array (
),
'reference' => '34bea19b6e03d8153165d8f30bba4c3be86184c1',
),
'paragonie/constant_time_encoding' =>
array (
'pretty_version' => 'v2.6.3',
'version' => '2.6.3.0',
'aliases' =>
array (
),
'reference' => '58c3f47f650c94ec05a151692652a868995d2938',
),
'phar-io/manifest' =>
array (
'pretty_version' => '2.0.3',
'version' => '2.0.3.0',
'aliases' =>
array (
),
'reference' => '97803eca37d319dfa7826cc2437fc020857acb53',
),
'phar-io/version' =>
array (
'pretty_version' => '3.2.1',
'version' => '3.2.1.0',
'aliases' =>
array (
),
'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74',
),
'phpdocumentor/reflection-common' =>
array (
'pretty_version' => '2.2.0',
'version' => '2.2.0.0',
'aliases' =>
array (
),
'reference' => '1d01c49d4ed62f25aa84a747ad35d5a16924662b',
),
'phpdocumentor/reflection-docblock' =>
array (
'pretty_version' => '5.3.0',
'version' => '5.3.0.0',
'aliases' =>
array (
),
'reference' => '622548b623e81ca6d78b721c5e029f4ce664f170',
),
'phpdocumentor/type-resolver' =>
array (
'pretty_version' => '1.6.1',
'version' => '1.6.1.0',
'aliases' =>
array (
),
'reference' => '77a32518733312af16a44300404e945338981de3',
),
'phpspec/prophecy' =>
array (
'pretty_version' => 'v1.15.0',
'version' => '1.15.0.0',
'aliases' =>
array (
),
'reference' => 'bbcd7380b0ebf3961ee21409db7b38bc31d69a13',
),
'phpstan/phpstan' =>
array (
'pretty_version' => '1.8.2',
'version' => '1.8.2.0',
'aliases' =>
array (
),
'reference' => 'c53312ecc575caf07b0e90dee43883fdf90ca67c',
),
'phpunit/php-code-coverage' =>
array (
'pretty_version' => '9.2.15',
'version' => '9.2.15.0',
'aliases' =>
array (
),
'reference' => '2e9da11878c4202f97915c1cb4bb1ca318a63f5f',
),
'phpunit/php-file-iterator' =>
array (
'pretty_version' => '3.0.6',
'version' => '3.0.6.0',
'aliases' =>
array (
),
'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf',
),
'phpunit/php-invoker' =>
array (
'pretty_version' => '3.1.1',
'version' => '3.1.1.0',
'aliases' =>
array (
),
'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67',
),
'phpunit/php-text-template' =>
array (
'pretty_version' => '2.0.4',
'version' => '2.0.4.0',
'aliases' =>
array (
),
'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28',
),
'phpunit/php-timer' =>
array (
'pretty_version' => '5.0.3',
'version' => '5.0.3.0',
'aliases' =>
array (
),
'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2',
),
'phpunit/phpunit' =>
array (
'pretty_version' => '9.5.16',
'version' => '9.5.16.0',
'aliases' =>
array (
),
'reference' => '5ff8c545a50226c569310a35f4fa89d79f1ddfdc',
),
'sebastian/cli-parser' =>
array (
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
'aliases' =>
array (
),
'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2',
),
'sebastian/code-unit' =>
array (
'pretty_version' => '1.0.8',
'version' => '1.0.8.0',
'aliases' =>
array (
),
'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120',
),
'sebastian/code-unit-reverse-lookup' =>
array (
'pretty_version' => '2.0.3',
'version' => '2.0.3.0',
'aliases' =>
array (
),
'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5',
),
'sebastian/comparator' =>
array (
'pretty_version' => '4.0.6',
'version' => '4.0.6.0',
'aliases' =>
array (
),
'reference' => '55f4261989e546dc112258c7a75935a81a7ce382',
),
'sebastian/complexity' =>
array (
'pretty_version' => '2.0.2',
'version' => '2.0.2.0',
'aliases' =>
array (
),
'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88',
),
'sebastian/diff' =>
array (
'pretty_version' => '4.0.4',
'version' => '4.0.4.0',
'aliases' =>
array (
),
'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d',
),
'sebastian/environment' =>
array (
'pretty_version' => '5.1.4',
'version' => '5.1.4.0',
'aliases' =>
array (
),
'reference' => '1b5dff7bb151a4db11d49d90e5408e4e938270f7',
),
'sebastian/exporter' =>
array (
'pretty_version' => '4.0.4',
'version' => '4.0.4.0',
'aliases' =>
array (
),
'reference' => '65e8b7db476c5dd267e65eea9cab77584d3cfff9',
),
'sebastian/global-state' =>
array (
'pretty_version' => '5.0.5',
'version' => '5.0.5.0',
'aliases' =>
array (
),
'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2',
),
'sebastian/lines-of-code' =>
array (
'pretty_version' => '1.0.3',
'version' => '1.0.3.0',
'aliases' =>
array (
),
'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc',
),
'sebastian/object-enumerator' =>
array (
'pretty_version' => '4.0.4',
'version' => '4.0.4.0',
'aliases' =>
array (
),
'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71',
),
'sebastian/object-reflector' =>
array (
'pretty_version' => '2.0.4',
'version' => '2.0.4.0',
'aliases' =>
array (
),
'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7',
),
'sebastian/recursion-context' =>
array (
'pretty_version' => '4.0.4',
'version' => '4.0.4.0',
'aliases' =>
array (
),
'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172',
),
'sebastian/resource-operations' =>
array (
'pretty_version' => '3.0.3',
'version' => '3.0.3.0',
'aliases' =>
array (
),
'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8',
),
'sebastian/type' =>
array (
'pretty_version' => '2.3.4',
'version' => '2.3.4.0',
'aliases' =>
array (
),
'reference' => 'b8cd8a1c753c90bc1a0f5372170e3e489136f914',
),
'sebastian/version' =>
array (
'pretty_version' => '3.0.2',
'version' => '3.0.2.0',
'aliases' =>
array (
),
'reference' => 'c6c1022351a901512170118436c764e473f6de8c',
),
'spomky-labs/otphp' =>
array (
'pretty_version' => 'v10.0.3',
'version' => '10.0.3.0',
'aliases' =>
array (
),
'reference' => '9784d9f7c790eed26e102d6c78f12c754036c366',
),
'thecodingmachine/safe' =>
array (
'pretty_version' => 'v2.2.2',
'version' => '2.2.2.0',
'aliases' =>
array (
),
'reference' => '440284f9592c9df402832452a6871a8b3c48d97e',
),
'theseer/tokenizer' =>
array (
'pretty_version' => '1.2.1',
'version' => '1.2.1.0',
'aliases' =>
array (
),
'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e',
),
'webmozart/assert' =>
array (
'pretty_version' => '1.11.0',
'version' => '1.11.0.0',
'aliases' =>
array (
),
'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991',
),
),
);
private static $canGetVendors;
/**
* @var array[]
* @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
*/
private static $installedByVendor = array();
/**
@ -54,6 +441,7 @@ class InstalledVersions
$packages[] = array_keys($installed['versions']);
}
if (1 === \count($packages)) {
return $packages[0];
}
@ -61,42 +449,19 @@ class InstalledVersions
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
}
/**
* Returns a list of all package names with a specific type e.g. 'library'
*
* @param string $type
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackagesByType($type)
{
$packagesByType = array();
foreach (self::getInstalled() as $installed) {
foreach ($installed['versions'] as $name => $package) {
if (isset($package['type']) && $package['type'] === $type) {
$packagesByType[] = $name;
}
}
}
return $packagesByType;
}
/**
* Checks whether the given package is installed
*
* This also returns true if the package name is provided or replaced by another package
*
* @param string $packageName
* @param bool $includeDevRequirements
* @return bool
*/
public static function isInstalled($packageName, $includeDevRequirements = true)
public static function isInstalled($packageName)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
return true;
}
}
@ -113,6 +478,7 @@ class InstalledVersions
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
* @param string $packageName
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
*
* @return bool
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
@ -222,26 +588,9 @@ class InstalledVersions
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
*/
public static function getInstallPath($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @return array
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]}
*/
public static function getRootPackage()
{
@ -253,38 +602,14 @@ class InstalledVersions
/**
* Returns the raw installed.php data for custom implementations
*
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
* @return array[]
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]}, versions: list<string, array{pretty_version: ?string, version: ?string, aliases: ?string[], reference: ?string, replaced: ?string[], provided: ?string[]}>}
*/
public static function getRawData()
{
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = include __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
return self::$installed;
}
/**
* Returns the raw data of all installed.php which are currently loaded for custom implementations
*
* @return array[]
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
*/
public static function getAllRawData()
{
return self::getInstalled();
}
/**
* Lets you reload the static array from another file
*
@ -301,7 +626,7 @@ class InstalledVersions
* @param array[] $data A vendor/composer/installed.php data set
* @return void
*
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]}, versions: list<string, array{pretty_version: ?string, version: ?string, aliases: ?string[], reference: ?string, replaced: ?string[], provided: ?string[]}>} $data
*/
public static function reload($data)
{
@ -311,7 +636,6 @@ class InstalledVersions
/**
* @return array[]
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
*/
private static function getInstalled()
{
@ -322,27 +646,16 @@ class InstalledVersions
$installed = array();
if (self::$canGetVendors) {
// @phpstan-ignore-next-line
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
}
}
}
}
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = require __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
$installed[] = self::$installed;
return $installed;

View File

@ -1,4 +1,3 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -18,4 +17,3 @@ 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.

View File

@ -22,6 +22,8 @@ class ComposerAutoloaderInit19fc2ff1c0f9a92279c7979386bb2056
return self::$loader;
}
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInit19fc2ff1c0f9a92279c7979386bb2056', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit19fc2ff1c0f9a92279c7979386bb2056', 'loadClassLoader'));

View File

@ -72,21 +72,21 @@
},
{
"name": "chillerlan/php-qrcode",
"version": "4.3.3",
"version_normalized": "4.3.3.0",
"version": "4.3.4",
"version_normalized": "4.3.4.0",
"source": {
"type": "git",
"url": "https://github.com/chillerlan/php-qrcode.git",
"reference": "6356b246948ac1025882b3f55e7c68ebd4515ae3"
"reference": "2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/6356b246948ac1025882b3f55e7c68ebd4515ae3",
"reference": "6356b246948ac1025882b3f55e7c68ebd4515ae3",
"url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d",
"reference": "2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d",
"shasum": ""
},
"require": {
"chillerlan/php-settings-container": "^2.1",
"chillerlan/php-settings-container": "^2.1.4",
"ext-mbstring": "*",
"php": "^7.4 || ^8.0"
},
@ -99,7 +99,7 @@
"chillerlan/php-authenticator": "Yet another Google authenticator! Also creates URIs for mobile apps.",
"setasign/fpdf": "Required to use the QR FPDF output."
},
"time": "2021-11-25T22:38:09+00:00",
"time": "2022-07-25T09:12:45+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -137,7 +137,7 @@
],
"support": {
"issues": "https://github.com/chillerlan/php-qrcode/issues",
"source": "https://github.com/chillerlan/php-qrcode/tree/4.3.3"
"source": "https://github.com/chillerlan/php-qrcode/tree/4.3.4"
},
"funding": [
{
@ -954,36 +954,31 @@
},
{
"name": "phpstan/phpstan",
"version": "1.1.2",
"version_normalized": "1.1.2.0",
"version": "1.8.2",
"version_normalized": "1.8.2.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "bcea0ae85868a89d5789c75f012c93129f842934"
"reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/bcea0ae85868a89d5789c75f012c93129f842934",
"reference": "bcea0ae85868a89d5789c75f012c93129f842934",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c53312ecc575caf07b0e90dee43883fdf90ca67c",
"reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c",
"shasum": ""
},
"require": {
"php": "^7.1|^8.0"
"php": "^7.2|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
},
"time": "2021-11-09T12:41:09+00:00",
"time": "2022-07-20T09:57:31+00:00",
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"installation-source": "dist",
"autoload": {
"files": [
@ -997,7 +992,7 @@
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.1.2"
"source": "https://github.com/phpstan/phpstan/tree/1.8.2"
},
"funding": [
{
@ -2550,17 +2545,17 @@
},
{
"name": "thecodingmachine/safe",
"version": "v2.2.1",
"version_normalized": "2.2.1.0",
"version": "v2.2.2",
"version_normalized": "2.2.2.0",
"source": {
"type": "git",
"url": "https://github.com/thecodingmachine/safe.git",
"reference": "2a8d758fd17763faf86e4aa798193e17b9fac38c"
"reference": "440284f9592c9df402832452a6871a8b3c48d97e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thecodingmachine/safe/zipball/2a8d758fd17763faf86e4aa798193e17b9fac38c",
"reference": "2a8d758fd17763faf86e4aa798193e17b9fac38c",
"url": "https://api.github.com/repos/thecodingmachine/safe/zipball/440284f9592c9df402832452a6871a8b3c48d97e",
"reference": "440284f9592c9df402832452a6871a8b3c48d97e",
"shasum": ""
},
"require": {
@ -2572,7 +2567,7 @@
"squizlabs/php_codesniffer": "^3.2",
"thecodingmachine/phpstan-strict-rules": "^1.0"
},
"time": "2022-06-09T15:36:45+00:00",
"time": "2022-07-20T17:46:34+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -2685,7 +2680,7 @@
"description": "PHP core functions that throw exceptions instead of returning FALSE on error",
"support": {
"issues": "https://github.com/thecodingmachine/safe/issues",
"source": "https://github.com/thecodingmachine/safe/tree/v2.2.1"
"source": "https://github.com/thecodingmachine/safe/tree/v2.2.2"
},
"install-path": "../thecodingmachine/safe"
},

View File

@ -1,403 +1,403 @@
<?php return array (
'root' => array(
'root' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '96f704d157fcf20da130f37a31fbffd62a8a9892',
'aliases' =>
array (
),
'reference' => 'd5c043e8467881c00b2cd836f2f37b8479cf0b96',
'name' => '__root__',
'dev' => true,
),
'versions' => array(
'__root__' => array(
'versions' =>
array (
'__root__' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '96f704d157fcf20da130f37a31fbffd62a8a9892',
'dev_requirement' => false,
'aliases' =>
array (
),
'beberlei/assert' => array(
'reference' => 'd5c043e8467881c00b2cd836f2f37b8479cf0b96',
),
'beberlei/assert' =>
array (
'pretty_version' => 'v3.3.2',
'version' => '3.3.2.0',
'type' => 'library',
'install_path' => __DIR__ . '/../beberlei/assert',
'aliases' => array(),
'aliases' =>
array (
),
'reference' => 'cb70015c04be1baee6f5f5c953703347c0ac1655',
'dev_requirement' => false,
),
'chillerlan/php-qrcode' => array(
'pretty_version' => '4.3.3',
'version' => '4.3.3.0',
'type' => 'library',
'install_path' => __DIR__ . '/../chillerlan/php-qrcode',
'aliases' => array(),
'reference' => '6356b246948ac1025882b3f55e7c68ebd4515ae3',
'dev_requirement' => false,
'chillerlan/php-qrcode' =>
array (
'pretty_version' => '4.3.4',
'version' => '4.3.4.0',
'aliases' =>
array (
),
'chillerlan/php-settings-container' => array(
'reference' => '2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d',
),
'chillerlan/php-settings-container' =>
array (
'pretty_version' => '2.1.4',
'version' => '2.1.4.0',
'type' => 'library',
'install_path' => __DIR__ . '/../chillerlan/php-settings-container',
'aliases' => array(),
'reference' => '1beb7df3c14346d4344b0b2e12f6f9a74feabd4a',
'dev_requirement' => false,
'aliases' =>
array (
),
'doctrine/instantiator' => array(
'reference' => '1beb7df3c14346d4344b0b2e12f6f9a74feabd4a',
),
'doctrine/instantiator' =>
array (
'pretty_version' => '1.4.1',
'version' => '1.4.1.0',
'type' => 'library',
'install_path' => __DIR__ . '/../doctrine/instantiator',
'aliases' => array(),
'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc',
'dev_requirement' => true,
'aliases' =>
array (
),
'j4mie/idiorm' => array(
'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc',
),
'j4mie/idiorm' =>
array (
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'type' => 'library',
'install_path' => __DIR__ . '/../j4mie/idiorm',
'aliases' => array(
'aliases' =>
array (
0 => '9999999-dev',
),
'reference' => 'efc8ea06698f53e2c479c7696f2b154c47c3a3cb',
'dev_requirement' => false,
),
'mervick/material-design-icons' => array(
'mervick/material-design-icons' =>
array (
'pretty_version' => '2.2.0',
'version' => '2.2.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../mervick/material-design-icons',
'aliases' => array(),
'reference' => '635435c8d3df3a6da3241648caf8a65d1c07cc1a',
'dev_requirement' => false,
'aliases' =>
array (
),
'myclabs/deep-copy' => array(
'reference' => '635435c8d3df3a6da3241648caf8a65d1c07cc1a',
),
'myclabs/deep-copy' =>
array (
'pretty_version' => '1.11.0',
'version' => '1.11.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../myclabs/deep-copy',
'aliases' => array(),
'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614',
'dev_requirement' => true,
'aliases' =>
array (
),
'nikic/php-parser' => array(
'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614',
),
'nikic/php-parser' =>
array (
'pretty_version' => 'v4.14.0',
'version' => '4.14.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../nikic/php-parser',
'aliases' => array(),
'reference' => '34bea19b6e03d8153165d8f30bba4c3be86184c1',
'dev_requirement' => true,
'aliases' =>
array (
),
'paragonie/constant_time_encoding' => array(
'reference' => '34bea19b6e03d8153165d8f30bba4c3be86184c1',
),
'paragonie/constant_time_encoding' =>
array (
'pretty_version' => 'v2.6.3',
'version' => '2.6.3.0',
'type' => 'library',
'install_path' => __DIR__ . '/../paragonie/constant_time_encoding',
'aliases' => array(),
'reference' => '58c3f47f650c94ec05a151692652a868995d2938',
'dev_requirement' => false,
'aliases' =>
array (
),
'phar-io/manifest' => array(
'reference' => '58c3f47f650c94ec05a151692652a868995d2938',
),
'phar-io/manifest' =>
array (
'pretty_version' => '2.0.3',
'version' => '2.0.3.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phar-io/manifest',
'aliases' => array(),
'reference' => '97803eca37d319dfa7826cc2437fc020857acb53',
'dev_requirement' => true,
'aliases' =>
array (
),
'phar-io/version' => array(
'reference' => '97803eca37d319dfa7826cc2437fc020857acb53',
),
'phar-io/version' =>
array (
'pretty_version' => '3.2.1',
'version' => '3.2.1.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phar-io/version',
'aliases' => array(),
'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74',
'dev_requirement' => true,
'aliases' =>
array (
),
'phpdocumentor/reflection-common' => array(
'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74',
),
'phpdocumentor/reflection-common' =>
array (
'pretty_version' => '2.2.0',
'version' => '2.2.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phpdocumentor/reflection-common',
'aliases' => array(),
'reference' => '1d01c49d4ed62f25aa84a747ad35d5a16924662b',
'dev_requirement' => true,
'aliases' =>
array (
),
'phpdocumentor/reflection-docblock' => array(
'reference' => '1d01c49d4ed62f25aa84a747ad35d5a16924662b',
),
'phpdocumentor/reflection-docblock' =>
array (
'pretty_version' => '5.3.0',
'version' => '5.3.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phpdocumentor/reflection-docblock',
'aliases' => array(),
'reference' => '622548b623e81ca6d78b721c5e029f4ce664f170',
'dev_requirement' => true,
'aliases' =>
array (
),
'phpdocumentor/type-resolver' => array(
'reference' => '622548b623e81ca6d78b721c5e029f4ce664f170',
),
'phpdocumentor/type-resolver' =>
array (
'pretty_version' => '1.6.1',
'version' => '1.6.1.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phpdocumentor/type-resolver',
'aliases' => array(),
'reference' => '77a32518733312af16a44300404e945338981de3',
'dev_requirement' => true,
'aliases' =>
array (
),
'phpspec/prophecy' => array(
'reference' => '77a32518733312af16a44300404e945338981de3',
),
'phpspec/prophecy' =>
array (
'pretty_version' => 'v1.15.0',
'version' => '1.15.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phpspec/prophecy',
'aliases' => array(),
'aliases' =>
array (
),
'reference' => 'bbcd7380b0ebf3961ee21409db7b38bc31d69a13',
'dev_requirement' => true,
),
'phpstan/phpstan' => array(
'pretty_version' => '1.1.2',
'version' => '1.1.2.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phpstan/phpstan',
'aliases' => array(),
'reference' => 'bcea0ae85868a89d5789c75f012c93129f842934',
'dev_requirement' => true,
'phpstan/phpstan' =>
array (
'pretty_version' => '1.8.2',
'version' => '1.8.2.0',
'aliases' =>
array (
),
'phpunit/php-code-coverage' => array(
'reference' => 'c53312ecc575caf07b0e90dee43883fdf90ca67c',
),
'phpunit/php-code-coverage' =>
array (
'pretty_version' => '9.2.15',
'version' => '9.2.15.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phpunit/php-code-coverage',
'aliases' => array(),
'reference' => '2e9da11878c4202f97915c1cb4bb1ca318a63f5f',
'dev_requirement' => true,
'aliases' =>
array (
),
'phpunit/php-file-iterator' => array(
'reference' => '2e9da11878c4202f97915c1cb4bb1ca318a63f5f',
),
'phpunit/php-file-iterator' =>
array (
'pretty_version' => '3.0.6',
'version' => '3.0.6.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phpunit/php-file-iterator',
'aliases' => array(),
'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf',
'dev_requirement' => true,
'aliases' =>
array (
),
'phpunit/php-invoker' => array(
'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf',
),
'phpunit/php-invoker' =>
array (
'pretty_version' => '3.1.1',
'version' => '3.1.1.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phpunit/php-invoker',
'aliases' => array(),
'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67',
'dev_requirement' => true,
'aliases' =>
array (
),
'phpunit/php-text-template' => array(
'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67',
),
'phpunit/php-text-template' =>
array (
'pretty_version' => '2.0.4',
'version' => '2.0.4.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phpunit/php-text-template',
'aliases' => array(),
'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28',
'dev_requirement' => true,
'aliases' =>
array (
),
'phpunit/php-timer' => array(
'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28',
),
'phpunit/php-timer' =>
array (
'pretty_version' => '5.0.3',
'version' => '5.0.3.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phpunit/php-timer',
'aliases' => array(),
'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2',
'dev_requirement' => true,
'aliases' =>
array (
),
'phpunit/phpunit' => array(
'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2',
),
'phpunit/phpunit' =>
array (
'pretty_version' => '9.5.16',
'version' => '9.5.16.0',
'type' => 'library',
'install_path' => __DIR__ . '/../phpunit/phpunit',
'aliases' => array(),
'reference' => '5ff8c545a50226c569310a35f4fa89d79f1ddfdc',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/cli-parser' => array(
'reference' => '5ff8c545a50226c569310a35f4fa89d79f1ddfdc',
),
'sebastian/cli-parser' =>
array (
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/cli-parser',
'aliases' => array(),
'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/code-unit' => array(
'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2',
),
'sebastian/code-unit' =>
array (
'pretty_version' => '1.0.8',
'version' => '1.0.8.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/code-unit',
'aliases' => array(),
'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/code-unit-reverse-lookup' => array(
'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120',
),
'sebastian/code-unit-reverse-lookup' =>
array (
'pretty_version' => '2.0.3',
'version' => '2.0.3.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup',
'aliases' => array(),
'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/comparator' => array(
'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5',
),
'sebastian/comparator' =>
array (
'pretty_version' => '4.0.6',
'version' => '4.0.6.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/comparator',
'aliases' => array(),
'reference' => '55f4261989e546dc112258c7a75935a81a7ce382',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/complexity' => array(
'reference' => '55f4261989e546dc112258c7a75935a81a7ce382',
),
'sebastian/complexity' =>
array (
'pretty_version' => '2.0.2',
'version' => '2.0.2.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/complexity',
'aliases' => array(),
'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/diff' => array(
'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88',
),
'sebastian/diff' =>
array (
'pretty_version' => '4.0.4',
'version' => '4.0.4.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/diff',
'aliases' => array(),
'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/environment' => array(
'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d',
),
'sebastian/environment' =>
array (
'pretty_version' => '5.1.4',
'version' => '5.1.4.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/environment',
'aliases' => array(),
'reference' => '1b5dff7bb151a4db11d49d90e5408e4e938270f7',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/exporter' => array(
'reference' => '1b5dff7bb151a4db11d49d90e5408e4e938270f7',
),
'sebastian/exporter' =>
array (
'pretty_version' => '4.0.4',
'version' => '4.0.4.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/exporter',
'aliases' => array(),
'reference' => '65e8b7db476c5dd267e65eea9cab77584d3cfff9',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/global-state' => array(
'reference' => '65e8b7db476c5dd267e65eea9cab77584d3cfff9',
),
'sebastian/global-state' =>
array (
'pretty_version' => '5.0.5',
'version' => '5.0.5.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/global-state',
'aliases' => array(),
'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/lines-of-code' => array(
'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2',
),
'sebastian/lines-of-code' =>
array (
'pretty_version' => '1.0.3',
'version' => '1.0.3.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/lines-of-code',
'aliases' => array(),
'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/object-enumerator' => array(
'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc',
),
'sebastian/object-enumerator' =>
array (
'pretty_version' => '4.0.4',
'version' => '4.0.4.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/object-enumerator',
'aliases' => array(),
'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/object-reflector' => array(
'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71',
),
'sebastian/object-reflector' =>
array (
'pretty_version' => '2.0.4',
'version' => '2.0.4.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/object-reflector',
'aliases' => array(),
'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/recursion-context' => array(
'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7',
),
'sebastian/recursion-context' =>
array (
'pretty_version' => '4.0.4',
'version' => '4.0.4.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/recursion-context',
'aliases' => array(),
'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/resource-operations' => array(
'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172',
),
'sebastian/resource-operations' =>
array (
'pretty_version' => '3.0.3',
'version' => '3.0.3.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/resource-operations',
'aliases' => array(),
'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/type' => array(
'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8',
),
'sebastian/type' =>
array (
'pretty_version' => '2.3.4',
'version' => '2.3.4.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/type',
'aliases' => array(),
'reference' => 'b8cd8a1c753c90bc1a0f5372170e3e489136f914',
'dev_requirement' => true,
'aliases' =>
array (
),
'sebastian/version' => array(
'reference' => 'b8cd8a1c753c90bc1a0f5372170e3e489136f914',
),
'sebastian/version' =>
array (
'pretty_version' => '3.0.2',
'version' => '3.0.2.0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/version',
'aliases' => array(),
'reference' => 'c6c1022351a901512170118436c764e473f6de8c',
'dev_requirement' => true,
'aliases' =>
array (
),
'spomky-labs/otphp' => array(
'reference' => 'c6c1022351a901512170118436c764e473f6de8c',
),
'spomky-labs/otphp' =>
array (
'pretty_version' => 'v10.0.3',
'version' => '10.0.3.0',
'type' => 'library',
'install_path' => __DIR__ . '/../spomky-labs/otphp',
'aliases' => array(),
'aliases' =>
array (
),
'reference' => '9784d9f7c790eed26e102d6c78f12c754036c366',
'dev_requirement' => false,
),
'thecodingmachine/safe' => array(
'pretty_version' => 'v2.2.1',
'version' => '2.2.1.0',
'type' => 'library',
'install_path' => __DIR__ . '/../thecodingmachine/safe',
'aliases' => array(),
'reference' => '2a8d758fd17763faf86e4aa798193e17b9fac38c',
'dev_requirement' => false,
'thecodingmachine/safe' =>
array (
'pretty_version' => 'v2.2.2',
'version' => '2.2.2.0',
'aliases' =>
array (
),
'theseer/tokenizer' => array(
'reference' => '440284f9592c9df402832452a6871a8b3c48d97e',
),
'theseer/tokenizer' =>
array (
'pretty_version' => '1.2.1',
'version' => '1.2.1.0',
'type' => 'library',
'install_path' => __DIR__ . '/../theseer/tokenizer',
'aliases' => array(),
'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e',
'dev_requirement' => true,
'aliases' =>
array (
),
'webmozart/assert' => array(
'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e',
),
'webmozart/assert' =>
array (
'pretty_version' => '1.11.0',
'version' => '1.11.0.0',
'type' => 'library',
'install_path' => __DIR__ . '/../webmozart/assert',
'aliases' => array(),
'aliases' =>
array (
),
'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991',
'dev_requirement' => true,
),
),
);

26
vendor/composer/platform_check.php vendored Normal file
View File

@ -0,0 +1,26 @@
<?php
// platform_check.php @generated by Composer
$issues = array();
if (!(PHP_VERSION_ID >= 80000)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.0". You are running ' . PHP_VERSION . '.';
}
if ($issues) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
} elseif (!headers_sent()) {
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
}
}
trigger_error(
'Composer detected issues in your platform: ' . implode(' ', $issues),
E_USER_ERROR
);
}

View File

@ -5,7 +5,7 @@
</p>
<p align="center">
<a href="https://github.com/phpstan/phpstan/actions"><img src="https://github.com/phpstan/phpstan/workflows/Build/badge.svg" alt="Build Status"></a>
<a href="https://github.com/phpstan/phpstan/actions"><img src="https://github.com/phpstan/phpstan/workflows/Tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/phpstan/phpstan"><img src="https://poser.pugx.org/phpstan/phpstan/v/stable" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/phpstan/phpstan/stats"><img src="https://poser.pugx.org/phpstan/phpstan/downloads" alt="Total Downloads"></a>
<a href="https://choosealicense.com/licenses/mit/"><img src="https://poser.pugx.org/phpstan/phpstan/license" alt="License"></a>
@ -26,13 +26,13 @@ can be checked before you run the actual line.
<a href="https://coders.thecodingmachine.com/phpstan"><img src="https://i.imgur.com/kQhNOTP.png" alt="TheCodingMachine" width="247" height="64"></a>
&nbsp;&nbsp;&nbsp;
<a href="https://packagist.com/?utm_source=phpstan&utm_medium=readme&utm_campaign=sponsorlogo"><img src="https://i.imgur.com/PmMC45f.png" alt="Private Packagist" width="326" height="64"></a>
<a href="https://packagist.com/?utm_source=phpstan&utm_medium=readme&utm_campaign=sponsorlogo"><img src="https://i.imgur.com/B2T63Do.png" alt="Private Packagist" width="283" height="64"></a>
<br>
<a href="https://careers.tuigroup.com/jobs/"><img src="https://i.imgur.com/uw5rAlR.png" alt="Musement" width="247" height="49"></a>
&nbsp;&nbsp;&nbsp;
<a href="https://blackfire.io/docs/introduction?utm_source=phpstan&utm_medium=github_readme&utm_campaign=logo"><img src="https://i.imgur.com/zR8rsqk.png" alt="Blackfire.io" width="254" height="64"></a>
<br>
<a href="https://www.intracto.com/"><img src="https://i.imgur.com/XRCDGZi.png" alt="Intracto" width="254" height="65"></a>
<a href="https://www.iodigital.com/"><img src="https://i.imgur.com/fJlw1n9.png" alt="iO" width="254" height="65"></a>
&nbsp;&nbsp;&nbsp;
<a href="https://jobs.ticketswap.com/"><img src="https://i.imgur.com/lhzcutK.png" alt="TicketSwap" width="269" height="64"></a>
<br>
@ -40,9 +40,9 @@ can be checked before you run the actual line.
&nbsp;&nbsp;&nbsp;
<a href="https://togetter.com/"><img src="https://i.imgur.com/x9n5cj3.png" alt="Togetter" width="283" height="64"></a>
<br>
<a href="https://join.rightcapital.com/?utm_source=phpstan&utm_medium=github&utm_campaign=sponsorship"><img src="https://i.imgur.com/EuIgI08.png" alt="RightCapital" width="283" height="64"></a>
<a href="https://join.rightcapital.com/?utm_source=phpstan&utm_medium=github&utm_campaign=sponsorship"><img src="https://i.imgur.com/1AhB5tW.png" alt="RightCapital" width="283" height="64"></a>
&nbsp;&nbsp;&nbsp;
<a href="https://www.contentkingapp.com/?ref=php-developer&utm_source=phpstan&utm_medium=referral&utm_campaign=sponsorship"><img src="https://i.imgur.com/0blm7ki.png" alt="ContentKing" width="283" height="64"></a>
<a href="https://www.contentkingapp.com/?ref=php-developer&utm_source=phpstan&utm_medium=referral&utm_campaign=sponsorship"><img src="https://i.imgur.com/HHhbPGN.png" alt="ContentKing" width="283" height="64"></a>
<br>
<a href="https://zol.fr?utm_source=phpstan"><img src="https://i.imgur.com/dzDgd4s.png" alt="ZOL" width="283" height="64"></a>
&nbsp;&nbsp;&nbsp;
@ -53,6 +53,14 @@ can be checked before you run the actual line.
<a href="https://craftcms.com/"><img src="https://i.imgur.com/xJWThke.png" alt="Craft CMS" width="283" height="64"></a>
<br>
<a href="https://www.worksome.com/"><img src="https://i.imgur.com/TQKSwOl.png" alt="Worksome" width="283" height="64"></a>
&nbsp;&nbsp;&nbsp;
<a href="https://www.campoint.net/"><img src="https://i.imgur.com/fR6eMUm.png" alt="campoint AG" width="283" height="64"></a>
<br>
<a href="https://www.crisp.nl/"><img src="https://i.imgur.com/jRJyPve.png" alt="Crisp.nl" width="283" height="64"></a>
&nbsp;&nbsp;&nbsp;
<a href="https://inviqa.com/"><img src="https://i.imgur.com/G99rj45.png" alt="Inviqa" width="254" height="65"></a>
<br>
<a href="https://www.psyonix.com/"><img src="https://i.imgur.com/p8svxQZ.png" alt="Psyonix" width="254" height="65"></a>
[**You can now sponsor my open-source work on PHPStan through GitHub Sponsors.**](https://github.com/sponsors/ondrejmirtes)
@ -69,6 +77,7 @@ All the documentation lives on the [phpstan.org website](https://phpstan.org/):
* [PHPDocs Basics](https://phpstan.org/writing-php-code/phpdocs-basics) & [PHPDoc Types](https://phpstan.org/writing-php-code/phpdoc-types)
* [Extension Library](https://phpstan.org/user-guide/extension-library)
* [Developing Extensions](https://phpstan.org/developing-extensions/extension-types)
* [API Reference](https://apiref.phpstan.org/)
## PHPStan Pro

View File

@ -3,7 +3,7 @@
"description": "PHPStan - PHP Static Analysis Tool",
"license": ["MIT"],
"require": {
"php": "^7.1|^8.0"
"php": "^7.2|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
@ -12,11 +12,6 @@
"phpstan",
"phpstan.phar"
],
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"files": ["bootstrap.php"]
}

Binary file not shown.

View File

@ -1,16 +1,16 @@
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEE0yaA1ZV9xxFr4pwUzxoQjQ565yAFAmGKbGQACgkQzxoQjQ56
5yAy7BAAgT9+V81RuOMz6F16uqm4gXH1ebioWokEvVb6ZR2fk7p3/m14STmmRkwe
MIkxzWKtx/wSC6VafqAtkBPNxpo2j5QU0pmfMAvkPHh79d2lWmUaJmF71I/DCNnh
pcZNJLe5x+YTDKU6NnwMlyZEvdaWmyJ2MCf2apBZIJ7axefEJRVVin2pshhXwbtN
dHhrT9yFYe/vqOkOLtGDWw+yT1I6he7IpoYZUTyO9b7eadC0ga6Bet7jibNL8JBE
cGcB2MFg9bvif0PgIOio0jQXAWjf0ZBXPvoOwTRCqq/UOPTL8SRtiflAFiFOAzk/
FRQVC0+26NsGx7R8kS5FZNOHYTIElY1ElyzFk8HWgqrYIvzDNLtkJ68178rDJ29f
GyAax4P+gN13biyXQycQHhXDfHN1UytopldiRkitXVFGq92sz6BFgQDLF9yxQOm1
iL5oxWSVf6rM8AOc3DV9Aa1kCpG6FrZPJ66NBgJLzTpKARzt7CM+M8VQNA/KnHB3
8Mt0WmAeRORSnBWQksOlnA4VUkxWDGkZGVBWMRist7gghfG7n7HxTAUAk1oo7j2b
/gTwbeOjv/330uZG31e+hCcaj/EcocHvglegWCPMmIhpXqn25TC+87QkGt2wb6z6
dpzTdy3Pimr5BK2YrN1+Le33CYeHKlc+6XL34BEVebAQ/A9OB/M=
=k3NZ
iQIzBAABCgAdFiEE0yaA1ZV9xxFr4pwUzxoQjQ565yAFAmLX0XwACgkQzxoQjQ56
5yAmDw/+KPoaY+vsYXrYjbNcYmXyH+9ca8Yl1WkgqMOAAiojQBAdN+PIeXqdM4P1
ODJq7SGPqhR5j9dK3k4wxvTkmAVlFHWCbOQS0eCueoV2s0w0Sg9xkut7zTMwwBTp
I+0TbU9W7DdnDk6k6xoNCNhT8OYpMElmwhS9nChoY2+cwdWJNZ0Lr5JeXwvb5R7W
YnHUqO/zTIAjwJNdKwb27J9szwL3GQ4nB9gSoKXCFQTIONszfMYNwboy3VlD8m/F
irh9ZZeZsMlCpEO9Rsqx4QyOvbLy0D2jEOKNYzXPQea9dx9gQvDiWJrVETsQBwkc
iWJ/HJVhs3ng7iyUfMr8VAPn7rf+3fSqYeQUs5Z5/ubqABF2ZI9/4DIPGsXtqH7q
b5OTOvSucvRpsxudnJElKWhkCjZUyjYzBqGdZ6erCh+GTiM4uFNB/en/QObfHmP2
z4D41Dk9peLxstqlrwoLL0sJCHR4fQZFvPKrQ6sKlTKliu1zBc0HcEqq3BFalKF+
XO2PT1QVNXx/9IqOruKm+M5siY63VKDwE/DXJZZTUPz7GN/Cr9j5Jz3pjq8jL0CR
e4D+sEu7xXzlJa7MFqg2odZhLTRYuM/DHZCj3cOyQGlYUQ+tZMGsAiix9JyO7XhB
1jzEMugtAglPAsmHr0HR/+oz+YDgwQEmQA4VO4l0swCNmjzLITA=
=LM6h
-----END PGP SIGNATURE-----

View File

@ -4,6 +4,79 @@ namespace Safe;
use Safe\Exceptions\ArrayException;
/**
* array_replace_recursive replaces the values of
* array with the same values from all the following
* arrays. If a key from the first array exists in the second array, its value
* will be replaced by the value from the second array. If the key exists in the
* second array, and not the first, it will be created in the first array.
* If a key only exists in the first array, it will be left as is.
* If several arrays are passed for replacement, they will be processed
* in order, the later array overwriting the previous values.
*
* array_replace_recursive is recursive : it will recurse into
* arrays and apply the same process to the inner value.
*
* When the value in the first array is scalar, it will be replaced
* by the value in the second array, may it be scalar or array.
* When the value in the first array and the second array
* are both arrays, array_replace_recursive will replace
* their respective value recursively.
*
* @param array $array The array in which elements are replaced.
* @param array $replacements Arrays from which elements will be extracted.
* @return array Returns an array.
* @throws ArrayException
*
*/
function array_replace_recursive(array $array, array ...$replacements): array
{
error_clear_last();
if ($replacements !== []) {
$result = \array_replace_recursive($array, ...$replacements);
} else {
$result = \array_replace_recursive($array);
}
if ($result === null) {
throw ArrayException::createFromPhpError();
}
return $result;
}
/**
* array_replace replaces the values of
* array with values having the same keys in each of the following
* arrays. If a key from the first array exists in the second array, its value
* will be replaced by the value from the second array. If the key exists in the
* second array, and not the first, it will be created in the first array.
* If a key only exists in the first array, it will be left as is.
* If several arrays are passed for replacement, they will be processed
* in order, the later arrays overwriting the previous values.
*
* array_replace is not recursive : it will replace
* values in the first array by whatever type is in the second array.
*
* @param array $array The array in which elements are replaced.
* @param array $replacements Arrays from which elements will be extracted.
* Values from later arrays overwrite the previous values.
* @return array Returns an array.
* @throws ArrayException
*
*/
function array_replace(array $array, array ...$replacements): array
{
error_clear_last();
if ($replacements !== []) {
$result = \array_replace($array, ...$replacements);
} else {
$result = \array_replace($array);
}
if ($result === null) {
throw ArrayException::createFromPhpError();
}
return $result;
}
/**
* array_flip returns an array in flip
* order, i.e. keys from array become values and values

View File

@ -12,6 +12,8 @@ return [
'apc_load_constants',
'apc_sma_info',
'arsort',
'array_replace',
'array_replace_recursive',
'array_combine',
'array_flip',
'asort',

View File

@ -4,81 +4,6 @@ namespace Safe;
use Safe\Exceptions\ArrayException;
/**
* array_replace_recursive replaces the values of
* array with the same values from all the following
* arrays. If a key from the first array exists in the second array, its value
* will be replaced by the value from the second array. If the key exists in the
* second array, and not the first, it will be created in the first array.
* If a key only exists in the first array, it will be left as is.
* If several arrays are passed for replacement, they will be processed
* in order, the later array overwriting the previous values.
*
* array_replace_recursive is recursive : it will recurse into
* arrays and apply the same process to the inner value.
*
* When the value in the first array is scalar, it will be replaced
* by the value in the second array, may it be scalar or array.
* When the value in the first array and the second array
* are both arrays, array_replace_recursive will replace
* their respective value recursively.
*
* @param array $array The array in which elements are replaced.
* @param array $replacements Arrays from which elements will be extracted.
* @return array Returns an array.
* @throws ArrayException
*
*/
function array_replace_recursive(array $array, array ...$replacements): array
{
error_clear_last();
if ($replacements !== []) {
$result = \array_replace_recursive($array, ...$replacements);
} else {
$result = \array_replace_recursive($array);
}
if ($result === null) {
throw ArrayException::createFromPhpError();
}
return $result;
}
/**
* array_replace replaces the values of
* array with values having the same keys in each of the following
* arrays. If a key from the first array exists in the second array, its value
* will be replaced by the value from the second array. If the key exists in the
* second array, and not the first, it will be created in the first array.
* If a key only exists in the first array, it will be left as is.
* If several arrays are passed for replacement, they will be processed
* in order, the later arrays overwriting the previous values.
*
* array_replace is not recursive : it will replace
* values in the first array by whatever type is in the second array.
*
* @param array $array The array in which elements are replaced.
* @param array $replacements Arrays from which elements will be extracted.
* Values from later arrays overwrite the previous values.
* @return array Returns an array.
* @throws ArrayException
*
*/
function array_replace(array $array, array ...$replacements): array
{
error_clear_last();
if ($replacements !== []) {
$result = \array_replace($array, ...$replacements);
} else {
$result = \array_replace($array);
}
if ($result === null) {
throw ArrayException::createFromPhpError();
}
return $result;
}
/**
* Applies the user-defined callback function to each
* element of the array. This function will recurse

View File

@ -18,7 +18,7 @@ function curl_copy_handle(\CurlHandle $handle): \CurlHandle
error_clear_last();
$result = \curl_copy_handle($handle);
if ($result === false) {
throw CurlException::createFromPhpError();
throw CurlException::createFromPhpError($handle);
}
return $result;
}
@ -39,7 +39,7 @@ function curl_escape(\CurlHandle $handle, string $string): string
error_clear_last();
$result = \curl_escape($handle, $string);
if ($result === false) {
throw CurlException::createFromPhpError();
throw CurlException::createFromPhpError($handle);
}
return $result;
}
@ -64,7 +64,7 @@ function curl_exec(\CurlHandle $handle)
error_clear_last();
$result = \curl_exec($handle);
if ($result === false) {
throw CurlException::createFromPhpError();
throw CurlException::createFromPhpError($handle);
}
return $result;
}
@ -541,7 +541,7 @@ function curl_getinfo(\CurlHandle $handle, int $option = null)
$result = \curl_getinfo($handle);
}
if ($result === false) {
throw CurlException::createFromPhpError();
throw CurlException::createFromPhpError($handle);
}
return $result;
}
@ -627,7 +627,7 @@ function curl_multi_info_read(\CurlMultiHandle $multi_handle, ?int &$queued_mess
error_clear_last();
$result = \curl_multi_info_read($multi_handle, $queued_messages);
if ($result === false) {
throw CurlException::createFromPhpError();
throw CurlException::createFromPhpError($multi_handle);
}
return $result;
}
@ -791,7 +791,7 @@ function curl_multi_setopt(\CurlMultiHandle $multi_handle, int $option, $value):
error_clear_last();
$result = \curl_multi_setopt($multi_handle, $option, $value);
if ($result === false) {
throw CurlException::createFromPhpError();
throw CurlException::createFromPhpError($multi_handle);
}
}
@ -1284,6 +1284,18 @@ function curl_multi_setopt(\CurlMultiHandle $multi_handle, int $option, $value):
*
*
*
* CURLOPT_SAFE_UPLOAD
*
* Always TRUE, what disables support for the @ prefix for
* uploading files in CURLOPT_POSTFIELDS, which
* means that values starting with @ can be safely
* passed as fields. CURLFile may be used for
* uploads instead.
*
*
*
*
*
* CURLOPT_SUPPRESS_CONNECT_HEADERS
*
* TRUE to suppress proxy CONNECT response headers from the user callback functions
@ -2576,7 +2588,7 @@ function curl_multi_setopt(\CurlMultiHandle $multi_handle, int $option, $value):
*
* CURLOPT_PROXY_TLSAUTH_USERNAME
*
* Tusername to use for the HTTPS proxy TLS authentication method specified with the
* The username to use for the HTTPS proxy TLS authentication method specified with the
* CURLOPT_PROXY_TLSAUTH_TYPE option. Requires that the
* CURLOPT_PROXY_TLSAUTH_PASSWORD option to also be set.
*
@ -3142,7 +3154,7 @@ function curl_setopt(\CurlHandle $handle, int $option, $value): void
error_clear_last();
$result = \curl_setopt($handle, $option, $value);
if ($result === false) {
throw CurlException::createFromPhpError();
throw CurlException::createFromPhpError($handle);
}
}
@ -3161,7 +3173,7 @@ function curl_share_errno(\CurlShareHandle $share_handle): int
error_clear_last();
$result = \curl_share_errno($share_handle);
if ($result === false) {
throw CurlException::createFromPhpError();
throw CurlException::createFromPhpError($share_handle);
}
return $result;
}
@ -3238,7 +3250,7 @@ function curl_share_setopt(\CurlShareHandle $share_handle, int $option, $value):
error_clear_last();
$result = \curl_share_setopt($share_handle, $option, $value);
if ($result === false) {
throw CurlException::createFromPhpError();
throw CurlException::createFromPhpError($share_handle);
}
}
@ -3258,7 +3270,7 @@ function curl_unescape(\CurlHandle $handle, string $string): string
error_clear_last();
$result = \curl_unescape($handle, $string);
if ($result === false) {
throw CurlException::createFromPhpError();
throw CurlException::createFromPhpError($handle);
}
return $result;
}

View File

@ -85,10 +85,10 @@ function passthru(string $command, ?int &$result_code = null): void
* @param int $priority The new priority value, the value of this may differ on platforms.
*
* On Unix, a low value, such as -20 means high priority
* wheras a positive value have a lower priority.
* whereas positive values have a lower priority.
*
* For Windows the priority parameter have the
* following meanings:
* For Windows the priority parameter has the
* following meaning:
* @throws ExecException
*
*/

View File

@ -1240,6 +1240,13 @@ function lstat(string $filename): array
* Attempts to create the directory specified by directory.
*
* @param string $directory The directory path.
* A URL can be used as a
* filename with this function if the fopen wrappers have been enabled.
* See fopen for more details on how to specify the
* filename. See the for links to information
* about what abilities the various wrappers have, notes on their usage,
* and information on any predefined variables they may
* provide.
* @param int $permissions The permissions are 0777 by default, which means the widest possible
* access. For more information on permissions, read the details
* on the chmod page.
@ -1250,8 +1257,8 @@ function lstat(string $filename): array
* which means it should have a leading zero. The permissions is also modified
* by the current umask, which you can change using
* umask.
* @param bool $recursive Allows the creation of nested directories specified in the
* directory.
* @param bool $recursive If TRUE, then any parent directories to the directory specified will
* also be created, with the same permissions.
* @param resource $context A context stream
* resource.
* @throws FilesystemException

View File

@ -14,8 +14,6 @@ return [
'apcu_inc',
'apcu_sma_info',
'apc_fetch',
'array_replace',
'array_replace_recursive',
'array_walk_recursive',
'assert_options',
'base64_decode',

View File

@ -6,7 +6,12 @@ use Safe\Exceptions\JsonException;
/**
* Returns a string containing the JSON representation of the supplied
* value.
* value. If the parameter is an array or object,
* it will be serialized recursively.
*
* If a value to be serialized is an object, then by default only publicly visible
* properties will be included. Alternatively, a class may implement JsonSerializable
* to control how its values are serialized to JSON.
*
* The encoding is affected by the supplied flags
* and additionally the encoding of float values depends on the value of

View File

@ -239,36 +239,36 @@ function ldap_exop_whoami($ldap)
/**
* Performs an extended operation on the specified link with
* reqoid the OID of the operation and
* reqdata the data.
* Performs an extended operation on the specified ldap with
* request_oid the OID of the operation and
* request_data the data.
*
* @param resource $ldap An LDAP\Connection instance, returned by ldap_connect.
* @param string $reqoid The extended operation request OID. You may use one of LDAP_EXOP_START_TLS, LDAP_EXOP_MODIFY_PASSWD, LDAP_EXOP_REFRESH, LDAP_EXOP_WHO_AM_I, LDAP_EXOP_TURN, or a string with the OID of the operation you want to send.
* @param string $reqdata The extended operation request data. May be NULL for some operations like LDAP_EXOP_WHO_AM_I, may also need to be BER encoded.
* @param array|null $serverctrls Array of LDAP Controls to send with the request.
* @param string|null $retdata Will be filled with the extended operation response data if provided.
* @param string $request_oid The extended operation request OID. You may use one of LDAP_EXOP_START_TLS, LDAP_EXOP_MODIFY_PASSWD, LDAP_EXOP_REFRESH, LDAP_EXOP_WHO_AM_I, LDAP_EXOP_TURN, or a string with the OID of the operation you want to send.
* @param string $request_data The extended operation request data. May be NULL for some operations like LDAP_EXOP_WHO_AM_I, may also need to be BER encoded.
* @param array|null $controls Array of LDAP Controls to send with the request.
* @param string|null $response_data Will be filled with the extended operation response data if provided.
* If not provided you may use ldap_parse_exop on the result object
* later to get this data.
* @param string|null $retoid Will be filled with the response OID if provided, usually equal to the request OID.
* @return resource|bool When used with retdata, returns TRUE on success.
* When used without retdata, returns a result identifier.
* @param string|null $response_oid Will be filled with the response OID if provided, usually equal to the request OID.
* @return resource|bool When used with response_data, returns TRUE on success.
* When used without response_data, returns a result identifier.
* @throws LdapException
*
*/
function ldap_exop($ldap, string $reqoid, string $reqdata = null, ?array $serverctrls = null, ?string &$retdata = null, ?string &$retoid = null)
function ldap_exop($ldap, string $request_oid, string $request_data = null, ?array $controls = null, ?string &$response_data = null, ?string &$response_oid = null)
{
error_clear_last();
if ($retoid !== null) {
$result = \ldap_exop($ldap, $reqoid, $reqdata, $serverctrls, $retdata, $retoid);
} elseif ($retdata !== null) {
$result = \ldap_exop($ldap, $reqoid, $reqdata, $serverctrls, $retdata);
} elseif ($serverctrls !== null) {
$result = \ldap_exop($ldap, $reqoid, $reqdata, $serverctrls);
} elseif ($reqdata !== null) {
$result = \ldap_exop($ldap, $reqoid, $reqdata);
if ($response_oid !== null) {
$result = \ldap_exop($ldap, $request_oid, $request_data, $controls, $response_data, $response_oid);
} elseif ($response_data !== null) {
$result = \ldap_exop($ldap, $request_oid, $request_data, $controls, $response_data);
} elseif ($controls !== null) {
$result = \ldap_exop($ldap, $request_oid, $request_data, $controls);
} elseif ($request_data !== null) {
$result = \ldap_exop($ldap, $request_oid, $request_data);
} else {
$result = \ldap_exop($ldap, $reqoid);
$result = \ldap_exop($ldap, $request_oid);
}
if ($result === false) {
throw LdapException::createFromPhpError();

View File

@ -11,8 +11,9 @@ use Safe\Exceptions\PcntlException;
* man page for specific details.
*
* @param int $process_id If NULL, the process id of the current process is used.
* @param int $mode One of PRIO_PGRP, PRIO_USER
* or PRIO_PROCESS.
* @param int $mode One of PRIO_PGRP, PRIO_USER,
* PRIO_PROCESS,
* PRIO_DARWIN_BG or PRIO_DARWIN_THREAD.
* @return int pcntl_getpriority returns the priority of the process. A lower numerical value causes more favorable
* scheduling.
* @throws PcntlException
@ -46,8 +47,9 @@ function pcntl_getpriority(int $process_id = null, int $mode = PRIO_PROCESS): in
* system types and kernel versions, please see your system's setpriority(2)
* man page for specific details.
* @param int $process_id If NULL, the process id of the current process is used.
* @param int $mode One of PRIO_PGRP, PRIO_USER
* or PRIO_PROCESS.
* @param int $mode One of PRIO_PGRP, PRIO_USER,
* PRIO_PROCESS,
* PRIO_DARWIN_BG or PRIO_DARWIN_THREAD.
* @throws PcntlException
*
*/

View File

@ -8,8 +8,8 @@ class CurlException extends \Exception implements SafeExceptionInterface
/**
* @param \CurlHandle $ch
*/
public static function createFromPhpError($ch): self
public static function createFromPhpError($ch = null): self
{
return new self(\curl_error($ch), \curl_errno($ch));
return new self($ch ? \curl_error($ch) : '', $ch ? \curl_errno($ch) : 0);
}
}

View File

@ -24,8 +24,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
'apcu_inc' => 'Safe\apcu_inc',
'apcu_sma_info' => 'Safe\apcu_sma_info',
'apc_fetch' => 'Safe\apc_fetch',
'array_replace' => 'Safe\array_replace',
'array_replace_recursive' => 'Safe\array_replace_recursive',
'array_walk_recursive' => 'Safe\array_walk_recursive',
'assert_options' => 'Safe\assert_options',
'base64_decode' => 'Safe\base64_decode',