Cleanup old Composer dependencies
This commit is contained in:
@@ -49,17 +49,8 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"require-dev" : {
|
"require-dev" : {
|
||||||
"phpunit/php-code-coverage": "^6",
|
|
||||||
"phpunit/php-token-stream": "^3.1",
|
|
||||||
"doctrine/instantiator": "^1.1",
|
|
||||||
"phpdocumentor/reflection-docblock": "5.2.2",
|
|
||||||
"symfony/debug": "4.4.14",
|
|
||||||
"symfony/yaml": "4.4.14",
|
|
||||||
"symfony/finder": "3.4.8",
|
|
||||||
"symfony/stopwatch" : "4.4.14",
|
"symfony/stopwatch" : "4.4.14",
|
||||||
"myclabs/deep-copy": "1.10.1",
|
|
||||||
"phpunit/phpunit" : "^7",
|
"phpunit/phpunit" : "^7",
|
||||||
"phpunit/phpunit-selenium": "^7",
|
|
||||||
"roave/security-advisories": "dev-master"
|
"roave/security-advisories": "dev-master"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
272
composer.lock
generated
272
composer.lock
generated
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "fdab24e914b0c8fc62c651f4fd752618",
|
"content-hash": "756165b7be42e55e964bdb90544c9b0d",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "christian-riesen/base32",
|
"name": "christian-riesen/base32",
|
||||||
@@ -722,25 +722,25 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/finder",
|
"name": "symfony/finder",
|
||||||
"version": "v3.4.8",
|
"version": "v5.1.7",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/finder.git",
|
"url": "https://github.com/symfony/finder.git",
|
||||||
"reference": "bd14efe8b1fabc4de82bf50dce62f05f9a102433"
|
"reference": "2c3ba7ad6884e6c4451ce2340e2dc23f6fa3e0d8"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/finder/zipball/bd14efe8b1fabc4de82bf50dce62f05f9a102433",
|
"url": "https://api.github.com/repos/symfony/finder/zipball/2c3ba7ad6884e6c4451ce2340e2dc23f6fa3e0d8",
|
||||||
"reference": "bd14efe8b1fabc4de82bf50dce62f05f9a102433",
|
"reference": "2c3ba7ad6884e6c4451ce2340e2dc23f6fa3e0d8",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.5.9|>=7.0.8"
|
"php": ">=7.2.5"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.4-dev"
|
"dev-master": "5.1-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -767,7 +767,7 @@
|
|||||||
],
|
],
|
||||||
"description": "Symfony Finder Component",
|
"description": "Symfony Finder Component",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2018-04-04T05:07:11+00:00"
|
"time": "2020-09-02T16:23:27+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-mbstring",
|
"name": "symfony/polyfill-mbstring",
|
||||||
@@ -1586,80 +1586,6 @@
|
|||||||
],
|
],
|
||||||
"time": "2020-01-08T08:45:45+00:00"
|
"time": "2020-01-08T08:45:45+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "phpunit/phpunit-selenium",
|
|
||||||
"version": "7.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/giorgiosironi/phpunit-selenium.git",
|
|
||||||
"reference": "3129be3c3a90bf46ef301817ea67c2f525451963"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/giorgiosironi/phpunit-selenium/zipball/3129be3c3a90bf46ef301817ea67c2f525451963",
|
|
||||||
"reference": "3129be3c3a90bf46ef301817ea67c2f525451963",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"ext-curl": "*",
|
|
||||||
"php": ">=7.1",
|
|
||||||
"phpunit/phpunit": ">=7.0,<8.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phing/phing": "2.*"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"PHPUnit/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"include-path": [
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Giorgio Sironi",
|
|
||||||
"email": "info@giorgiosironi.com",
|
|
||||||
"role": "developer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Ivan Kurnosov",
|
|
||||||
"email": "zerkms@zerkms.com",
|
|
||||||
"role": "developer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Sebastian Bergmann",
|
|
||||||
"email": "sb@sebastian-bergmann.de",
|
|
||||||
"role": "original developer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Paul Briton",
|
|
||||||
"role": "developer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Patrik Štrba",
|
|
||||||
"role": "developer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Petr Kotek",
|
|
||||||
"role": "developer"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Selenium Server integration for PHPUnit",
|
|
||||||
"homepage": "http://www.phpunit.de/",
|
|
||||||
"keywords": [
|
|
||||||
"phpunit",
|
|
||||||
"selenium",
|
|
||||||
"testing",
|
|
||||||
"xunit"
|
|
||||||
],
|
|
||||||
"time": "2019-07-02T20:42:44+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "roave/security-advisories",
|
"name": "roave/security-advisories",
|
||||||
"version": "dev-master",
|
"version": "dev-master",
|
||||||
@@ -2523,63 +2449,6 @@
|
|||||||
"homepage": "https://github.com/sebastianbergmann/version",
|
"homepage": "https://github.com/sebastianbergmann/version",
|
||||||
"time": "2016-10-03T07:35:21+00:00"
|
"time": "2016-10-03T07:35:21+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "symfony/debug",
|
|
||||||
"version": "v4.4.14",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/debug.git",
|
|
||||||
"reference": "726b85e69342e767d60e3853b98559a68ff74183"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/debug/zipball/726b85e69342e767d60e3853b98559a68ff74183",
|
|
||||||
"reference": "726b85e69342e767d60e3853b98559a68ff74183",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.1.3",
|
|
||||||
"psr/log": "~1.0",
|
|
||||||
"symfony/polyfill-php80": "^1.15"
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
"symfony/http-kernel": "<3.4"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"symfony/http-kernel": "^3.4|^4.0|^5.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "4.4-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Component\\Debug\\": ""
|
|
||||||
},
|
|
||||||
"exclude-from-classmap": [
|
|
||||||
"/Tests/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony Debug Component",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"time": "2020-09-09T05:20:36+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-ctype",
|
"name": "symfony/polyfill-ctype",
|
||||||
"version": "v1.18.1",
|
"version": "v1.18.1",
|
||||||
@@ -2642,72 +2511,6 @@
|
|||||||
],
|
],
|
||||||
"time": "2020-07-14T12:35:20+00:00"
|
"time": "2020-07-14T12:35:20+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-php80",
|
|
||||||
"version": "v1.18.1",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/polyfill-php80.git",
|
|
||||||
"reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/d87d5766cbf48d72388a9f6b85f280c8ad51f981",
|
|
||||||
"reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.0.8"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.18-dev"
|
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/polyfill",
|
|
||||||
"url": "https://github.com/symfony/polyfill"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Php80\\": ""
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"bootstrap.php"
|
|
||||||
],
|
|
||||||
"classmap": [
|
|
||||||
"Resources/stubs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Ion Bazan",
|
|
||||||
"email": "ion.bazan@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Nicolas Grekas",
|
|
||||||
"email": "p@tchwork.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"compatibility",
|
|
||||||
"polyfill",
|
|
||||||
"portable",
|
|
||||||
"shim"
|
|
||||||
],
|
|
||||||
"time": "2020-07-14T12:35:20+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "symfony/stopwatch",
|
"name": "symfony/stopwatch",
|
||||||
"version": "v4.4.14",
|
"version": "v4.4.14",
|
||||||
@@ -2758,65 +2561,6 @@
|
|||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2020-09-02T16:08:58+00:00"
|
"time": "2020-09-02T16:08:58+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "symfony/yaml",
|
|
||||||
"version": "v4.4.14",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/yaml.git",
|
|
||||||
"reference": "c7885964b1eceb70b0981556d0a9b01d2d97c8d1"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/c7885964b1eceb70b0981556d0a9b01d2d97c8d1",
|
|
||||||
"reference": "c7885964b1eceb70b0981556d0a9b01d2d97c8d1",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.1.3",
|
|
||||||
"symfony/polyfill-ctype": "~1.8"
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
"symfony/console": "<3.4"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"symfony/console": "^3.4|^4.0|^5.0"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"symfony/console": "For validating YAML files using the lint command"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "4.4-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Component\\Yaml\\": ""
|
|
||||||
},
|
|
||||||
"exclude-from-classmap": [
|
|
||||||
"/Tests/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony Yaml Component",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"time": "2020-09-27T03:36:23+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "theseer/tokenizer",
|
"name": "theseer/tokenizer",
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
|
|||||||
4
vendor/composer/autoload_classmap.php
vendored
4
vendor/composer/autoload_classmap.php
vendored
@@ -938,8 +938,9 @@ return array(
|
|||||||
'Symfony\\Component\\Finder\\Comparator\\DateComparator' => $vendorDir . '/symfony/finder/Comparator/DateComparator.php',
|
'Symfony\\Component\\Finder\\Comparator\\DateComparator' => $vendorDir . '/symfony/finder/Comparator/DateComparator.php',
|
||||||
'Symfony\\Component\\Finder\\Comparator\\NumberComparator' => $vendorDir . '/symfony/finder/Comparator/NumberComparator.php',
|
'Symfony\\Component\\Finder\\Comparator\\NumberComparator' => $vendorDir . '/symfony/finder/Comparator/NumberComparator.php',
|
||||||
'Symfony\\Component\\Finder\\Exception\\AccessDeniedException' => $vendorDir . '/symfony/finder/Exception/AccessDeniedException.php',
|
'Symfony\\Component\\Finder\\Exception\\AccessDeniedException' => $vendorDir . '/symfony/finder/Exception/AccessDeniedException.php',
|
||||||
'Symfony\\Component\\Finder\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/finder/Exception/ExceptionInterface.php',
|
'Symfony\\Component\\Finder\\Exception\\DirectoryNotFoundException' => $vendorDir . '/symfony/finder/Exception/DirectoryNotFoundException.php',
|
||||||
'Symfony\\Component\\Finder\\Finder' => $vendorDir . '/symfony/finder/Finder.php',
|
'Symfony\\Component\\Finder\\Finder' => $vendorDir . '/symfony/finder/Finder.php',
|
||||||
|
'Symfony\\Component\\Finder\\Gitignore' => $vendorDir . '/symfony/finder/Gitignore.php',
|
||||||
'Symfony\\Component\\Finder\\Glob' => $vendorDir . '/symfony/finder/Glob.php',
|
'Symfony\\Component\\Finder\\Glob' => $vendorDir . '/symfony/finder/Glob.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\CustomFilterIterator' => $vendorDir . '/symfony/finder/Iterator/CustomFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\CustomFilterIterator' => $vendorDir . '/symfony/finder/Iterator/CustomFilterIterator.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\DateRangeFilterIterator' => $vendorDir . '/symfony/finder/Iterator/DateRangeFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\DateRangeFilterIterator' => $vendorDir . '/symfony/finder/Iterator/DateRangeFilterIterator.php',
|
||||||
@@ -948,7 +949,6 @@ return array(
|
|||||||
'Symfony\\Component\\Finder\\Iterator\\FileTypeFilterIterator' => $vendorDir . '/symfony/finder/Iterator/FileTypeFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\FileTypeFilterIterator' => $vendorDir . '/symfony/finder/Iterator/FileTypeFilterIterator.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\FilecontentFilterIterator' => $vendorDir . '/symfony/finder/Iterator/FilecontentFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\FilecontentFilterIterator' => $vendorDir . '/symfony/finder/Iterator/FilecontentFilterIterator.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\FilenameFilterIterator' => $vendorDir . '/symfony/finder/Iterator/FilenameFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\FilenameFilterIterator' => $vendorDir . '/symfony/finder/Iterator/FilenameFilterIterator.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\FilterIterator' => $vendorDir . '/symfony/finder/Iterator/FilterIterator.php',
|
|
||||||
'Symfony\\Component\\Finder\\Iterator\\MultiplePcreFilterIterator' => $vendorDir . '/symfony/finder/Iterator/MultiplePcreFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\MultiplePcreFilterIterator' => $vendorDir . '/symfony/finder/Iterator/MultiplePcreFilterIterator.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\PathFilterIterator' => $vendorDir . '/symfony/finder/Iterator/PathFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\PathFilterIterator' => $vendorDir . '/symfony/finder/Iterator/PathFilterIterator.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\RecursiveDirectoryIterator' => $vendorDir . '/symfony/finder/Iterator/RecursiveDirectoryIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\RecursiveDirectoryIterator' => $vendorDir . '/symfony/finder/Iterator/RecursiveDirectoryIterator.php',
|
||||||
|
|||||||
4
vendor/composer/autoload_static.php
vendored
4
vendor/composer/autoload_static.php
vendored
@@ -1054,8 +1054,9 @@ class ComposerStaticInit80f59a55e693f3d5493bcaaa968d1851
|
|||||||
'Symfony\\Component\\Finder\\Comparator\\DateComparator' => __DIR__ . '/..' . '/symfony/finder/Comparator/DateComparator.php',
|
'Symfony\\Component\\Finder\\Comparator\\DateComparator' => __DIR__ . '/..' . '/symfony/finder/Comparator/DateComparator.php',
|
||||||
'Symfony\\Component\\Finder\\Comparator\\NumberComparator' => __DIR__ . '/..' . '/symfony/finder/Comparator/NumberComparator.php',
|
'Symfony\\Component\\Finder\\Comparator\\NumberComparator' => __DIR__ . '/..' . '/symfony/finder/Comparator/NumberComparator.php',
|
||||||
'Symfony\\Component\\Finder\\Exception\\AccessDeniedException' => __DIR__ . '/..' . '/symfony/finder/Exception/AccessDeniedException.php',
|
'Symfony\\Component\\Finder\\Exception\\AccessDeniedException' => __DIR__ . '/..' . '/symfony/finder/Exception/AccessDeniedException.php',
|
||||||
'Symfony\\Component\\Finder\\Exception\\ExceptionInterface' => __DIR__ . '/..' . '/symfony/finder/Exception/ExceptionInterface.php',
|
'Symfony\\Component\\Finder\\Exception\\DirectoryNotFoundException' => __DIR__ . '/..' . '/symfony/finder/Exception/DirectoryNotFoundException.php',
|
||||||
'Symfony\\Component\\Finder\\Finder' => __DIR__ . '/..' . '/symfony/finder/Finder.php',
|
'Symfony\\Component\\Finder\\Finder' => __DIR__ . '/..' . '/symfony/finder/Finder.php',
|
||||||
|
'Symfony\\Component\\Finder\\Gitignore' => __DIR__ . '/..' . '/symfony/finder/Gitignore.php',
|
||||||
'Symfony\\Component\\Finder\\Glob' => __DIR__ . '/..' . '/symfony/finder/Glob.php',
|
'Symfony\\Component\\Finder\\Glob' => __DIR__ . '/..' . '/symfony/finder/Glob.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\CustomFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/CustomFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\CustomFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/CustomFilterIterator.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\DateRangeFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/DateRangeFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\DateRangeFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/DateRangeFilterIterator.php',
|
||||||
@@ -1064,7 +1065,6 @@ class ComposerStaticInit80f59a55e693f3d5493bcaaa968d1851
|
|||||||
'Symfony\\Component\\Finder\\Iterator\\FileTypeFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/FileTypeFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\FileTypeFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/FileTypeFilterIterator.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\FilecontentFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/FilecontentFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\FilecontentFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/FilecontentFilterIterator.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\FilenameFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/FilenameFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\FilenameFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/FilenameFilterIterator.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\FilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/FilterIterator.php',
|
|
||||||
'Symfony\\Component\\Finder\\Iterator\\MultiplePcreFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/MultiplePcreFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\MultiplePcreFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/MultiplePcreFilterIterator.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\PathFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/PathFilterIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\PathFilterIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/PathFilterIterator.php',
|
||||||
'Symfony\\Component\\Finder\\Iterator\\RecursiveDirectoryIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/RecursiveDirectoryIterator.php',
|
'Symfony\\Component\\Finder\\Iterator\\RecursiveDirectoryIterator' => __DIR__ . '/..' . '/symfony/finder/Iterator/RecursiveDirectoryIterator.php',
|
||||||
|
|||||||
16
vendor/composer/installed.json
vendored
16
vendor/composer/installed.json
vendored
@@ -741,27 +741,27 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/finder",
|
"name": "symfony/finder",
|
||||||
"version": "v3.4.8",
|
"version": "v5.1.7",
|
||||||
"version_normalized": "3.4.8.0",
|
"version_normalized": "5.1.7.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/finder.git",
|
"url": "https://github.com/symfony/finder.git",
|
||||||
"reference": "bd14efe8b1fabc4de82bf50dce62f05f9a102433"
|
"reference": "2c3ba7ad6884e6c4451ce2340e2dc23f6fa3e0d8"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/finder/zipball/bd14efe8b1fabc4de82bf50dce62f05f9a102433",
|
"url": "https://api.github.com/repos/symfony/finder/zipball/2c3ba7ad6884e6c4451ce2340e2dc23f6fa3e0d8",
|
||||||
"reference": "bd14efe8b1fabc4de82bf50dce62f05f9a102433",
|
"reference": "2c3ba7ad6884e6c4451ce2340e2dc23f6fa3e0d8",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.5.9|>=7.0.8"
|
"php": ">=7.2.5"
|
||||||
},
|
},
|
||||||
"time": "2018-04-04T05:07:11+00:00",
|
"time": "2020-09-02T16:23:27+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.4-dev"
|
"dev-master": "5.1-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
|
|||||||
3
vendor/symfony/finder/.gitignore
vendored
3
vendor/symfony/finder/.gitignore
vendored
@@ -1,3 +0,0 @@
|
|||||||
vendor/
|
|
||||||
composer.lock
|
|
||||||
phpunit.xml
|
|
||||||
24
vendor/symfony/finder/CHANGELOG.md
vendored
24
vendor/symfony/finder/CHANGELOG.md
vendored
@@ -1,6 +1,30 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
5.0.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* added `$useNaturalSort` argument to `Finder::sortByName()`
|
||||||
|
|
||||||
|
4.3.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* added Finder::ignoreVCSIgnored() to ignore files based on rules listed in .gitignore
|
||||||
|
|
||||||
|
4.2.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* added $useNaturalSort option to Finder::sortByName() method
|
||||||
|
* the `Finder::sortByName()` method will have a new `$useNaturalSort`
|
||||||
|
argument in version 5.0, not defining it is deprecated
|
||||||
|
* added `Finder::reverseSorting()` to reverse the sorting
|
||||||
|
|
||||||
|
4.0.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* removed `ExceptionInterface`
|
||||||
|
* removed `Symfony\Component\Finder\Iterator\FilterIterator`
|
||||||
|
|
||||||
3.4.0
|
3.4.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|||||||
15
vendor/symfony/finder/Comparator/Comparator.php
vendored
15
vendor/symfony/finder/Comparator/Comparator.php
vendored
@@ -31,12 +31,7 @@ class Comparator
|
|||||||
return $this->target;
|
return $this->target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setTarget(string $target)
|
||||||
* Sets the target value.
|
|
||||||
*
|
|
||||||
* @param string $target The target value
|
|
||||||
*/
|
|
||||||
public function setTarget($target)
|
|
||||||
{
|
{
|
||||||
$this->target = $target;
|
$this->target = $target;
|
||||||
}
|
}
|
||||||
@@ -54,17 +49,15 @@ class Comparator
|
|||||||
/**
|
/**
|
||||||
* Sets the comparison operator.
|
* Sets the comparison operator.
|
||||||
*
|
*
|
||||||
* @param string $operator A valid operator
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function setOperator($operator)
|
public function setOperator(string $operator)
|
||||||
{
|
{
|
||||||
if (!$operator) {
|
if ('' === $operator) {
|
||||||
$operator = '==';
|
$operator = '==';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array($operator, array('>', '<', '>=', '<=', '==', '!='))) {
|
if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
|
||||||
throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
|
throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class DateComparator extends Comparator
|
|||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException If the test is not understood
|
* @throws \InvalidArgumentException If the test is not understood
|
||||||
*/
|
*/
|
||||||
public function __construct($test)
|
public function __construct(string $test)
|
||||||
{
|
{
|
||||||
if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
|
if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
|
||||||
throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
|
throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class NumberComparator extends Comparator
|
|||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException If the test is not understood
|
* @throws \InvalidArgumentException If the test is not understood
|
||||||
*/
|
*/
|
||||||
public function __construct($test)
|
public function __construct(?string $test)
|
||||||
{
|
{
|
||||||
if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
|
if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
|
||||||
throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test));
|
throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test));
|
||||||
|
|||||||
@@ -12,14 +12,8 @@
|
|||||||
namespace Symfony\Component\Finder\Exception;
|
namespace Symfony\Component\Finder\Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
* @author Andreas Erhard <andreas.erhard@i-med.ac.at>
|
||||||
*
|
|
||||||
* @deprecated since 3.3, to be removed in 4.0.
|
|
||||||
*/
|
*/
|
||||||
interface ExceptionInterface
|
class DirectoryNotFoundException extends \InvalidArgumentException
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @return \Symfony\Component\Finder\Adapter\AdapterInterface
|
|
||||||
*/
|
|
||||||
public function getAdapter();
|
|
||||||
}
|
}
|
||||||
270
vendor/symfony/finder/Finder.php
vendored
270
vendor/symfony/finder/Finder.php
vendored
@@ -13,6 +13,7 @@ namespace Symfony\Component\Finder;
|
|||||||
|
|
||||||
use Symfony\Component\Finder\Comparator\DateComparator;
|
use Symfony\Component\Finder\Comparator\DateComparator;
|
||||||
use Symfony\Component\Finder\Comparator\NumberComparator;
|
use Symfony\Component\Finder\Comparator\NumberComparator;
|
||||||
|
use Symfony\Component\Finder\Exception\DirectoryNotFoundException;
|
||||||
use Symfony\Component\Finder\Iterator\CustomFilterIterator;
|
use Symfony\Component\Finder\Iterator\CustomFilterIterator;
|
||||||
use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
|
use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
|
||||||
use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
|
use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
|
||||||
@@ -29,9 +30,9 @@ use Symfony\Component\Finder\Iterator\SortableIterator;
|
|||||||
*
|
*
|
||||||
* All rules may be invoked several times.
|
* All rules may be invoked several times.
|
||||||
*
|
*
|
||||||
* All methods return the current Finder object to allow easy chaining:
|
* All methods return the current Finder object to allow chaining:
|
||||||
*
|
*
|
||||||
* $finder = Finder::create()->files()->name('*.php')->in(__DIR__);
|
* $finder = Finder::create()->files()->name('*.php')->in(__DIR__);
|
||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
@@ -39,27 +40,29 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
{
|
{
|
||||||
const IGNORE_VCS_FILES = 1;
|
const IGNORE_VCS_FILES = 1;
|
||||||
const IGNORE_DOT_FILES = 2;
|
const IGNORE_DOT_FILES = 2;
|
||||||
|
const IGNORE_VCS_IGNORED_FILES = 4;
|
||||||
|
|
||||||
private $mode = 0;
|
private $mode = 0;
|
||||||
private $names = array();
|
private $names = [];
|
||||||
private $notNames = array();
|
private $notNames = [];
|
||||||
private $exclude = array();
|
private $exclude = [];
|
||||||
private $filters = array();
|
private $filters = [];
|
||||||
private $depths = array();
|
private $depths = [];
|
||||||
private $sizes = array();
|
private $sizes = [];
|
||||||
private $followLinks = false;
|
private $followLinks = false;
|
||||||
|
private $reverseSorting = false;
|
||||||
private $sort = false;
|
private $sort = false;
|
||||||
private $ignore = 0;
|
private $ignore = 0;
|
||||||
private $dirs = array();
|
private $dirs = [];
|
||||||
private $dates = array();
|
private $dates = [];
|
||||||
private $iterators = array();
|
private $iterators = [];
|
||||||
private $contains = array();
|
private $contains = [];
|
||||||
private $notContains = array();
|
private $notContains = [];
|
||||||
private $paths = array();
|
private $paths = [];
|
||||||
private $notPaths = array();
|
private $notPaths = [];
|
||||||
private $ignoreUnreadableDirs = false;
|
private $ignoreUnreadableDirs = false;
|
||||||
|
|
||||||
private static $vcsPatterns = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg');
|
private static $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@@ -105,19 +108,22 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
*
|
*
|
||||||
* $finder->depth('> 1') // the Finder will start matching at level 1.
|
* $finder->depth('> 1') // the Finder will start matching at level 1.
|
||||||
* $finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point.
|
* $finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point.
|
||||||
|
* $finder->depth(['>= 1', '< 3'])
|
||||||
*
|
*
|
||||||
* @param string|int $level The depth level expression
|
* @param string|int|string[]|int[] $levels The depth level expression or an array of depth levels
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @see DepthRangeFilterIterator
|
* @see DepthRangeFilterIterator
|
||||||
* @see NumberComparator
|
* @see NumberComparator
|
||||||
*/
|
*/
|
||||||
public function depth($level)
|
public function depth($levels)
|
||||||
{
|
{
|
||||||
$this->depths[] = new Comparator\NumberComparator($level);
|
foreach ((array) $levels as $level) {
|
||||||
|
$this->depths[] = new Comparator\NumberComparator($level);
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -127,12 +133,13 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*
|
*
|
||||||
* The date must be something that strtotime() is able to parse:
|
* The date must be something that strtotime() is able to parse:
|
||||||
*
|
*
|
||||||
* $finder->date('since yesterday');
|
* $finder->date('since yesterday');
|
||||||
* $finder->date('until 2 days ago');
|
* $finder->date('until 2 days ago');
|
||||||
* $finder->date('> now - 2 hours');
|
* $finder->date('> now - 2 hours');
|
||||||
* $finder->date('>= 2005-10-15');
|
* $finder->date('>= 2005-10-15');
|
||||||
|
* $finder->date(['>= 2005-10-15', '<= 2006-05-27']);
|
||||||
*
|
*
|
||||||
* @param string $date A date range string
|
* @param string|string[] $dates A date range string or an array of date ranges
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
@@ -140,9 +147,11 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
* @see DateRangeFilterIterator
|
* @see DateRangeFilterIterator
|
||||||
* @see DateComparator
|
* @see DateComparator
|
||||||
*/
|
*/
|
||||||
public function date($date)
|
public function date($dates)
|
||||||
{
|
{
|
||||||
$this->dates[] = new Comparator\DateComparator($date);
|
foreach ((array) $dates as $date) {
|
||||||
|
$this->dates[] = new Comparator\DateComparator($date);
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -152,19 +161,20 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*
|
*
|
||||||
* You can use patterns (delimited with / sign), globs or simple strings.
|
* You can use patterns (delimited with / sign), globs or simple strings.
|
||||||
*
|
*
|
||||||
* $finder->name('*.php')
|
* $finder->name('*.php')
|
||||||
* $finder->name('/\.php$/') // same as above
|
* $finder->name('/\.php$/') // same as above
|
||||||
* $finder->name('test.php')
|
* $finder->name('test.php')
|
||||||
|
* $finder->name(['test.py', 'test.php'])
|
||||||
*
|
*
|
||||||
* @param string $pattern A pattern (a regexp, a glob, or a string)
|
* @param string|string[] $patterns A pattern (a regexp, a glob, or a string) or an array of patterns
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @see FilenameFilterIterator
|
* @see FilenameFilterIterator
|
||||||
*/
|
*/
|
||||||
public function name($pattern)
|
public function name($patterns)
|
||||||
{
|
{
|
||||||
$this->names[] = $pattern;
|
$this->names = array_merge($this->names, (array) $patterns);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -172,15 +182,15 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
/**
|
/**
|
||||||
* Adds rules that files must not match.
|
* Adds rules that files must not match.
|
||||||
*
|
*
|
||||||
* @param string $pattern A pattern (a regexp, a glob, or a string)
|
* @param string|string[] $patterns A pattern (a regexp, a glob, or a string) or an array of patterns
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @see FilenameFilterIterator
|
* @see FilenameFilterIterator
|
||||||
*/
|
*/
|
||||||
public function notName($pattern)
|
public function notName($patterns)
|
||||||
{
|
{
|
||||||
$this->notNames[] = $pattern;
|
$this->notNames = array_merge($this->notNames, (array) $patterns);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -190,18 +200,19 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*
|
*
|
||||||
* Strings or PCRE patterns can be used:
|
* Strings or PCRE patterns can be used:
|
||||||
*
|
*
|
||||||
* $finder->contains('Lorem ipsum')
|
* $finder->contains('Lorem ipsum')
|
||||||
* $finder->contains('/Lorem ipsum/i')
|
* $finder->contains('/Lorem ipsum/i')
|
||||||
|
* $finder->contains(['dolor', '/ipsum/i'])
|
||||||
*
|
*
|
||||||
* @param string $pattern A pattern (string or regexp)
|
* @param string|string[] $patterns A pattern (string or regexp) or an array of patterns
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @see FilecontentFilterIterator
|
* @see FilecontentFilterIterator
|
||||||
*/
|
*/
|
||||||
public function contains($pattern)
|
public function contains($patterns)
|
||||||
{
|
{
|
||||||
$this->contains[] = $pattern;
|
$this->contains = array_merge($this->contains, (array) $patterns);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -211,18 +222,19 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*
|
*
|
||||||
* Strings or PCRE patterns can be used:
|
* Strings or PCRE patterns can be used:
|
||||||
*
|
*
|
||||||
* $finder->notContains('Lorem ipsum')
|
* $finder->notContains('Lorem ipsum')
|
||||||
* $finder->notContains('/Lorem ipsum/i')
|
* $finder->notContains('/Lorem ipsum/i')
|
||||||
|
* $finder->notContains(['lorem', '/dolor/i'])
|
||||||
*
|
*
|
||||||
* @param string $pattern A pattern (string or regexp)
|
* @param string|string[] $patterns A pattern (string or regexp) or an array of patterns
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @see FilecontentFilterIterator
|
* @see FilecontentFilterIterator
|
||||||
*/
|
*/
|
||||||
public function notContains($pattern)
|
public function notContains($patterns)
|
||||||
{
|
{
|
||||||
$this->notContains[] = $pattern;
|
$this->notContains = array_merge($this->notContains, (array) $patterns);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -232,20 +244,21 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*
|
*
|
||||||
* You can use patterns (delimited with / sign) or simple strings.
|
* You can use patterns (delimited with / sign) or simple strings.
|
||||||
*
|
*
|
||||||
* $finder->path('some/special/dir')
|
* $finder->path('some/special/dir')
|
||||||
* $finder->path('/some\/special\/dir/') // same as above
|
* $finder->path('/some\/special\/dir/') // same as above
|
||||||
|
* $finder->path(['some dir', 'another/dir'])
|
||||||
*
|
*
|
||||||
* Use only / as dirname separator.
|
* Use only / as dirname separator.
|
||||||
*
|
*
|
||||||
* @param string $pattern A pattern (a regexp or a string)
|
* @param string|string[] $patterns A pattern (a regexp or a string) or an array of patterns
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @see FilenameFilterIterator
|
* @see FilenameFilterIterator
|
||||||
*/
|
*/
|
||||||
public function path($pattern)
|
public function path($patterns)
|
||||||
{
|
{
|
||||||
$this->paths[] = $pattern;
|
$this->paths = array_merge($this->paths, (array) $patterns);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -255,20 +268,21 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*
|
*
|
||||||
* You can use patterns (delimited with / sign) or simple strings.
|
* You can use patterns (delimited with / sign) or simple strings.
|
||||||
*
|
*
|
||||||
* $finder->notPath('some/special/dir')
|
* $finder->notPath('some/special/dir')
|
||||||
* $finder->notPath('/some\/special\/dir/') // same as above
|
* $finder->notPath('/some\/special\/dir/') // same as above
|
||||||
|
* $finder->notPath(['some/file.txt', 'another/file.log'])
|
||||||
*
|
*
|
||||||
* Use only / as dirname separator.
|
* Use only / as dirname separator.
|
||||||
*
|
*
|
||||||
* @param string $pattern A pattern (a regexp or a string)
|
* @param string|string[] $patterns A pattern (a regexp or a string) or an array of patterns
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @see FilenameFilterIterator
|
* @see FilenameFilterIterator
|
||||||
*/
|
*/
|
||||||
public function notPath($pattern)
|
public function notPath($patterns)
|
||||||
{
|
{
|
||||||
$this->notPaths[] = $pattern;
|
$this->notPaths = array_merge($this->notPaths, (array) $patterns);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -276,20 +290,23 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
/**
|
/**
|
||||||
* Adds tests for file sizes.
|
* Adds tests for file sizes.
|
||||||
*
|
*
|
||||||
* $finder->size('> 10K');
|
* $finder->size('> 10K');
|
||||||
* $finder->size('<= 1Ki');
|
* $finder->size('<= 1Ki');
|
||||||
* $finder->size(4);
|
* $finder->size(4);
|
||||||
|
* $finder->size(['> 10K', '< 20K'])
|
||||||
*
|
*
|
||||||
* @param string|int $size A size range string or an integer
|
* @param string|int|string[]|int[] $sizes A size range string or an integer or an array of size ranges
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @see SizeRangeFilterIterator
|
* @see SizeRangeFilterIterator
|
||||||
* @see NumberComparator
|
* @see NumberComparator
|
||||||
*/
|
*/
|
||||||
public function size($size)
|
public function size($sizes)
|
||||||
{
|
{
|
||||||
$this->sizes[] = new Comparator\NumberComparator($size);
|
foreach ((array) $sizes as $size) {
|
||||||
|
$this->sizes[] = new Comparator\NumberComparator($size);
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -319,13 +336,11 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*
|
*
|
||||||
* This option is enabled by default.
|
* This option is enabled by default.
|
||||||
*
|
*
|
||||||
* @param bool $ignoreDotFiles Whether to exclude "hidden" files or not
|
|
||||||
*
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @see ExcludeDirectoryFilterIterator
|
* @see ExcludeDirectoryFilterIterator
|
||||||
*/
|
*/
|
||||||
public function ignoreDotFiles($ignoreDotFiles)
|
public function ignoreDotFiles(bool $ignoreDotFiles)
|
||||||
{
|
{
|
||||||
if ($ignoreDotFiles) {
|
if ($ignoreDotFiles) {
|
||||||
$this->ignore |= static::IGNORE_DOT_FILES;
|
$this->ignore |= static::IGNORE_DOT_FILES;
|
||||||
@@ -341,13 +356,11 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*
|
*
|
||||||
* This option is enabled by default.
|
* This option is enabled by default.
|
||||||
*
|
*
|
||||||
* @param bool $ignoreVCS Whether to exclude VCS files or not
|
|
||||||
*
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @see ExcludeDirectoryFilterIterator
|
* @see ExcludeDirectoryFilterIterator
|
||||||
*/
|
*/
|
||||||
public function ignoreVCS($ignoreVCS)
|
public function ignoreVCS(bool $ignoreVCS)
|
||||||
{
|
{
|
||||||
if ($ignoreVCS) {
|
if ($ignoreVCS) {
|
||||||
$this->ignore |= static::IGNORE_VCS_FILES;
|
$this->ignore |= static::IGNORE_VCS_FILES;
|
||||||
@@ -358,6 +371,24 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces Finder to obey .gitignore and ignore files based on rules listed there.
|
||||||
|
*
|
||||||
|
* This option is disabled by default.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function ignoreVCSIgnored(bool $ignoreVCSIgnored)
|
||||||
|
{
|
||||||
|
if ($ignoreVCSIgnored) {
|
||||||
|
$this->ignore |= static::IGNORE_VCS_IGNORED_FILES;
|
||||||
|
} else {
|
||||||
|
$this->ignore &= ~static::IGNORE_VCS_IGNORED_FILES;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds VCS patterns.
|
* Adds VCS patterns.
|
||||||
*
|
*
|
||||||
@@ -401,9 +432,9 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*
|
*
|
||||||
* @see SortableIterator
|
* @see SortableIterator
|
||||||
*/
|
*/
|
||||||
public function sortByName()
|
public function sortByName(bool $useNaturalSort = false)
|
||||||
{
|
{
|
||||||
$this->sort = Iterator\SortableIterator::SORT_BY_NAME;
|
$this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL : Iterator\SortableIterator::SORT_BY_NAME;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -442,6 +473,18 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverses the sorting.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function reverseSorting()
|
||||||
|
{
|
||||||
|
$this->reverseSorting = true;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts files and directories by the last inode changed time.
|
* Sorts files and directories by the last inode changed time.
|
||||||
*
|
*
|
||||||
@@ -514,13 +557,11 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*
|
*
|
||||||
* By default, scanning unreadable directories content throws an AccessDeniedException.
|
* By default, scanning unreadable directories content throws an AccessDeniedException.
|
||||||
*
|
*
|
||||||
* @param bool $ignore
|
|
||||||
*
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function ignoreUnreadableDirs($ignore = true)
|
public function ignoreUnreadableDirs(bool $ignore = true)
|
||||||
{
|
{
|
||||||
$this->ignoreUnreadableDirs = (bool) $ignore;
|
$this->ignoreUnreadableDirs = $ignore;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -528,23 +569,24 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
/**
|
/**
|
||||||
* Searches files and directories which match defined rules.
|
* Searches files and directories which match defined rules.
|
||||||
*
|
*
|
||||||
* @param string|array $dirs A directory path or an array of directories
|
* @param string|string[] $dirs A directory path or an array of directories
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException if one of the directories does not exist
|
* @throws DirectoryNotFoundException if one of the directories does not exist
|
||||||
*/
|
*/
|
||||||
public function in($dirs)
|
public function in($dirs)
|
||||||
{
|
{
|
||||||
$resolvedDirs = array();
|
$resolvedDirs = [];
|
||||||
|
|
||||||
foreach ((array) $dirs as $dir) {
|
foreach ((array) $dirs as $dir) {
|
||||||
if (is_dir($dir)) {
|
if (is_dir($dir)) {
|
||||||
$resolvedDirs[] = $this->normalizeDir($dir);
|
$resolvedDirs[] = $this->normalizeDir($dir);
|
||||||
} elseif ($glob = glob($dir, (defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
|
} elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? \GLOB_BRACE : 0) | \GLOB_ONLYDIR | \GLOB_NOSORT)) {
|
||||||
$resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob));
|
sort($glob);
|
||||||
|
$resolvedDirs = array_merge($resolvedDirs, array_map([$this, 'normalizeDir'], $glob));
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
|
throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,11 +606,11 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*/
|
*/
|
||||||
public function getIterator()
|
public function getIterator()
|
||||||
{
|
{
|
||||||
if (0 === count($this->dirs) && 0 === count($this->iterators)) {
|
if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
|
||||||
throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
|
throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 === count($this->dirs) && 0 === count($this->iterators)) {
|
if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
|
||||||
return $this->searchInDirectory($this->dirs[0]);
|
return $this->searchInDirectory($this->dirs[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,19 +631,17 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
*
|
*
|
||||||
* The set can be another Finder, an Iterator, an IteratorAggregate, or even a plain array.
|
* The set can be another Finder, an Iterator, an IteratorAggregate, or even a plain array.
|
||||||
*
|
*
|
||||||
* @param mixed $iterator
|
|
||||||
*
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException when the given argument is not iterable
|
* @throws \InvalidArgumentException when the given argument is not iterable
|
||||||
*/
|
*/
|
||||||
public function append($iterator)
|
public function append(iterable $iterator)
|
||||||
{
|
{
|
||||||
if ($iterator instanceof \IteratorAggregate) {
|
if ($iterator instanceof \IteratorAggregate) {
|
||||||
$this->iterators[] = $iterator->getIterator();
|
$this->iterators[] = $iterator->getIterator();
|
||||||
} elseif ($iterator instanceof \Iterator) {
|
} elseif ($iterator instanceof \Iterator) {
|
||||||
$this->iterators[] = $iterator;
|
$this->iterators[] = $iterator;
|
||||||
} elseif ($iterator instanceof \Traversable || is_array($iterator)) {
|
} elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
|
||||||
$it = new \ArrayIterator();
|
$it = new \ArrayIterator();
|
||||||
foreach ($iterator as $file) {
|
foreach ($iterator as $file) {
|
||||||
$it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
|
$it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
|
||||||
@@ -638,23 +678,29 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
return iterator_count($this->getIterator());
|
return iterator_count($this->getIterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function searchInDirectory(string $dir): \Iterator
|
||||||
* @param $dir
|
|
||||||
*
|
|
||||||
* @return \Iterator
|
|
||||||
*/
|
|
||||||
private function searchInDirectory($dir)
|
|
||||||
{
|
{
|
||||||
|
$exclude = $this->exclude;
|
||||||
|
$notPaths = $this->notPaths;
|
||||||
|
|
||||||
if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
|
if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
|
||||||
$this->exclude = array_merge($this->exclude, self::$vcsPatterns);
|
$exclude = array_merge($exclude, self::$vcsPatterns);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
|
if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
|
||||||
$this->notPaths[] = '#(^|/)\..+(/|$)#';
|
$notPaths[] = '#(^|/)\..+(/|$)#';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (static::IGNORE_VCS_IGNORED_FILES === (static::IGNORE_VCS_IGNORED_FILES & $this->ignore)) {
|
||||||
|
$gitignoreFilePath = sprintf('%s/.gitignore', $dir);
|
||||||
|
if (!is_readable($gitignoreFilePath)) {
|
||||||
|
throw new \RuntimeException(sprintf('The "ignoreVCSIgnored" option cannot be used by the Finder as the "%s" file is not readable.', $gitignoreFilePath));
|
||||||
|
}
|
||||||
|
$notPaths = array_merge($notPaths, [Gitignore::toRegex(file_get_contents($gitignoreFilePath))]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$minDepth = 0;
|
$minDepth = 0;
|
||||||
$maxDepth = PHP_INT_MAX;
|
$maxDepth = \PHP_INT_MAX;
|
||||||
|
|
||||||
foreach ($this->depths as $comparator) {
|
foreach ($this->depths as $comparator) {
|
||||||
switch ($comparator->getOperator()) {
|
switch ($comparator->getOperator()) {
|
||||||
@@ -683,13 +729,13 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
|
|
||||||
$iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
|
$iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
|
||||||
|
|
||||||
if ($this->exclude) {
|
if ($exclude) {
|
||||||
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
|
$iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $exclude);
|
||||||
}
|
}
|
||||||
|
|
||||||
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
|
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
|
||||||
|
|
||||||
if ($minDepth > 0 || $maxDepth < PHP_INT_MAX) {
|
if ($minDepth > 0 || $maxDepth < \PHP_INT_MAX) {
|
||||||
$iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
|
$iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,12 +763,12 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
$iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
|
$iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->paths || $this->notPaths) {
|
if ($this->paths || $notPaths) {
|
||||||
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
|
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->sort) {
|
if ($this->sort || $this->reverseSorting) {
|
||||||
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
|
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting);
|
||||||
$iterator = $iteratorAggregate->getIterator();
|
$iterator = $iteratorAggregate->getIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -732,12 +778,20 @@ class Finder implements \IteratorAggregate, \Countable
|
|||||||
/**
|
/**
|
||||||
* Normalizes given directory names by removing trailing slashes.
|
* Normalizes given directory names by removing trailing slashes.
|
||||||
*
|
*
|
||||||
* @param string $dir
|
* Excluding: (s)ftp:// or ssh2.(s)ftp:// wrapper
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
private function normalizeDir($dir)
|
private function normalizeDir(string $dir): string
|
||||||
{
|
{
|
||||||
return rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
|
if ('/' === $dir) {
|
||||||
|
return $dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dir = rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
|
if (preg_match('#^(ssh2\.)?s?ftp://#', $dir)) {
|
||||||
|
$dir .= '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
133
vendor/symfony/finder/Gitignore.php
vendored
Normal file
133
vendor/symfony/finder/Gitignore.php
vendored
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Finder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gitignore matches against text.
|
||||||
|
*
|
||||||
|
* @author Ahmed Abdou <mail@ahmd.io>
|
||||||
|
*/
|
||||||
|
class Gitignore
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns a regexp which is the equivalent of the gitignore pattern.
|
||||||
|
*
|
||||||
|
* @return string The regexp
|
||||||
|
*/
|
||||||
|
public static function toRegex(string $gitignoreFileContent): string
|
||||||
|
{
|
||||||
|
$gitignoreFileContent = preg_replace('/^[^\\\r\n]*#.*/m', '', $gitignoreFileContent);
|
||||||
|
$gitignoreLines = preg_split('/\r\n|\r|\n/', $gitignoreFileContent);
|
||||||
|
|
||||||
|
$positives = [];
|
||||||
|
$negatives = [];
|
||||||
|
foreach ($gitignoreLines as $i => $line) {
|
||||||
|
$line = trim($line);
|
||||||
|
if ('' === $line) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (1 === preg_match('/^!/', $line)) {
|
||||||
|
$positives[$i] = null;
|
||||||
|
$negatives[$i] = self::getRegexFromGitignore(preg_replace('/^!(.*)/', '${1}', $line), true);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$negatives[$i] = null;
|
||||||
|
$positives[$i] = self::getRegexFromGitignore($line);
|
||||||
|
}
|
||||||
|
|
||||||
|
$index = 0;
|
||||||
|
$patterns = [];
|
||||||
|
foreach ($positives as $pattern) {
|
||||||
|
if (null === $pattern) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$negativesAfter = array_filter(\array_slice($negatives, ++$index));
|
||||||
|
if ([] !== $negativesAfter) {
|
||||||
|
$pattern .= sprintf('(?<!%s)', implode('|', $negativesAfter));
|
||||||
|
}
|
||||||
|
|
||||||
|
$patterns[] = $pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sprintf('/^((%s))$/', implode(')|(', $patterns));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getRegexFromGitignore(string $gitignorePattern, bool $negative = false): string
|
||||||
|
{
|
||||||
|
$regex = '';
|
||||||
|
$isRelativePath = false;
|
||||||
|
// If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself
|
||||||
|
$slashPosition = strpos($gitignorePattern, '/');
|
||||||
|
if (false !== $slashPosition && \strlen($gitignorePattern) - 1 !== $slashPosition) {
|
||||||
|
if (0 === $slashPosition) {
|
||||||
|
$gitignorePattern = substr($gitignorePattern, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$isRelativePath = true;
|
||||||
|
$regex .= '^';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('/' === $gitignorePattern[\strlen($gitignorePattern) - 1]) {
|
||||||
|
$gitignorePattern = substr($gitignorePattern, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$iMax = \strlen($gitignorePattern);
|
||||||
|
for ($i = 0; $i < $iMax; ++$i) {
|
||||||
|
$tripleChars = substr($gitignorePattern, $i, 3);
|
||||||
|
if ('**/' === $tripleChars || '/**' === $tripleChars) {
|
||||||
|
$regex .= '.*';
|
||||||
|
$i += 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$doubleChars = substr($gitignorePattern, $i, 2);
|
||||||
|
if ('**' === $doubleChars) {
|
||||||
|
$regex .= '.*';
|
||||||
|
++$i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ('*/' === $doubleChars) {
|
||||||
|
$regex .= '[^\/]*\/?[^\/]*';
|
||||||
|
++$i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$c = $gitignorePattern[$i];
|
||||||
|
switch ($c) {
|
||||||
|
case '*':
|
||||||
|
$regex .= $isRelativePath ? '[^\/]*' : '[^\/]*\/?[^\/]*';
|
||||||
|
break;
|
||||||
|
case '/':
|
||||||
|
case '.':
|
||||||
|
case ':':
|
||||||
|
case '(':
|
||||||
|
case ')':
|
||||||
|
case '{':
|
||||||
|
case '}':
|
||||||
|
$regex .= '\\'.$c;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$regex .= $c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($negative) {
|
||||||
|
// a lookbehind assertion has to be a fixed width (it can not have nested '|' statements)
|
||||||
|
return sprintf('%s$|%s\/$', $regex, $regex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '(?>'.$regex.'($|\/.*))';
|
||||||
|
}
|
||||||
|
}
|
||||||
25
vendor/symfony/finder/Glob.php
vendored
25
vendor/symfony/finder/Glob.php
vendored
@@ -14,14 +14,14 @@ namespace Symfony\Component\Finder;
|
|||||||
/**
|
/**
|
||||||
* Glob matches globbing patterns against text.
|
* Glob matches globbing patterns against text.
|
||||||
*
|
*
|
||||||
* if match_glob("foo.*", "foo.bar") echo "matched\n";
|
* if match_glob("foo.*", "foo.bar") echo "matched\n";
|
||||||
*
|
*
|
||||||
* // prints foo.bar and foo.baz
|
* // prints foo.bar and foo.baz
|
||||||
* $regex = glob_to_regex("foo.*");
|
* $regex = glob_to_regex("foo.*");
|
||||||
* for (array('foo.bar', 'foo.baz', 'foo', 'bar') as $t)
|
* for (['foo.bar', 'foo.baz', 'foo', 'bar'] as $t)
|
||||||
* {
|
* {
|
||||||
* if (/$regex/) echo "matched: $car\n";
|
* if (/$regex/) echo "matched: $car\n";
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Glob implements glob(3) style matching that can be used to match
|
* Glob implements glob(3) style matching that can be used to match
|
||||||
* against text, rather than fetching names from a filesystem.
|
* against text, rather than fetching names from a filesystem.
|
||||||
@@ -38,20 +38,15 @@ class Glob
|
|||||||
/**
|
/**
|
||||||
* Returns a regexp which is the equivalent of the glob pattern.
|
* Returns a regexp which is the equivalent of the glob pattern.
|
||||||
*
|
*
|
||||||
* @param string $glob The glob pattern
|
* @return string
|
||||||
* @param bool $strictLeadingDot
|
|
||||||
* @param bool $strictWildcardSlash
|
|
||||||
* @param string $delimiter Optional delimiter
|
|
||||||
*
|
|
||||||
* @return string regex The regexp
|
|
||||||
*/
|
*/
|
||||||
public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true, $delimiter = '#')
|
public static function toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#')
|
||||||
{
|
{
|
||||||
$firstByte = true;
|
$firstByte = true;
|
||||||
$escaping = false;
|
$escaping = false;
|
||||||
$inCurlies = 0;
|
$inCurlies = 0;
|
||||||
$regex = '';
|
$regex = '';
|
||||||
$sizeGlob = strlen($glob);
|
$sizeGlob = \strlen($glob);
|
||||||
for ($i = 0; $i < $sizeGlob; ++$i) {
|
for ($i = 0; $i < $sizeGlob; ++$i) {
|
||||||
$car = $glob[$i];
|
$car = $glob[$i];
|
||||||
if ($firstByte && $strictLeadingDot && '.' !== $car) {
|
if ($firstByte && $strictLeadingDot && '.' !== $car) {
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ namespace Symfony\Component\Finder\Iterator;
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class CustomFilterIterator extends FilterIterator
|
class CustomFilterIterator extends \FilterIterator
|
||||||
{
|
{
|
||||||
private $filters = array();
|
private $filters = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Iterator $iterator The Iterator to filter
|
* @param \Iterator $iterator The Iterator to filter
|
||||||
@@ -32,7 +32,7 @@ class CustomFilterIterator extends FilterIterator
|
|||||||
public function __construct(\Iterator $iterator, array $filters)
|
public function __construct(\Iterator $iterator, array $filters)
|
||||||
{
|
{
|
||||||
foreach ($filters as $filter) {
|
foreach ($filters as $filter) {
|
||||||
if (!is_callable($filter)) {
|
if (!\is_callable($filter)) {
|
||||||
throw new \InvalidArgumentException('Invalid PHP callback.');
|
throw new \InvalidArgumentException('Invalid PHP callback.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ class CustomFilterIterator extends FilterIterator
|
|||||||
$fileinfo = $this->current();
|
$fileinfo = $this->current();
|
||||||
|
|
||||||
foreach ($this->filters as $filter) {
|
foreach ($this->filters as $filter) {
|
||||||
if (false === call_user_func($filter, $fileinfo)) {
|
if (false === $filter($fileinfo)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ use Symfony\Component\Finder\Comparator\DateComparator;
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class DateRangeFilterIterator extends FilterIterator
|
class DateRangeFilterIterator extends \FilterIterator
|
||||||
{
|
{
|
||||||
private $comparators = array();
|
private $comparators = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Iterator $iterator The Iterator to filter
|
* @param \Iterator $iterator The Iterator to filter
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Symfony\Component\Finder\Iterator;
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class DepthRangeFilterIterator extends FilterIterator
|
class DepthRangeFilterIterator extends \FilterIterator
|
||||||
{
|
{
|
||||||
private $minDepth = 0;
|
private $minDepth = 0;
|
||||||
|
|
||||||
@@ -25,10 +25,10 @@ class DepthRangeFilterIterator extends FilterIterator
|
|||||||
* @param int $minDepth The min depth
|
* @param int $minDepth The min depth
|
||||||
* @param int $maxDepth The max depth
|
* @param int $maxDepth The max depth
|
||||||
*/
|
*/
|
||||||
public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX)
|
public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth = 0, int $maxDepth = \PHP_INT_MAX)
|
||||||
{
|
{
|
||||||
$this->minDepth = $minDepth;
|
$this->minDepth = $minDepth;
|
||||||
$iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
|
$iterator->setMaxDepth(\PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
|
||||||
|
|
||||||
parent::__construct($iterator);
|
parent::__construct($iterator);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,22 +16,22 @@ namespace Symfony\Component\Finder\Iterator;
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class ExcludeDirectoryFilterIterator extends FilterIterator implements \RecursiveIterator
|
class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator
|
||||||
{
|
{
|
||||||
private $iterator;
|
private $iterator;
|
||||||
private $isRecursive;
|
private $isRecursive;
|
||||||
private $excludedDirs = array();
|
private $excludedDirs = [];
|
||||||
private $excludedPattern;
|
private $excludedPattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Iterator $iterator The Iterator to filter
|
* @param \Iterator $iterator The Iterator to filter
|
||||||
* @param array $directories An array of directories to exclude
|
* @param string[] $directories An array of directories to exclude
|
||||||
*/
|
*/
|
||||||
public function __construct(\Iterator $iterator, array $directories)
|
public function __construct(\Iterator $iterator, array $directories)
|
||||||
{
|
{
|
||||||
$this->iterator = $iterator;
|
$this->iterator = $iterator;
|
||||||
$this->isRecursive = $iterator instanceof \RecursiveIterator;
|
$this->isRecursive = $iterator instanceof \RecursiveIterator;
|
||||||
$patterns = array();
|
$patterns = [];
|
||||||
foreach ($directories as $directory) {
|
foreach ($directories as $directory) {
|
||||||
$directory = rtrim($directory, '/');
|
$directory = rtrim($directory, '/');
|
||||||
if (!$this->isRecursive || false !== strpos($directory, '/')) {
|
if (!$this->isRecursive || false !== strpos($directory, '/')) {
|
||||||
@@ -68,6 +68,9 @@ class ExcludeDirectoryFilterIterator extends FilterIterator implements \Recursiv
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function hasChildren()
|
public function hasChildren()
|
||||||
{
|
{
|
||||||
return $this->isRecursive && $this->iterator->hasChildren();
|
return $this->isRecursive && $this->iterator->hasChildren();
|
||||||
@@ -75,7 +78,7 @@ class ExcludeDirectoryFilterIterator extends FilterIterator implements \Recursiv
|
|||||||
|
|
||||||
public function getChildren()
|
public function getChildren()
|
||||||
{
|
{
|
||||||
$children = new self($this->iterator->getChildren(), array());
|
$children = new self($this->iterator->getChildren(), []);
|
||||||
$children->excludedDirs = $this->excludedDirs;
|
$children->excludedDirs = $this->excludedDirs;
|
||||||
$children->excludedPattern = $this->excludedPattern;
|
$children->excludedPattern = $this->excludedPattern;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Symfony\Component\Finder\Iterator;
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class FileTypeFilterIterator extends FilterIterator
|
class FileTypeFilterIterator extends \FilterIterator
|
||||||
{
|
{
|
||||||
const ONLY_FILES = 1;
|
const ONLY_FILES = 1;
|
||||||
const ONLY_DIRECTORIES = 2;
|
const ONLY_DIRECTORIES = 2;
|
||||||
@@ -27,7 +27,7 @@ class FileTypeFilterIterator extends FilterIterator
|
|||||||
* @param \Iterator $iterator The Iterator to filter
|
* @param \Iterator $iterator The Iterator to filter
|
||||||
* @param int $mode The mode (self::ONLY_FILES or self::ONLY_DIRECTORIES)
|
* @param int $mode The mode (self::ONLY_FILES or self::ONLY_DIRECTORIES)
|
||||||
*/
|
*/
|
||||||
public function __construct(\Iterator $iterator, $mode)
|
public function __construct(\Iterator $iterator, int $mode)
|
||||||
{
|
{
|
||||||
$this->mode = $mode;
|
$this->mode = $mode;
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class FilecontentFilterIterator extends MultiplePcreFilterIterator
|
|||||||
*
|
*
|
||||||
* @return string regexp corresponding to a given string or regexp
|
* @return string regexp corresponding to a given string or regexp
|
||||||
*/
|
*/
|
||||||
protected function toRegex($str)
|
protected function toRegex(string $str)
|
||||||
{
|
{
|
||||||
return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
|
return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class FilenameFilterIterator extends MultiplePcreFilterIterator
|
|||||||
*
|
*
|
||||||
* @return string regexp corresponding to a given glob or regexp
|
* @return string regexp corresponding to a given glob or regexp
|
||||||
*/
|
*/
|
||||||
protected function toRegex($str)
|
protected function toRegex(string $str)
|
||||||
{
|
{
|
||||||
return $this->isRegex($str) ? $str : Glob::toRegex($str);
|
return $this->isRegex($str) ? $str : Glob::toRegex($str);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Iterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This iterator just overrides the rewind method in order to correct a PHP bug,
|
|
||||||
* which existed before version 5.5.23/5.6.7.
|
|
||||||
*
|
|
||||||
* @see https://bugs.php.net/68557
|
|
||||||
*
|
|
||||||
* @author Alex Bogomazov
|
|
||||||
*
|
|
||||||
* @deprecated since 3.4, to be removed in 4.0.
|
|
||||||
*/
|
|
||||||
abstract class FilterIterator extends \FilterIterator
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* This is a workaround for the problem with \FilterIterator leaving inner \FilesystemIterator in wrong state after
|
|
||||||
* rewind in some cases.
|
|
||||||
*
|
|
||||||
* @see FilterIterator::rewind()
|
|
||||||
*/
|
|
||||||
public function rewind()
|
|
||||||
{
|
|
||||||
if (\PHP_VERSION_ID > 50607 || (\PHP_VERSION_ID > 50523 && \PHP_VERSION_ID < 50600)) {
|
|
||||||
parent::rewind();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$iterator = $this;
|
|
||||||
while ($iterator instanceof \OuterIterator) {
|
|
||||||
$innerIterator = $iterator->getInnerIterator();
|
|
||||||
|
|
||||||
if ($innerIterator instanceof RecursiveDirectoryIterator) {
|
|
||||||
// this condition is necessary for iterators to work properly with non-local filesystems like ftp
|
|
||||||
if ($innerIterator->isRewindable()) {
|
|
||||||
$innerIterator->next();
|
|
||||||
$innerIterator->rewind();
|
|
||||||
}
|
|
||||||
} elseif ($innerIterator instanceof \FilesystemIterator) {
|
|
||||||
$innerIterator->next();
|
|
||||||
$innerIterator->rewind();
|
|
||||||
}
|
|
||||||
|
|
||||||
$iterator = $innerIterator;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::rewind();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,15 +16,15 @@ namespace Symfony\Component\Finder\Iterator;
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
abstract class MultiplePcreFilterIterator extends FilterIterator
|
abstract class MultiplePcreFilterIterator extends \FilterIterator
|
||||||
{
|
{
|
||||||
protected $matchRegexps = array();
|
protected $matchRegexps = [];
|
||||||
protected $noMatchRegexps = array();
|
protected $noMatchRegexps = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Iterator $iterator The Iterator to filter
|
* @param \Iterator $iterator The Iterator to filter
|
||||||
* @param array $matchPatterns An array of patterns that need to match
|
* @param string[] $matchPatterns An array of patterns that need to match
|
||||||
* @param array $noMatchPatterns An array of patterns that need to not match
|
* @param string[] $noMatchPatterns An array of patterns that need to not match
|
||||||
*/
|
*/
|
||||||
public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
|
public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
|
||||||
{
|
{
|
||||||
@@ -46,11 +46,9 @@ abstract class MultiplePcreFilterIterator extends FilterIterator
|
|||||||
* Such case can be handled by child classes before calling the method if they want to
|
* Such case can be handled by child classes before calling the method if they want to
|
||||||
* apply a different behavior.
|
* apply a different behavior.
|
||||||
*
|
*
|
||||||
* @param string $string The string to be matched against filters
|
|
||||||
*
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function isAccepted($string)
|
protected function isAccepted(string $string)
|
||||||
{
|
{
|
||||||
// should at least not match one rule to exclude
|
// should at least not match one rule to exclude
|
||||||
foreach ($this->noMatchRegexps as $regex) {
|
foreach ($this->noMatchRegexps as $regex) {
|
||||||
@@ -77,11 +75,9 @@ abstract class MultiplePcreFilterIterator extends FilterIterator
|
|||||||
/**
|
/**
|
||||||
* Checks whether the string is a regex.
|
* Checks whether the string is a regex.
|
||||||
*
|
*
|
||||||
* @param string $str
|
* @return bool
|
||||||
*
|
|
||||||
* @return bool Whether the given string is a regex
|
|
||||||
*/
|
*/
|
||||||
protected function isRegex($str)
|
protected function isRegex(string $str)
|
||||||
{
|
{
|
||||||
if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
|
if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
|
||||||
$start = substr($m[1], 0, 1);
|
$start = substr($m[1], 0, 1);
|
||||||
@@ -91,7 +87,7 @@ abstract class MultiplePcreFilterIterator extends FilterIterator
|
|||||||
return !preg_match('/[*?[:alnum:] \\\\]/', $start);
|
return !preg_match('/[*?[:alnum:] \\\\]/', $start);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array(array('{', '}'), array('(', ')'), array('[', ']'), array('<', '>')) as $delimiters) {
|
foreach ([['{', '}'], ['(', ')'], ['[', ']'], ['<', '>']] as $delimiters) {
|
||||||
if ($start === $delimiters[0] && $end === $delimiters[1]) {
|
if ($start === $delimiters[0] && $end === $delimiters[1]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -104,9 +100,7 @@ abstract class MultiplePcreFilterIterator extends FilterIterator
|
|||||||
/**
|
/**
|
||||||
* Converts string into regexp.
|
* Converts string into regexp.
|
||||||
*
|
*
|
||||||
* @param string $str Pattern
|
* @return string
|
||||||
*
|
|
||||||
* @return string regexp corresponding to a given string
|
|
||||||
*/
|
*/
|
||||||
abstract protected function toRegex($str);
|
abstract protected function toRegex(string $str);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator
|
|||||||
{
|
{
|
||||||
$filename = $this->current()->getRelativePathname();
|
$filename = $this->current()->getRelativePathname();
|
||||||
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||||
$filename = str_replace('\\', '/', $filename);
|
$filename = str_replace('\\', '/', $filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator
|
|||||||
*
|
*
|
||||||
* @return string regexp corresponding to a given string or regexp
|
* @return string regexp corresponding to a given string or regexp
|
||||||
*/
|
*/
|
||||||
protected function toRegex($str)
|
protected function toRegex(string $str)
|
||||||
{
|
{
|
||||||
return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
|
return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,13 +37,9 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|||||||
private $directorySeparator = '/';
|
private $directorySeparator = '/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $path
|
|
||||||
* @param int $flags
|
|
||||||
* @param bool $ignoreUnreadableDirs
|
|
||||||
*
|
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function __construct($path, $flags, $ignoreUnreadableDirs = false)
|
public function __construct(string $path, int $flags, bool $ignoreUnreadableDirs = false)
|
||||||
{
|
{
|
||||||
if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
|
if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
|
||||||
throw new \RuntimeException('This iterator only support returning current as fileinfo.');
|
throw new \RuntimeException('This iterator only support returning current as fileinfo.');
|
||||||
@@ -52,8 +48,8 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|||||||
parent::__construct($path, $flags);
|
parent::__construct($path, $flags);
|
||||||
$this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
|
$this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
|
||||||
$this->rootPath = $path;
|
$this->rootPath = $path;
|
||||||
if ('/' !== DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
|
if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
|
||||||
$this->directorySeparator = DIRECTORY_SEPARATOR;
|
$this->directorySeparator = \DIRECTORY_SEPARATOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +70,11 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|||||||
}
|
}
|
||||||
$subPathname .= $this->getFilename();
|
$subPathname .= $this->getFilename();
|
||||||
|
|
||||||
return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname);
|
if ('/' !== $basePath = $this->rootPath) {
|
||||||
|
$basePath .= $this->directorySeparator;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SplFileInfo($basePath.$subPathname, $this->subPath, $subPathname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,7 +100,7 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|||||||
} catch (\UnexpectedValueException $e) {
|
} catch (\UnexpectedValueException $e) {
|
||||||
if ($this->ignoreUnreadableDirs) {
|
if ($this->ignoreUnreadableDirs) {
|
||||||
// If directory is unreadable and finder is set to ignore it, a fake empty content is returned.
|
// If directory is unreadable and finder is set to ignore it, a fake empty content is returned.
|
||||||
return new \RecursiveArrayIterator(array());
|
return new \RecursiveArrayIterator([]);
|
||||||
} else {
|
} else {
|
||||||
throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
|
throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
|
||||||
}
|
}
|
||||||
@@ -116,11 +116,6 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @see https://bugs.php.net/68557
|
|
||||||
if (\PHP_VERSION_ID < 50523 || \PHP_VERSION_ID >= 50600 && \PHP_VERSION_ID < 50607) {
|
|
||||||
parent::next();
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::rewind();
|
parent::rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,11 +130,6 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
|||||||
return $this->rewindable;
|
return $this->rewindable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround for an HHVM bug, should be removed when https://github.com/facebook/hhvm/issues/7281 is fixed
|
|
||||||
if ('' === $this->getPath()) {
|
|
||||||
return $this->rewindable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (false !== $stream = @opendir($this->getPath())) {
|
if (false !== $stream = @opendir($this->getPath())) {
|
||||||
$infos = stream_get_meta_data($stream);
|
$infos = stream_get_meta_data($stream);
|
||||||
closedir($stream);
|
closedir($stream);
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ use Symfony\Component\Finder\Comparator\NumberComparator;
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class SizeRangeFilterIterator extends FilterIterator
|
class SizeRangeFilterIterator extends \FilterIterator
|
||||||
{
|
{
|
||||||
private $comparators = array();
|
private $comparators = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Iterator $iterator The Iterator to filter
|
* @param \Iterator $iterator The Iterator to filter
|
||||||
|
|||||||
@@ -18,11 +18,13 @@ namespace Symfony\Component\Finder\Iterator;
|
|||||||
*/
|
*/
|
||||||
class SortableIterator implements \IteratorAggregate
|
class SortableIterator implements \IteratorAggregate
|
||||||
{
|
{
|
||||||
|
const SORT_BY_NONE = 0;
|
||||||
const SORT_BY_NAME = 1;
|
const SORT_BY_NAME = 1;
|
||||||
const SORT_BY_TYPE = 2;
|
const SORT_BY_TYPE = 2;
|
||||||
const SORT_BY_ACCESSED_TIME = 3;
|
const SORT_BY_ACCESSED_TIME = 3;
|
||||||
const SORT_BY_CHANGED_TIME = 4;
|
const SORT_BY_CHANGED_TIME = 4;
|
||||||
const SORT_BY_MODIFIED_TIME = 5;
|
const SORT_BY_MODIFIED_TIME = 5;
|
||||||
|
const SORT_BY_NAME_NATURAL = 6;
|
||||||
|
|
||||||
private $iterator;
|
private $iterator;
|
||||||
private $sort;
|
private $sort;
|
||||||
@@ -33,47 +35,66 @@ class SortableIterator implements \IteratorAggregate
|
|||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function __construct(\Traversable $iterator, $sort)
|
public function __construct(\Traversable $iterator, $sort, bool $reverseOrder = false)
|
||||||
{
|
{
|
||||||
$this->iterator = $iterator;
|
$this->iterator = $iterator;
|
||||||
|
$order = $reverseOrder ? -1 : 1;
|
||||||
|
|
||||||
if (self::SORT_BY_NAME === $sort) {
|
if (self::SORT_BY_NAME === $sort) {
|
||||||
$this->sort = function ($a, $b) {
|
$this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
|
||||||
return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
|
return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||||
|
};
|
||||||
|
} elseif (self::SORT_BY_NAME_NATURAL === $sort) {
|
||||||
|
$this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
|
||||||
|
return $order * strnatcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||||
};
|
};
|
||||||
} elseif (self::SORT_BY_TYPE === $sort) {
|
} elseif (self::SORT_BY_TYPE === $sort) {
|
||||||
$this->sort = function ($a, $b) {
|
$this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
|
||||||
if ($a->isDir() && $b->isFile()) {
|
if ($a->isDir() && $b->isFile()) {
|
||||||
return -1;
|
return -$order;
|
||||||
} elseif ($a->isFile() && $b->isDir()) {
|
} elseif ($a->isFile() && $b->isDir()) {
|
||||||
return 1;
|
return $order;
|
||||||
}
|
}
|
||||||
|
|
||||||
return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
|
return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||||
};
|
};
|
||||||
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
|
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
|
||||||
$this->sort = function ($a, $b) {
|
$this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
|
||||||
return $a->getATime() - $b->getATime();
|
return $order * ($a->getATime() - $b->getATime());
|
||||||
};
|
};
|
||||||
} elseif (self::SORT_BY_CHANGED_TIME === $sort) {
|
} elseif (self::SORT_BY_CHANGED_TIME === $sort) {
|
||||||
$this->sort = function ($a, $b) {
|
$this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
|
||||||
return $a->getCTime() - $b->getCTime();
|
return $order * ($a->getCTime() - $b->getCTime());
|
||||||
};
|
};
|
||||||
} elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
|
} elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
|
||||||
$this->sort = function ($a, $b) {
|
$this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
|
||||||
return $a->getMTime() - $b->getMTime();
|
return $order * ($a->getMTime() - $b->getMTime());
|
||||||
};
|
};
|
||||||
} elseif (is_callable($sort)) {
|
} elseif (self::SORT_BY_NONE === $sort) {
|
||||||
$this->sort = $sort;
|
$this->sort = $order;
|
||||||
|
} elseif (\is_callable($sort)) {
|
||||||
|
$this->sort = $reverseOrder ? static function (\SplFileInfo $a, \SplFileInfo $b) use ($sort) { return -$sort($a, $b); } : $sort;
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
|
throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Traversable
|
||||||
|
*/
|
||||||
public function getIterator()
|
public function getIterator()
|
||||||
{
|
{
|
||||||
|
if (1 === $this->sort) {
|
||||||
|
return $this->iterator;
|
||||||
|
}
|
||||||
|
|
||||||
$array = iterator_to_array($this->iterator, true);
|
$array = iterator_to_array($this->iterator, true);
|
||||||
uasort($array, $this->sort);
|
|
||||||
|
if (-1 === $this->sort) {
|
||||||
|
$array = array_reverse($array);
|
||||||
|
} else {
|
||||||
|
uasort($array, $this->sort);
|
||||||
|
}
|
||||||
|
|
||||||
return new \ArrayIterator($array);
|
return new \ArrayIterator($array);
|
||||||
}
|
}
|
||||||
|
|||||||
2
vendor/symfony/finder/LICENSE
vendored
2
vendor/symfony/finder/LICENSE
vendored
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2004-2018 Fabien Potencier
|
Copyright (c) 2004-2020 Fabien Potencier
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
16
vendor/symfony/finder/SplFileInfo.php
vendored
16
vendor/symfony/finder/SplFileInfo.php
vendored
@@ -26,7 +26,7 @@ class SplFileInfo extends \SplFileInfo
|
|||||||
* @param string $relativePath The relative path
|
* @param string $relativePath The relative path
|
||||||
* @param string $relativePathname The relative path name
|
* @param string $relativePathname The relative path name
|
||||||
*/
|
*/
|
||||||
public function __construct($file, $relativePath, $relativePathname)
|
public function __construct(string $file, string $relativePath, string $relativePathname)
|
||||||
{
|
{
|
||||||
parent::__construct($file);
|
parent::__construct($file);
|
||||||
$this->relativePath = $relativePath;
|
$this->relativePath = $relativePath;
|
||||||
@@ -57,6 +57,13 @@ class SplFileInfo extends \SplFileInfo
|
|||||||
return $this->relativePathname;
|
return $this->relativePathname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFilenameWithoutExtension(): string
|
||||||
|
{
|
||||||
|
$filename = $this->getFilename();
|
||||||
|
|
||||||
|
return pathinfo($filename, \PATHINFO_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the contents of the file.
|
* Returns the contents of the file.
|
||||||
*
|
*
|
||||||
@@ -66,12 +73,11 @@ class SplFileInfo extends \SplFileInfo
|
|||||||
*/
|
*/
|
||||||
public function getContents()
|
public function getContents()
|
||||||
{
|
{
|
||||||
$level = error_reporting(0);
|
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
||||||
$content = file_get_contents($this->getPathname());
|
$content = file_get_contents($this->getPathname());
|
||||||
error_reporting($level);
|
restore_error_handler();
|
||||||
if (false === $content) {
|
if (false === $content) {
|
||||||
$error = error_get_last();
|
throw new \RuntimeException($error);
|
||||||
throw new \RuntimeException($error['message']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Comparator;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Symfony\Component\Finder\Comparator\Comparator;
|
|
||||||
|
|
||||||
class ComparatorTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testGetSetOperator()
|
|
||||||
{
|
|
||||||
$comparator = new Comparator();
|
|
||||||
try {
|
|
||||||
$comparator->setOperator('foo');
|
|
||||||
$this->fail('->setOperator() throws an \InvalidArgumentException if the operator is not valid.');
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->assertInstanceOf('InvalidArgumentException', $e, '->setOperator() throws an \InvalidArgumentException if the operator is not valid.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$comparator = new Comparator();
|
|
||||||
$comparator->setOperator('>');
|
|
||||||
$this->assertEquals('>', $comparator->getOperator(), '->getOperator() returns the current operator');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetSetTarget()
|
|
||||||
{
|
|
||||||
$comparator = new Comparator();
|
|
||||||
$comparator->setTarget(8);
|
|
||||||
$this->assertEquals(8, $comparator->getTarget(), '->getTarget() returns the target');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider getTestData
|
|
||||||
*/
|
|
||||||
public function testTest($operator, $target, $match, $noMatch)
|
|
||||||
{
|
|
||||||
$c = new Comparator();
|
|
||||||
$c->setOperator($operator);
|
|
||||||
$c->setTarget($target);
|
|
||||||
|
|
||||||
foreach ($match as $m) {
|
|
||||||
$this->assertTrue($c->test($m), '->test() tests a string against the expression');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($noMatch as $m) {
|
|
||||||
$this->assertFalse($c->test($m), '->test() tests a string against the expression');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTestData()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array('<', '1000', array('500', '999'), array('1000', '1500')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Comparator;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Symfony\Component\Finder\Comparator\DateComparator;
|
|
||||||
|
|
||||||
class DateComparatorTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testConstructor()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
new DateComparator('foobar');
|
|
||||||
$this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
new DateComparator('');
|
|
||||||
$this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider getTestData
|
|
||||||
*/
|
|
||||||
public function testTest($test, $match, $noMatch)
|
|
||||||
{
|
|
||||||
$c = new DateComparator($test);
|
|
||||||
|
|
||||||
foreach ($match as $m) {
|
|
||||||
$this->assertTrue($c->test($m), '->test() tests a string against the expression');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($noMatch as $m) {
|
|
||||||
$this->assertFalse($c->test($m), '->test() tests a string against the expression');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTestData()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array('< 2005-10-10', array(strtotime('2005-10-09')), array(strtotime('2005-10-15'))),
|
|
||||||
array('until 2005-10-10', array(strtotime('2005-10-09')), array(strtotime('2005-10-15'))),
|
|
||||||
array('before 2005-10-10', array(strtotime('2005-10-09')), array(strtotime('2005-10-15'))),
|
|
||||||
array('> 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))),
|
|
||||||
array('after 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))),
|
|
||||||
array('since 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))),
|
|
||||||
array('!= 2005-10-10', array(strtotime('2005-10-11')), array(strtotime('2005-10-10'))),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Comparator;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Symfony\Component\Finder\Comparator\NumberComparator;
|
|
||||||
|
|
||||||
class NumberComparatorTest extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @dataProvider getConstructorTestData
|
|
||||||
*/
|
|
||||||
public function testConstructor($successes, $failures)
|
|
||||||
{
|
|
||||||
foreach ($successes as $s) {
|
|
||||||
new NumberComparator($s);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($failures as $f) {
|
|
||||||
try {
|
|
||||||
new NumberComparator($f);
|
|
||||||
$this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider getTestData
|
|
||||||
*/
|
|
||||||
public function testTest($test, $match, $noMatch)
|
|
||||||
{
|
|
||||||
$c = new NumberComparator($test);
|
|
||||||
|
|
||||||
foreach ($match as $m) {
|
|
||||||
$this->assertTrue($c->test($m), '->test() tests a string against the expression');
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($noMatch as $m) {
|
|
||||||
$this->assertFalse($c->test($m), '->test() tests a string against the expression');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTestData()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array('< 1000', array('500', '999'), array('1000', '1500')),
|
|
||||||
|
|
||||||
array('< 1K', array('500', '999'), array('1000', '1500')),
|
|
||||||
array('<1k', array('500', '999'), array('1000', '1500')),
|
|
||||||
array(' < 1 K ', array('500', '999'), array('1000', '1500')),
|
|
||||||
array('<= 1K', array('1000'), array('1001')),
|
|
||||||
array('> 1K', array('1001'), array('1000')),
|
|
||||||
array('>= 1K', array('1000'), array('999')),
|
|
||||||
|
|
||||||
array('< 1KI', array('500', '1023'), array('1024', '1500')),
|
|
||||||
array('<= 1KI', array('1024'), array('1025')),
|
|
||||||
array('> 1KI', array('1025'), array('1024')),
|
|
||||||
array('>= 1KI', array('1024'), array('1023')),
|
|
||||||
|
|
||||||
array('1KI', array('1024'), array('1023', '1025')),
|
|
||||||
array('==1KI', array('1024'), array('1023', '1025')),
|
|
||||||
|
|
||||||
array('==1m', array('1000000'), array('999999', '1000001')),
|
|
||||||
array('==1mi', array(1024 * 1024), array(1024 * 1024 - 1, 1024 * 1024 + 1)),
|
|
||||||
|
|
||||||
array('==1g', array('1000000000'), array('999999999', '1000000001')),
|
|
||||||
array('==1gi', array(1024 * 1024 * 1024), array(1024 * 1024 * 1024 - 1, 1024 * 1024 * 1024 + 1)),
|
|
||||||
|
|
||||||
array('!= 1000', array('500', '999'), array('1000')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getConstructorTestData()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'1', '0',
|
|
||||||
'3.5', '33.55', '123.456', '123456.78',
|
|
||||||
'.1', '.123',
|
|
||||||
'.0', '0.0',
|
|
||||||
'1.', '0.', '123.',
|
|
||||||
'==1', '!=1', '<1', '>1', '<=1', '>=1',
|
|
||||||
'==1k', '==1ki', '==1m', '==1mi', '==1g', '==1gi',
|
|
||||||
'1k', '1ki', '1m', '1mi', '1g', '1gi',
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
false, null, '',
|
|
||||||
' ', 'foobar',
|
|
||||||
'=1', '===1',
|
|
||||||
'0 . 1', '123 .45', '234. 567',
|
|
||||||
'..', '.0.', '0.1.2',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
737
vendor/symfony/finder/Tests/FinderTest.php
vendored
737
vendor/symfony/finder/Tests/FinderTest.php
vendored
@@ -1,737 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests;
|
|
||||||
|
|
||||||
use Symfony\Component\Finder\Finder;
|
|
||||||
|
|
||||||
class FinderTest extends Iterator\RealIteratorTestCase
|
|
||||||
{
|
|
||||||
public function testCreate()
|
|
||||||
{
|
|
||||||
$this->assertInstanceOf('Symfony\Component\Finder\Finder', Finder::create());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDirectories()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->directories());
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->directories();
|
|
||||||
$finder->files();
|
|
||||||
$finder->directories();
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFiles()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->files());
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->files();
|
|
||||||
$finder->directories();
|
|
||||||
$finder->files();
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRemoveTrailingSlash()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
|
|
||||||
$expected = $this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar'));
|
|
||||||
$in = self::$tmpDir.'//';
|
|
||||||
|
|
||||||
$this->assertIterator($expected, $finder->in($in)->files()->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSymlinksNotResolved()
|
|
||||||
{
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
|
||||||
$this->markTestSkipped('symlinks are not supported on Windows');
|
|
||||||
}
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
|
|
||||||
symlink($this->toAbsolute('foo'), $this->toAbsolute('baz'));
|
|
||||||
$expected = $this->toAbsolute(array('baz/bar.tmp'));
|
|
||||||
$in = self::$tmpDir.'/baz/';
|
|
||||||
try {
|
|
||||||
$this->assertIterator($expected, $finder->in($in)->files()->getIterator());
|
|
||||||
unlink($this->toAbsolute('baz'));
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
unlink($this->toAbsolute('baz'));
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testBackPathNotNormalized()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
|
|
||||||
$expected = $this->toAbsolute(array('foo/../foo/bar.tmp'));
|
|
||||||
$in = self::$tmpDir.'/foo/../foo/';
|
|
||||||
$this->assertIterator($expected, $finder->in($in)->files()->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDepth()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->depth('< 1'));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->depth('<= 0'));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->depth('>= 1'));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->depth('< 1')->depth('>= 1');
|
|
||||||
$this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testName()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->name('*.php'));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->name('test.ph*');
|
|
||||||
$finder->name('test.py');
|
|
||||||
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->name('~^test~i');
|
|
||||||
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->name('~\\.php$~i');
|
|
||||||
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->name('test.p{hp,y}');
|
|
||||||
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNotName()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->notName('*.php'));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->notName('*.php');
|
|
||||||
$finder->notName('*.py');
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->name('test.ph*');
|
|
||||||
$finder->name('test.py');
|
|
||||||
$finder->notName('*.php');
|
|
||||||
$finder->notName('*.py');
|
|
||||||
$this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->name('test.ph*');
|
|
||||||
$finder->name('test.py');
|
|
||||||
$finder->notName('*.p{hp,y}');
|
|
||||||
$this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider getRegexNameTestData
|
|
||||||
*/
|
|
||||||
public function testRegexName($regex)
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->name($regex);
|
|
||||||
$this->assertIterator($this->toAbsolute(array('test.py', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSize()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->files()->size('< 1K')->size('> 500'));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDate()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->files()->date('until last month'));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testExclude()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->exclude('foo'));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIgnoreVCS()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->ignoreVCS(false)->ignoreDotFiles(false));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->ignoreVCS(false)->ignoreVCS(false)->ignoreDotFiles(false);
|
|
||||||
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->ignoreVCS(true)->ignoreDotFiles(false));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIgnoreDotFiles()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->ignoreDotFiles(false)->ignoreVCS(false));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->ignoreDotFiles(false)->ignoreDotFiles(false)->ignoreVCS(false);
|
|
||||||
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->ignoreDotFiles(true)->ignoreVCS(false));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSortByName()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->sortByName());
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSortByType()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->sortByType());
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'toto', 'foo/bar.tmp', 'test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSortByAccessedTime()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->sortByAccessedTime());
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'toto', 'test.py', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSortByChangedTime()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->sortByChangedTime());
|
|
||||||
$this->assertIterator($this->toAbsolute(array('toto', 'test.py', 'test.php', 'foo/bar.tmp', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSortByModifiedTime()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->sortByModifiedTime());
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'toto', 'test.py', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSort()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->sort(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFilter()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) { return false !== strpos($f, 'test'); }));
|
|
||||||
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFollowLinks()
|
|
||||||
{
|
|
||||||
if ('\\' == DIRECTORY_SEPARATOR) {
|
|
||||||
$this->markTestSkipped('symlinks are not supported on Windows');
|
|
||||||
}
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertSame($finder, $finder->followLinks());
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIn()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$iterator = $finder->files()->name('*.php')->depth('< 1')->in(array(self::$tmpDir, __DIR__))->getIterator();
|
|
||||||
|
|
||||||
$expected = array(
|
|
||||||
self::$tmpDir.DIRECTORY_SEPARATOR.'test.php',
|
|
||||||
__DIR__.DIRECTORY_SEPARATOR.'FinderTest.php',
|
|
||||||
__DIR__.DIRECTORY_SEPARATOR.'GlobTest.php',
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertIterator($expected, $iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testInWithNonExistentDirectory()
|
|
||||||
{
|
|
||||||
$finder = new Finder();
|
|
||||||
$finder->in('foobar');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testInWithGlob()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->in(array(__DIR__.'/Fixtures/*/B/C/', __DIR__.'/Fixtures/*/*/B/C/'))->getIterator();
|
|
||||||
|
|
||||||
$this->assertIterator($this->toAbsoluteFixtures(array('A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy')), $finder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testInWithNonDirectoryGlob()
|
|
||||||
{
|
|
||||||
$finder = new Finder();
|
|
||||||
$finder->in(__DIR__.'/Fixtures/A/a*');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testInWithGlobBrace()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->in(array(__DIR__.'/Fixtures/{A,copy/A}/B/C'))->getIterator();
|
|
||||||
|
|
||||||
$this->assertIterator($this->toAbsoluteFixtures(array('A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy')), $finder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \LogicException
|
|
||||||
*/
|
|
||||||
public function testGetIteratorWithoutIn()
|
|
||||||
{
|
|
||||||
$finder = Finder::create();
|
|
||||||
$finder->getIterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetIterator()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$dirs = array();
|
|
||||||
foreach ($finder->directories()->in(self::$tmpDir) as $dir) {
|
|
||||||
$dirs[] = (string) $dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
$expected = $this->toAbsolute(array('foo', 'toto'));
|
|
||||||
|
|
||||||
sort($dirs);
|
|
||||||
sort($expected);
|
|
||||||
|
|
||||||
$this->assertEquals($expected, $dirs, 'implements the \IteratorAggregate interface');
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$this->assertEquals(2, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$a = iterator_to_array($finder->directories()->in(self::$tmpDir));
|
|
||||||
$a = array_values(array_map('strval', $a));
|
|
||||||
sort($a);
|
|
||||||
$this->assertEquals($expected, $a, 'implements the \IteratorAggregate interface');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRelativePath()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder()->in(self::$tmpDir);
|
|
||||||
|
|
||||||
$paths = array();
|
|
||||||
|
|
||||||
foreach ($finder as $file) {
|
|
||||||
$paths[] = $file->getRelativePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
$ref = array('', '', '', '', 'foo', '');
|
|
||||||
|
|
||||||
sort($ref);
|
|
||||||
sort($paths);
|
|
||||||
|
|
||||||
$this->assertEquals($ref, $paths);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRelativePathname()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder()->in(self::$tmpDir)->sortByName();
|
|
||||||
|
|
||||||
$paths = array();
|
|
||||||
|
|
||||||
foreach ($finder as $file) {
|
|
||||||
$paths[] = $file->getRelativePathname();
|
|
||||||
}
|
|
||||||
|
|
||||||
$ref = array('test.php', 'toto', 'test.py', 'foo', 'foo'.DIRECTORY_SEPARATOR.'bar.tmp', 'foo bar');
|
|
||||||
|
|
||||||
sort($paths);
|
|
||||||
sort($ref);
|
|
||||||
|
|
||||||
$this->assertEquals($ref, $paths);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAppendWithAFinder()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->files()->in(self::$tmpDir.DIRECTORY_SEPARATOR.'foo');
|
|
||||||
|
|
||||||
$finder1 = $this->buildFinder();
|
|
||||||
$finder1->directories()->in(self::$tmpDir);
|
|
||||||
|
|
||||||
$finder = $finder->append($finder1);
|
|
||||||
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto')), $finder->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAppendWithAnArray()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->files()->in(self::$tmpDir.DIRECTORY_SEPARATOR.'foo');
|
|
||||||
|
|
||||||
$finder->append($this->toAbsolute(array('foo', 'toto')));
|
|
||||||
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto')), $finder->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAppendReturnsAFinder()
|
|
||||||
{
|
|
||||||
$this->assertInstanceOf('Symfony\\Component\\Finder\\Finder', Finder::create()->append(array()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAppendDoesNotRequireIn()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->in(self::$tmpDir.DIRECTORY_SEPARATOR.'foo');
|
|
||||||
|
|
||||||
$finder1 = Finder::create()->append($finder);
|
|
||||||
|
|
||||||
$this->assertIterator(iterator_to_array($finder->getIterator()), $finder1->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCountDirectories()
|
|
||||||
{
|
|
||||||
$directory = Finder::create()->directories()->in(self::$tmpDir);
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
foreach ($directory as $dir) {
|
|
||||||
++$i;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertCount($i, $directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCountFiles()
|
|
||||||
{
|
|
||||||
$files = Finder::create()->files()->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures');
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
foreach ($files as $file) {
|
|
||||||
++$i;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertCount($i, $files);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \LogicException
|
|
||||||
*/
|
|
||||||
public function testCountWithoutIn()
|
|
||||||
{
|
|
||||||
$finder = Finder::create()->files();
|
|
||||||
count($finder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHasResults()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->in(__DIR__);
|
|
||||||
$this->assertTrue($finder->hasResults());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNoResults()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->in(__DIR__)->name('DoesNotExist');
|
|
||||||
$this->assertFalse($finder->hasResults());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider getContainsTestData
|
|
||||||
*/
|
|
||||||
public function testContains($matchPatterns, $noMatchPatterns, $expected)
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures')
|
|
||||||
->name('*.txt')->sortByName()
|
|
||||||
->contains($matchPatterns)
|
|
||||||
->notContains($noMatchPatterns);
|
|
||||||
|
|
||||||
$this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testContainsOnDirectory()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->in(__DIR__)
|
|
||||||
->directories()
|
|
||||||
->name('Fixtures')
|
|
||||||
->contains('abc');
|
|
||||||
$this->assertIterator(array(), $finder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNotContainsOnDirectory()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->in(__DIR__)
|
|
||||||
->directories()
|
|
||||||
->name('Fixtures')
|
|
||||||
->notContains('abc');
|
|
||||||
$this->assertIterator(array(), $finder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Searching in multiple locations involves AppendIterator which does an unnecessary rewind which leaves FilterIterator
|
|
||||||
* with inner FilesystemIterator in an invalid state.
|
|
||||||
*
|
|
||||||
* @see https://bugs.php.net/68557
|
|
||||||
*/
|
|
||||||
public function testMultipleLocations()
|
|
||||||
{
|
|
||||||
$locations = array(
|
|
||||||
self::$tmpDir.'/',
|
|
||||||
self::$tmpDir.'/toto/',
|
|
||||||
);
|
|
||||||
|
|
||||||
// it is expected that there are test.py test.php in the tmpDir
|
|
||||||
$finder = new Finder();
|
|
||||||
$finder->in($locations)
|
|
||||||
// the default flag IGNORE_DOT_FILES fixes the problem indirectly
|
|
||||||
// so we set it to false for better isolation
|
|
||||||
->ignoreDotFiles(false)
|
|
||||||
->depth('< 1')->name('test.php');
|
|
||||||
|
|
||||||
$this->assertCount(1, $finder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Searching in multiple locations with sub directories involves
|
|
||||||
* AppendIterator which does an unnecessary rewind which leaves
|
|
||||||
* FilterIterator with inner FilesystemIterator in an invalid state.
|
|
||||||
*
|
|
||||||
* @see https://bugs.php.net/68557
|
|
||||||
*/
|
|
||||||
public function testMultipleLocationsWithSubDirectories()
|
|
||||||
{
|
|
||||||
$locations = array(
|
|
||||||
__DIR__.'/Fixtures/one',
|
|
||||||
self::$tmpDir.DIRECTORY_SEPARATOR.'toto',
|
|
||||||
);
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->in($locations)->depth('< 10')->name('*.neon');
|
|
||||||
|
|
||||||
$expected = array(
|
|
||||||
__DIR__.'/Fixtures/one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'c.neon',
|
|
||||||
__DIR__.'/Fixtures/one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'d.neon',
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertIterator($expected, $finder);
|
|
||||||
$this->assertIteratorInForeach($expected, $finder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Iterator keys must be the file pathname.
|
|
||||||
*/
|
|
||||||
public function testIteratorKeys()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder()->in(self::$tmpDir);
|
|
||||||
foreach ($finder as $key => $file) {
|
|
||||||
$this->assertEquals($file->getPathname(), $key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartFlag()
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.gex[c]a(r)s')
|
|
||||||
->path('/^dir/');
|
|
||||||
|
|
||||||
$expected = array('r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir', 'r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat');
|
|
||||||
$this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getContainsTestData()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array('', '', array()),
|
|
||||||
array('foo', 'bar', array()),
|
|
||||||
array('', 'foobar', array('dolor.txt', 'ipsum.txt', 'lorem.txt')),
|
|
||||||
array('lorem ipsum dolor sit amet', 'foobar', array('lorem.txt')),
|
|
||||||
array('sit', 'bar', array('dolor.txt', 'ipsum.txt', 'lorem.txt')),
|
|
||||||
array('dolor sit amet', '@^L@m', array('dolor.txt', 'ipsum.txt')),
|
|
||||||
array('/^lorem ipsum dolor sit amet$/m', 'foobar', array('lorem.txt')),
|
|
||||||
array('lorem', 'foobar', array('lorem.txt')),
|
|
||||||
array('', 'lorem', array('dolor.txt', 'ipsum.txt')),
|
|
||||||
array('ipsum dolor sit amet', '/^IPSUM/m', array('lorem.txt')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRegexNameTestData()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array('~.+\\.p.+~i'),
|
|
||||||
array('~t.*s~i'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider getTestPathData
|
|
||||||
*/
|
|
||||||
public function testPath($matchPatterns, $noMatchPatterns, array $expected)
|
|
||||||
{
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures')
|
|
||||||
->path($matchPatterns)
|
|
||||||
->notPath($noMatchPatterns);
|
|
||||||
|
|
||||||
$this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTestPathData()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array('', '', array()),
|
|
||||||
array('/^A\/B\/C/', '/C$/',
|
|
||||||
array('A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat'),
|
|
||||||
),
|
|
||||||
array('/^A\/B/', 'foobar',
|
|
||||||
array(
|
|
||||||
'A'.DIRECTORY_SEPARATOR.'B',
|
|
||||||
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
|
|
||||||
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat',
|
|
||||||
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
array('A/B/C', 'foobar',
|
|
||||||
array(
|
|
||||||
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
|
|
||||||
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
|
|
||||||
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
|
|
||||||
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
array('A/B', 'foobar',
|
|
||||||
array(
|
|
||||||
//dirs
|
|
||||||
'A'.DIRECTORY_SEPARATOR.'B',
|
|
||||||
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
|
|
||||||
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B',
|
|
||||||
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
|
|
||||||
//files
|
|
||||||
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat',
|
|
||||||
'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
|
|
||||||
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat.copy',
|
|
||||||
'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
array('/^with space\//', 'foobar',
|
|
||||||
array(
|
|
||||||
'with space'.DIRECTORY_SEPARATOR.'foo.txt',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAccessDeniedException()
|
|
||||||
{
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
|
||||||
$this->markTestSkipped('chmod is not supported on Windows');
|
|
||||||
}
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->files()->in(self::$tmpDir);
|
|
||||||
|
|
||||||
// make 'foo' directory non-readable
|
|
||||||
$testDir = self::$tmpDir.DIRECTORY_SEPARATOR.'foo';
|
|
||||||
chmod($testDir, 0333);
|
|
||||||
|
|
||||||
if (false === $couldRead = is_readable($testDir)) {
|
|
||||||
try {
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator());
|
|
||||||
$this->fail('Finder should throw an exception when opening a non-readable directory.');
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$expectedExceptionClass = 'Symfony\\Component\\Finder\\Exception\\AccessDeniedException';
|
|
||||||
if ($e instanceof \PHPUnit_Framework_ExpectationFailedException) {
|
|
||||||
$this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, 'PHPUnit_Framework_ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($e instanceof \PHPUnit\Framework\ExpectationFailedException) {
|
|
||||||
$this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, '\PHPUnit\Framework\ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertInstanceOf($expectedExceptionClass, $e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// restore original permissions
|
|
||||||
chmod($testDir, 0777);
|
|
||||||
clearstatcache($testDir);
|
|
||||||
|
|
||||||
if ($couldRead) {
|
|
||||||
$this->markTestSkipped('could read test files while test requires unreadable');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIgnoredAccessDeniedException()
|
|
||||||
{
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
|
||||||
$this->markTestSkipped('chmod is not supported on Windows');
|
|
||||||
}
|
|
||||||
|
|
||||||
$finder = $this->buildFinder();
|
|
||||||
$finder->files()->ignoreUnreadableDirs()->in(self::$tmpDir);
|
|
||||||
|
|
||||||
// make 'foo' directory non-readable
|
|
||||||
$testDir = self::$tmpDir.DIRECTORY_SEPARATOR.'foo';
|
|
||||||
chmod($testDir, 0333);
|
|
||||||
|
|
||||||
if (false === ($couldRead = is_readable($testDir))) {
|
|
||||||
$this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator());
|
|
||||||
}
|
|
||||||
|
|
||||||
// restore original permissions
|
|
||||||
chmod($testDir, 0777);
|
|
||||||
clearstatcache($testDir);
|
|
||||||
|
|
||||||
if ($couldRead) {
|
|
||||||
$this->markTestSkipped('could read test files while test requires unreadable');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function buildFinder()
|
|
||||||
{
|
|
||||||
return Finder::create();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
dolor sit amet
|
|
||||||
DOLOR SIT AMET
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
ipsum dolor sit amet
|
|
||||||
IPSUM DOLOR SIT AMET
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
lorem ipsum dolor sit amet
|
|
||||||
LOREM IPSUM DOLOR SIT AMET
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
.dot
|
|
||||||
95
vendor/symfony/finder/Tests/GlobTest.php
vendored
95
vendor/symfony/finder/Tests/GlobTest.php
vendored
@@ -1,95 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Symfony\Component\Finder\Finder;
|
|
||||||
use Symfony\Component\Finder\Glob;
|
|
||||||
|
|
||||||
class GlobTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testGlobToRegexDelimiters()
|
|
||||||
{
|
|
||||||
$this->assertEquals('#^(?=[^\.])\#$#', Glob::toRegex('#'));
|
|
||||||
$this->assertEquals('#^\.[^/]*$#', Glob::toRegex('.*'));
|
|
||||||
$this->assertEquals('^\.[^/]*$', Glob::toRegex('.*', true, true, ''));
|
|
||||||
$this->assertEquals('/^\.[^/]*$/', Glob::toRegex('.*', true, true, '/'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGlobToRegexDoubleStarStrictDots()
|
|
||||||
{
|
|
||||||
$finder = new Finder();
|
|
||||||
$finder->ignoreDotFiles(false);
|
|
||||||
$regex = Glob::toRegex('/**/*.neon');
|
|
||||||
|
|
||||||
foreach ($finder->in(__DIR__) as $k => $v) {
|
|
||||||
$k = str_replace(DIRECTORY_SEPARATOR, '/', $k);
|
|
||||||
if (preg_match($regex, substr($k, strlen(__DIR__)))) {
|
|
||||||
$match[] = substr($k, 10 + strlen(__DIR__));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sort($match);
|
|
||||||
|
|
||||||
$this->assertSame(array('one/b/c.neon', 'one/b/d.neon'), $match);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGlobToRegexDoubleStarNonStrictDots()
|
|
||||||
{
|
|
||||||
$finder = new Finder();
|
|
||||||
$finder->ignoreDotFiles(false);
|
|
||||||
$regex = Glob::toRegex('/**/*.neon', false);
|
|
||||||
|
|
||||||
foreach ($finder->in(__DIR__) as $k => $v) {
|
|
||||||
$k = str_replace(DIRECTORY_SEPARATOR, '/', $k);
|
|
||||||
if (preg_match($regex, substr($k, strlen(__DIR__)))) {
|
|
||||||
$match[] = substr($k, 10 + strlen(__DIR__));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sort($match);
|
|
||||||
|
|
||||||
$this->assertSame(array('.dot/b/c.neon', '.dot/b/d.neon', 'one/b/c.neon', 'one/b/d.neon'), $match);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGlobToRegexDoubleStarWithoutLeadingSlash()
|
|
||||||
{
|
|
||||||
$finder = new Finder();
|
|
||||||
$finder->ignoreDotFiles(false);
|
|
||||||
$regex = Glob::toRegex('/Fixtures/one/**');
|
|
||||||
|
|
||||||
foreach ($finder->in(__DIR__) as $k => $v) {
|
|
||||||
$k = str_replace(DIRECTORY_SEPARATOR, '/', $k);
|
|
||||||
if (preg_match($regex, substr($k, strlen(__DIR__)))) {
|
|
||||||
$match[] = substr($k, 10 + strlen(__DIR__));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sort($match);
|
|
||||||
|
|
||||||
$this->assertSame(array('one/a', 'one/b', 'one/b/c.neon', 'one/b/d.neon'), $match);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGlobToRegexDoubleStarWithoutLeadingSlashNotStrictLeadingDot()
|
|
||||||
{
|
|
||||||
$finder = new Finder();
|
|
||||||
$finder->ignoreDotFiles(false);
|
|
||||||
$regex = Glob::toRegex('/Fixtures/one/**', false);
|
|
||||||
|
|
||||||
foreach ($finder->in(__DIR__) as $k => $v) {
|
|
||||||
$k = str_replace(DIRECTORY_SEPARATOR, '/', $k);
|
|
||||||
if (preg_match($regex, substr($k, strlen(__DIR__)))) {
|
|
||||||
$match[] = substr($k, 10 + strlen(__DIR__));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sort($match);
|
|
||||||
|
|
||||||
$this->assertSame(array('one/.dot', 'one/a', 'one/b', 'one/b/c.neon', 'one/b/d.neon'), $match);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use Symfony\Component\Finder\Iterator\CustomFilterIterator;
|
|
||||||
|
|
||||||
class CustomFilterIteratorTest extends IteratorTestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testWithInvalidFilter()
|
|
||||||
{
|
|
||||||
new CustomFilterIterator(new Iterator(), array('foo'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider getAcceptData
|
|
||||||
*/
|
|
||||||
public function testAccept($filters, $expected)
|
|
||||||
{
|
|
||||||
$inner = new Iterator(array('test.php', 'test.py', 'foo.php'));
|
|
||||||
|
|
||||||
$iterator = new CustomFilterIterator($inner, $filters);
|
|
||||||
|
|
||||||
$this->assertIterator($expected, $iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAcceptData()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array(array(function (\SplFileInfo $fileinfo) { return false; }), array()),
|
|
||||||
array(array(function (\SplFileInfo $fileinfo) { return 0 === strpos($fileinfo, 'test'); }), array('test.php', 'test.py')),
|
|
||||||
array(array('is_dir'), array()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
|
|
||||||
use Symfony\Component\Finder\Comparator\DateComparator;
|
|
||||||
|
|
||||||
class DateRangeFilterIteratorTest extends RealIteratorTestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @dataProvider getAcceptData
|
|
||||||
*/
|
|
||||||
public function testAccept($size, $expected)
|
|
||||||
{
|
|
||||||
$files = self::$files;
|
|
||||||
$files[] = self::toAbsolute('doesnotexist');
|
|
||||||
$inner = new Iterator($files);
|
|
||||||
|
|
||||||
$iterator = new DateRangeFilterIterator($inner, $size);
|
|
||||||
|
|
||||||
$this->assertIterator($expected, $iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAcceptData()
|
|
||||||
{
|
|
||||||
$since20YearsAgo = array(
|
|
||||||
'.git',
|
|
||||||
'test.py',
|
|
||||||
'foo',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'test.php',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
'.bar',
|
|
||||||
'.foo',
|
|
||||||
'.foo/.bar',
|
|
||||||
'foo bar',
|
|
||||||
'.foo/bar',
|
|
||||||
);
|
|
||||||
|
|
||||||
$since2MonthsAgo = array(
|
|
||||||
'.git',
|
|
||||||
'test.py',
|
|
||||||
'foo',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
'.bar',
|
|
||||||
'.foo',
|
|
||||||
'.foo/.bar',
|
|
||||||
'foo bar',
|
|
||||||
'.foo/bar',
|
|
||||||
);
|
|
||||||
|
|
||||||
$untilLastMonth = array(
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'test.php',
|
|
||||||
);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array(array(new DateComparator('since 20 years ago')), $this->toAbsolute($since20YearsAgo)),
|
|
||||||
array(array(new DateComparator('since 2 months ago')), $this->toAbsolute($since2MonthsAgo)),
|
|
||||||
array(array(new DateComparator('until last month')), $this->toAbsolute($untilLastMonth)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
|
|
||||||
|
|
||||||
class DepthRangeFilterIteratorTest extends RealIteratorTestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @dataProvider getAcceptData
|
|
||||||
*/
|
|
||||||
public function testAccept($minDepth, $maxDepth, $expected)
|
|
||||||
{
|
|
||||||
$inner = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
|
|
||||||
|
|
||||||
$iterator = new DepthRangeFilterIterator($inner, $minDepth, $maxDepth);
|
|
||||||
|
|
||||||
$actual = array_keys(iterator_to_array($iterator));
|
|
||||||
sort($expected);
|
|
||||||
sort($actual);
|
|
||||||
$this->assertEquals($expected, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAcceptData()
|
|
||||||
{
|
|
||||||
$lessThan1 = array(
|
|
||||||
'.git',
|
|
||||||
'test.py',
|
|
||||||
'foo',
|
|
||||||
'test.php',
|
|
||||||
'toto',
|
|
||||||
'.foo',
|
|
||||||
'.bar',
|
|
||||||
'foo bar',
|
|
||||||
);
|
|
||||||
|
|
||||||
$lessThanOrEqualTo1 = array(
|
|
||||||
'.git',
|
|
||||||
'test.py',
|
|
||||||
'foo',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'test.php',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
'.foo',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.bar',
|
|
||||||
'foo bar',
|
|
||||||
'.foo/bar',
|
|
||||||
);
|
|
||||||
|
|
||||||
$graterThanOrEqualTo1 = array(
|
|
||||||
'toto/.git',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
);
|
|
||||||
|
|
||||||
$equalTo1 = array(
|
|
||||||
'toto/.git',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array(0, 0, $this->toAbsolute($lessThan1)),
|
|
||||||
array(0, 1, $this->toAbsolute($lessThanOrEqualTo1)),
|
|
||||||
array(2, PHP_INT_MAX, array()),
|
|
||||||
array(1, PHP_INT_MAX, $this->toAbsolute($graterThanOrEqualTo1)),
|
|
||||||
array(1, 1, $this->toAbsolute($equalTo1)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
|
|
||||||
use Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator;
|
|
||||||
|
|
||||||
class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @dataProvider getAcceptData
|
|
||||||
*/
|
|
||||||
public function testAccept($directories, $expected)
|
|
||||||
{
|
|
||||||
$inner = new \RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
|
|
||||||
|
|
||||||
$iterator = new ExcludeDirectoryFilterIterator($inner, $directories);
|
|
||||||
|
|
||||||
$this->assertIterator($expected, $iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAcceptData()
|
|
||||||
{
|
|
||||||
$foo = array(
|
|
||||||
'.bar',
|
|
||||||
'.foo',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
'.git',
|
|
||||||
'test.py',
|
|
||||||
'test.php',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
'foo bar',
|
|
||||||
);
|
|
||||||
|
|
||||||
$fo = array(
|
|
||||||
'.bar',
|
|
||||||
'.foo',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
'.git',
|
|
||||||
'test.py',
|
|
||||||
'foo',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'test.php',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
'foo bar',
|
|
||||||
);
|
|
||||||
|
|
||||||
$toto = array(
|
|
||||||
'.bar',
|
|
||||||
'.foo',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
'.git',
|
|
||||||
'test.py',
|
|
||||||
'foo',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'test.php',
|
|
||||||
'foo bar',
|
|
||||||
);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array(array('foo'), $this->toAbsolute($foo)),
|
|
||||||
array(array('fo'), $this->toAbsolute($fo)),
|
|
||||||
array(array('toto/'), $this->toAbsolute($toto)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use Symfony\Component\Finder\Iterator\FileTypeFilterIterator;
|
|
||||||
|
|
||||||
class FileTypeFilterIteratorTest extends RealIteratorTestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @dataProvider getAcceptData
|
|
||||||
*/
|
|
||||||
public function testAccept($mode, $expected)
|
|
||||||
{
|
|
||||||
$inner = new InnerTypeIterator(self::$files);
|
|
||||||
|
|
||||||
$iterator = new FileTypeFilterIterator($inner, $mode);
|
|
||||||
|
|
||||||
$this->assertIterator($expected, $iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAcceptData()
|
|
||||||
{
|
|
||||||
$onlyFiles = array(
|
|
||||||
'test.py',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'test.php',
|
|
||||||
'.bar',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
'foo bar',
|
|
||||||
);
|
|
||||||
|
|
||||||
$onlyDirectories = array(
|
|
||||||
'.git',
|
|
||||||
'foo',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
'.foo',
|
|
||||||
);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array(FileTypeFilterIterator::ONLY_FILES, $this->toAbsolute($onlyFiles)),
|
|
||||||
array(FileTypeFilterIterator::ONLY_DIRECTORIES, $this->toAbsolute($onlyDirectories)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InnerTypeIterator extends \ArrayIterator
|
|
||||||
{
|
|
||||||
public function current()
|
|
||||||
{
|
|
||||||
return new \SplFileInfo(parent::current());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isFile()
|
|
||||||
{
|
|
||||||
return $this->current()->isFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isDir()
|
|
||||||
{
|
|
||||||
return $this->current()->isDir();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
|
|
||||||
|
|
||||||
class FilecontentFilterIteratorTest extends IteratorTestCase
|
|
||||||
{
|
|
||||||
public function testAccept()
|
|
||||||
{
|
|
||||||
$inner = new MockFileListIterator(array('test.txt'));
|
|
||||||
$iterator = new FilecontentFilterIterator($inner, array(), array());
|
|
||||||
$this->assertIterator(array('test.txt'), $iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDirectory()
|
|
||||||
{
|
|
||||||
$inner = new MockFileListIterator(array('directory'));
|
|
||||||
$iterator = new FilecontentFilterIterator($inner, array('directory'), array());
|
|
||||||
$this->assertIterator(array(), $iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUnreadableFile()
|
|
||||||
{
|
|
||||||
$inner = new MockFileListIterator(array('file r-'));
|
|
||||||
$iterator = new FilecontentFilterIterator($inner, array('file r-'), array());
|
|
||||||
$this->assertIterator(array(), $iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider getTestFilterData
|
|
||||||
*/
|
|
||||||
public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatchPatterns, array $resultArray)
|
|
||||||
{
|
|
||||||
$iterator = new FilecontentFilterIterator($inner, $matchPatterns, $noMatchPatterns);
|
|
||||||
$this->assertIterator($resultArray, $iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTestFilterData()
|
|
||||||
{
|
|
||||||
$inner = new MockFileListIterator();
|
|
||||||
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
|
||||||
'name' => 'a.txt',
|
|
||||||
'contents' => 'Lorem ipsum...',
|
|
||||||
'type' => 'file',
|
|
||||||
'mode' => 'r+', )
|
|
||||||
);
|
|
||||||
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
|
||||||
'name' => 'b.yml',
|
|
||||||
'contents' => 'dolor sit...',
|
|
||||||
'type' => 'file',
|
|
||||||
'mode' => 'r+', )
|
|
||||||
);
|
|
||||||
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
|
||||||
'name' => 'some/other/dir/third.php',
|
|
||||||
'contents' => 'amet...',
|
|
||||||
'type' => 'file',
|
|
||||||
'mode' => 'r+', )
|
|
||||||
);
|
|
||||||
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
|
||||||
'name' => 'unreadable-file.txt',
|
|
||||||
'contents' => false,
|
|
||||||
'type' => 'file',
|
|
||||||
'mode' => 'r+', )
|
|
||||||
);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array($inner, array('.'), array(), array('a.txt', 'b.yml', 'some/other/dir/third.php')),
|
|
||||||
array($inner, array('ipsum'), array(), array('a.txt')),
|
|
||||||
array($inner, array('i', 'amet'), array('Lorem', 'amet'), array('b.yml')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
|
|
||||||
|
|
||||||
class FilenameFilterIteratorTest extends IteratorTestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @dataProvider getAcceptData
|
|
||||||
*/
|
|
||||||
public function testAccept($matchPatterns, $noMatchPatterns, $expected)
|
|
||||||
{
|
|
||||||
$inner = new InnerNameIterator(array('test.php', 'test.py', 'foo.php'));
|
|
||||||
|
|
||||||
$iterator = new FilenameFilterIterator($inner, $matchPatterns, $noMatchPatterns);
|
|
||||||
|
|
||||||
$this->assertIterator($expected, $iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAcceptData()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array(array('test.*'), array(), array('test.php', 'test.py')),
|
|
||||||
array(array(), array('test.*'), array('foo.php')),
|
|
||||||
array(array('*.php'), array('test.*'), array('foo.php')),
|
|
||||||
array(array('*.php', '*.py'), array('foo.*'), array('test.php', 'test.py')),
|
|
||||||
array(array('/\.php$/'), array(), array('test.php', 'foo.php')),
|
|
||||||
array(array(), array('/\.php$/'), array('test.py')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InnerNameIterator extends \ArrayIterator
|
|
||||||
{
|
|
||||||
public function current()
|
|
||||||
{
|
|
||||||
return new \SplFileInfo(parent::current());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFilename()
|
|
||||||
{
|
|
||||||
return parent::current();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Alex Bogomazov
|
|
||||||
*
|
|
||||||
* @group legacy
|
|
||||||
*/
|
|
||||||
class FilterIteratorTest extends RealIteratorTestCase
|
|
||||||
{
|
|
||||||
public function testFilterFilesystemIterators()
|
|
||||||
{
|
|
||||||
$i = new \FilesystemIterator($this->toAbsolute());
|
|
||||||
|
|
||||||
// it is expected that there are test.py test.php in the tmpDir
|
|
||||||
$i = $this->getMockForAbstractClass('Symfony\Component\Finder\Iterator\FilterIterator', array($i));
|
|
||||||
$i->expects($this->any())
|
|
||||||
->method('accept')
|
|
||||||
->will($this->returnCallback(function () use ($i) {
|
|
||||||
return (bool) preg_match('/\.php/', (string) $i->current());
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
$c = 0;
|
|
||||||
foreach ($i as $item) {
|
|
||||||
++$c;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals(1, $c);
|
|
||||||
|
|
||||||
$i->rewind();
|
|
||||||
|
|
||||||
$c = 0;
|
|
||||||
foreach ($i as $item) {
|
|
||||||
++$c;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This would fail in php older than 5.5.23/5.6.7 with \FilterIterator
|
|
||||||
// but works with Symfony\Component\Finder\Iterator\FilterIterator
|
|
||||||
// see https://bugs.php.net/68557
|
|
||||||
$this->assertEquals(1, $c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
class Iterator implements \Iterator
|
|
||||||
{
|
|
||||||
protected $values = array();
|
|
||||||
|
|
||||||
public function __construct(array $values = array())
|
|
||||||
{
|
|
||||||
foreach ($values as $value) {
|
|
||||||
$this->attach(new \SplFileInfo($value));
|
|
||||||
}
|
|
||||||
$this->rewind();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function attach(\SplFileInfo $fileinfo)
|
|
||||||
{
|
|
||||||
$this->values[] = $fileinfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function rewind()
|
|
||||||
{
|
|
||||||
reset($this->values);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function valid()
|
|
||||||
{
|
|
||||||
return false !== $this->current();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function next()
|
|
||||||
{
|
|
||||||
next($this->values);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function current()
|
|
||||||
{
|
|
||||||
return current($this->values);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function key()
|
|
||||||
{
|
|
||||||
return key($this->values);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
abstract class IteratorTestCase extends TestCase
|
|
||||||
{
|
|
||||||
protected function assertIterator($expected, \Traversable $iterator)
|
|
||||||
{
|
|
||||||
// set iterator_to_array $use_key to false to avoid values merge
|
|
||||||
// this made FinderTest::testAppendWithAnArray() fail with GnuFinderAdapter
|
|
||||||
$values = array_map(function (\SplFileInfo $fileinfo) { return str_replace('/', DIRECTORY_SEPARATOR, $fileinfo->getPathname()); }, iterator_to_array($iterator, false));
|
|
||||||
|
|
||||||
$expected = array_map(function ($path) { return str_replace('/', DIRECTORY_SEPARATOR, $path); }, $expected);
|
|
||||||
|
|
||||||
sort($values);
|
|
||||||
sort($expected);
|
|
||||||
|
|
||||||
$this->assertEquals($expected, array_values($values));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function assertOrderedIterator($expected, \Traversable $iterator)
|
|
||||||
{
|
|
||||||
$values = array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator));
|
|
||||||
|
|
||||||
$this->assertEquals($expected, array_values($values));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Same as assertOrderedIterator, but checks the order of groups of
|
|
||||||
* array elements.
|
|
||||||
*
|
|
||||||
* @param array $expected - an array of arrays. For any two subarrays
|
|
||||||
* $a and $b such that $a goes before $b in $expected, the method
|
|
||||||
* asserts that any element of $a goes before any element of $b
|
|
||||||
* in the sequence generated by $iterator
|
|
||||||
* @param \Traversable $iterator
|
|
||||||
*/
|
|
||||||
protected function assertOrderedIteratorForGroups($expected, \Traversable $iterator)
|
|
||||||
{
|
|
||||||
$values = array_values(array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator)));
|
|
||||||
|
|
||||||
foreach ($expected as $subarray) {
|
|
||||||
$temp = array();
|
|
||||||
while (count($values) && count($temp) < count($subarray)) {
|
|
||||||
$temp[] = array_shift($values);
|
|
||||||
}
|
|
||||||
sort($temp);
|
|
||||||
sort($subarray);
|
|
||||||
$this->assertEquals($subarray, $temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Same as IteratorTestCase::assertIterator with foreach usage.
|
|
||||||
*
|
|
||||||
* @param array $expected
|
|
||||||
* @param \Traversable $iterator
|
|
||||||
*/
|
|
||||||
protected function assertIteratorInForeach($expected, \Traversable $iterator)
|
|
||||||
{
|
|
||||||
$values = array();
|
|
||||||
foreach ($iterator as $file) {
|
|
||||||
$this->assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $file);
|
|
||||||
$values[] = $file->getPathname();
|
|
||||||
}
|
|
||||||
|
|
||||||
sort($values);
|
|
||||||
sort($expected);
|
|
||||||
|
|
||||||
$this->assertEquals($expected, array_values($values));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Same as IteratorTestCase::assertOrderedIterator with foreach usage.
|
|
||||||
*
|
|
||||||
* @param array $expected
|
|
||||||
* @param \Traversable $iterator
|
|
||||||
*/
|
|
||||||
protected function assertOrderedIteratorInForeach($expected, \Traversable $iterator)
|
|
||||||
{
|
|
||||||
$values = array();
|
|
||||||
foreach ($iterator as $file) {
|
|
||||||
$this->assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $file);
|
|
||||||
$values[] = $file->getPathname();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals($expected, array_values($values));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
class MockFileListIterator extends \ArrayIterator
|
|
||||||
{
|
|
||||||
public function __construct(array $filesArray = array())
|
|
||||||
{
|
|
||||||
$files = array_map(function ($file) { return new MockSplFileInfo($file); }, $filesArray);
|
|
||||||
parent::__construct($files);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
class MockSplFileInfo extends \SplFileInfo
|
|
||||||
{
|
|
||||||
const TYPE_DIRECTORY = 1;
|
|
||||||
const TYPE_FILE = 2;
|
|
||||||
const TYPE_UNKNOWN = 3;
|
|
||||||
|
|
||||||
private $contents = null;
|
|
||||||
private $mode = null;
|
|
||||||
private $type = null;
|
|
||||||
private $relativePath = null;
|
|
||||||
private $relativePathname = null;
|
|
||||||
|
|
||||||
public function __construct($param)
|
|
||||||
{
|
|
||||||
if (is_string($param)) {
|
|
||||||
parent::__construct($param);
|
|
||||||
} elseif (is_array($param)) {
|
|
||||||
$defaults = array(
|
|
||||||
'name' => 'file.txt',
|
|
||||||
'contents' => null,
|
|
||||||
'mode' => null,
|
|
||||||
'type' => null,
|
|
||||||
'relativePath' => null,
|
|
||||||
'relativePathname' => null,
|
|
||||||
);
|
|
||||||
$defaults = array_merge($defaults, $param);
|
|
||||||
parent::__construct($defaults['name']);
|
|
||||||
$this->setContents($defaults['contents']);
|
|
||||||
$this->setMode($defaults['mode']);
|
|
||||||
$this->setType($defaults['type']);
|
|
||||||
$this->setRelativePath($defaults['relativePath']);
|
|
||||||
$this->setRelativePathname($defaults['relativePathname']);
|
|
||||||
} else {
|
|
||||||
throw new \RuntimeException(sprintf('Incorrect parameter "%s"', $param));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isFile()
|
|
||||||
{
|
|
||||||
if (null === $this->type) {
|
|
||||||
return false !== strpos($this->getFilename(), 'file');
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::TYPE_FILE === $this->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isDir()
|
|
||||||
{
|
|
||||||
if (null === $this->type) {
|
|
||||||
return false !== strpos($this->getFilename(), 'directory');
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::TYPE_DIRECTORY === $this->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isReadable()
|
|
||||||
{
|
|
||||||
if (null === $this->mode) {
|
|
||||||
return preg_match('/r\+/', $this->getFilename());
|
|
||||||
}
|
|
||||||
|
|
||||||
return preg_match('/r\+/', $this->mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getContents()
|
|
||||||
{
|
|
||||||
return $this->contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setContents($contents)
|
|
||||||
{
|
|
||||||
$this->contents = $contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setMode($mode)
|
|
||||||
{
|
|
||||||
$this->mode = $mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setType($type)
|
|
||||||
{
|
|
||||||
if (is_string($type)) {
|
|
||||||
switch ($type) {
|
|
||||||
case 'directory':
|
|
||||||
case 'd':
|
|
||||||
$this->type = self::TYPE_DIRECTORY;
|
|
||||||
break;
|
|
||||||
case 'file':
|
|
||||||
case 'f':
|
|
||||||
$this->type = self::TYPE_FILE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$this->type = self::TYPE_UNKNOWN;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$this->type = $type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setRelativePath($relativePath)
|
|
||||||
{
|
|
||||||
$this->relativePath = $relativePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setRelativePathname($relativePathname)
|
|
||||||
{
|
|
||||||
$this->relativePathname = $relativePathname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRelativePath()
|
|
||||||
{
|
|
||||||
return $this->relativePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRelativePathname()
|
|
||||||
{
|
|
||||||
return $this->relativePathname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Symfony\Component\Finder\Iterator\MultiplePcreFilterIterator;
|
|
||||||
|
|
||||||
class MultiplePcreFilterIteratorTest extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @dataProvider getIsRegexFixtures
|
|
||||||
*/
|
|
||||||
public function testIsRegex($string, $isRegex, $message)
|
|
||||||
{
|
|
||||||
$testIterator = new TestMultiplePcreFilterIterator();
|
|
||||||
$this->assertEquals($isRegex, $testIterator->isRegex($string), $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIsRegexFixtures()
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
array('foo', false, 'string'),
|
|
||||||
array(' foo ', false, '" " is not a valid delimiter'),
|
|
||||||
array('\\foo\\', false, '"\\" is not a valid delimiter'),
|
|
||||||
array('afooa', false, '"a" is not a valid delimiter'),
|
|
||||||
array('//', false, 'the pattern should contain at least 1 character'),
|
|
||||||
array('/a/', true, 'valid regex'),
|
|
||||||
array('/foo/', true, 'valid regex'),
|
|
||||||
array('/foo/i', true, 'valid regex with a single modifier'),
|
|
||||||
array('/foo/imsxu', true, 'valid regex with multiple modifiers'),
|
|
||||||
array('#foo#', true, '"#" is a valid delimiter'),
|
|
||||||
array('{foo}', true, '"{,}" is a valid delimiter pair'),
|
|
||||||
array('[foo]', true, '"[,]" is a valid delimiter pair'),
|
|
||||||
array('(foo)', true, '"(,)" is a valid delimiter pair'),
|
|
||||||
array('<foo>', true, '"<,>" is a valid delimiter pair'),
|
|
||||||
array('*foo.*', false, '"*" is not considered as a valid delimiter'),
|
|
||||||
array('?foo.?', false, '"?" is not considered as a valid delimiter'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestMultiplePcreFilterIterator extends MultiplePcreFilterIterator
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function accept()
|
|
||||||
{
|
|
||||||
throw new \BadFunctionCallException('Not implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isRegex($str)
|
|
||||||
{
|
|
||||||
return parent::isRegex($str);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toRegex($str)
|
|
||||||
{
|
|
||||||
throw new \BadFunctionCallException('Not implemented');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use Symfony\Component\Finder\Iterator\PathFilterIterator;
|
|
||||||
|
|
||||||
class PathFilterIteratorTest extends IteratorTestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @dataProvider getTestFilterData
|
|
||||||
*/
|
|
||||||
public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatchPatterns, array $resultArray)
|
|
||||||
{
|
|
||||||
$iterator = new PathFilterIterator($inner, $matchPatterns, $noMatchPatterns);
|
|
||||||
$this->assertIterator($resultArray, $iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTestFilterData()
|
|
||||||
{
|
|
||||||
$inner = new MockFileListIterator();
|
|
||||||
|
|
||||||
//PATH: A/B/C/abc.dat
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
|
||||||
'name' => 'abc.dat',
|
|
||||||
'relativePathname' => 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
|
|
||||||
));
|
|
||||||
|
|
||||||
//PATH: A/B/ab.dat
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
|
||||||
'name' => 'ab.dat',
|
|
||||||
'relativePathname' => 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat',
|
|
||||||
));
|
|
||||||
|
|
||||||
//PATH: A/a.dat
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
|
||||||
'name' => 'a.dat',
|
|
||||||
'relativePathname' => 'A'.DIRECTORY_SEPARATOR.'a.dat',
|
|
||||||
));
|
|
||||||
|
|
||||||
//PATH: copy/A/B/C/abc.dat.copy
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
|
||||||
'name' => 'abc.dat.copy',
|
|
||||||
'relativePathname' => 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
|
|
||||||
));
|
|
||||||
|
|
||||||
//PATH: copy/A/B/ab.dat.copy
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
|
||||||
'name' => 'ab.dat.copy',
|
|
||||||
'relativePathname' => 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat',
|
|
||||||
));
|
|
||||||
|
|
||||||
//PATH: copy/A/a.dat.copy
|
|
||||||
$inner[] = new MockSplFileInfo(array(
|
|
||||||
'name' => 'a.dat.copy',
|
|
||||||
'relativePathname' => 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'a.dat',
|
|
||||||
));
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array($inner, array('/^A/'), array(), array('abc.dat', 'ab.dat', 'a.dat')),
|
|
||||||
array($inner, array('/^A\/B/'), array(), array('abc.dat', 'ab.dat')),
|
|
||||||
array($inner, array('/^A\/B\/C/'), array(), array('abc.dat')),
|
|
||||||
array($inner, array('/A\/B\/C/'), array(), array('abc.dat', 'abc.dat.copy')),
|
|
||||||
|
|
||||||
array($inner, array('A'), array(), array('abc.dat', 'ab.dat', 'a.dat', 'abc.dat.copy', 'ab.dat.copy', 'a.dat.copy')),
|
|
||||||
array($inner, array('A/B'), array(), array('abc.dat', 'ab.dat', 'abc.dat.copy', 'ab.dat.copy')),
|
|
||||||
array($inner, array('A/B/C'), array(), array('abc.dat', 'abc.dat.copy')),
|
|
||||||
|
|
||||||
array($inner, array('copy/A'), array(), array('abc.dat.copy', 'ab.dat.copy', 'a.dat.copy')),
|
|
||||||
array($inner, array('copy/A/B'), array(), array('abc.dat.copy', 'ab.dat.copy')),
|
|
||||||
array($inner, array('copy/A/B/C'), array(), array('abc.dat.copy')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
abstract class RealIteratorTestCase extends IteratorTestCase
|
|
||||||
{
|
|
||||||
protected static $tmpDir;
|
|
||||||
protected static $files;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony_finder';
|
|
||||||
|
|
||||||
self::$files = array(
|
|
||||||
'.git/',
|
|
||||||
'.foo/',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
'.bar',
|
|
||||||
'test.py',
|
|
||||||
'foo/',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'test.php',
|
|
||||||
'toto/',
|
|
||||||
'toto/.git/',
|
|
||||||
'foo bar',
|
|
||||||
);
|
|
||||||
|
|
||||||
self::$files = self::toAbsolute(self::$files);
|
|
||||||
|
|
||||||
if (is_dir(self::$tmpDir)) {
|
|
||||||
self::tearDownAfterClass();
|
|
||||||
} else {
|
|
||||||
mkdir(self::$tmpDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (self::$files as $file) {
|
|
||||||
if (DIRECTORY_SEPARATOR === $file[strlen($file) - 1]) {
|
|
||||||
mkdir($file);
|
|
||||||
} else {
|
|
||||||
touch($file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
file_put_contents(self::toAbsolute('test.php'), str_repeat(' ', 800));
|
|
||||||
file_put_contents(self::toAbsolute('test.py'), str_repeat(' ', 2000));
|
|
||||||
|
|
||||||
touch(self::toAbsolute('foo/bar.tmp'), strtotime('2005-10-15'));
|
|
||||||
touch(self::toAbsolute('test.php'), strtotime('2005-10-15'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
|
||||||
{
|
|
||||||
foreach (array_reverse(self::$files) as $file) {
|
|
||||||
if (DIRECTORY_SEPARATOR === $file[strlen($file) - 1]) {
|
|
||||||
@rmdir($file);
|
|
||||||
} else {
|
|
||||||
@unlink($file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function toAbsolute($files = null)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Without the call to setUpBeforeClass() property can be null.
|
|
||||||
*/
|
|
||||||
if (!self::$tmpDir) {
|
|
||||||
self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony_finder';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_array($files)) {
|
|
||||||
$f = array();
|
|
||||||
foreach ($files as $file) {
|
|
||||||
if (is_array($file)) {
|
|
||||||
$f[] = self::toAbsolute($file);
|
|
||||||
} else {
|
|
||||||
$f[] = self::$tmpDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_string($files)) {
|
|
||||||
return self::$tmpDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $files);
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$tmpDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function toAbsoluteFixtures($files)
|
|
||||||
{
|
|
||||||
$f = array();
|
|
||||||
foreach ($files as $file) {
|
|
||||||
$f[] = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.$file);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator;
|
|
||||||
|
|
||||||
class RecursiveDirectoryIteratorTest extends IteratorTestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @group network
|
|
||||||
*/
|
|
||||||
public function testRewindOnFtp()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$i = new RecursiveDirectoryIterator('ftp://speedtest.tele2.net/', \RecursiveDirectoryIterator::SKIP_DOTS);
|
|
||||||
} catch (\UnexpectedValueException $e) {
|
|
||||||
$this->markTestSkipped('Unsupported stream "ftp".');
|
|
||||||
}
|
|
||||||
|
|
||||||
$i->rewind();
|
|
||||||
|
|
||||||
$this->assertTrue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group network
|
|
||||||
*/
|
|
||||||
public function testSeekOnFtp()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$i = new RecursiveDirectoryIterator('ftp://speedtest.tele2.net/', \RecursiveDirectoryIterator::SKIP_DOTS);
|
|
||||||
} catch (\UnexpectedValueException $e) {
|
|
||||||
$this->markTestSkipped('Unsupported stream "ftp".');
|
|
||||||
}
|
|
||||||
|
|
||||||
$contains = array(
|
|
||||||
'ftp://speedtest.tele2.net'.DIRECTORY_SEPARATOR.'1000GB.zip',
|
|
||||||
'ftp://speedtest.tele2.net'.DIRECTORY_SEPARATOR.'100GB.zip',
|
|
||||||
);
|
|
||||||
$actual = array();
|
|
||||||
|
|
||||||
$i->seek(0);
|
|
||||||
$actual[] = $i->getPathname();
|
|
||||||
|
|
||||||
$i->seek(1);
|
|
||||||
$actual[] = $i->getPathname();
|
|
||||||
|
|
||||||
$this->assertEquals($contains, $actual);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
|
|
||||||
use Symfony\Component\Finder\Comparator\NumberComparator;
|
|
||||||
|
|
||||||
class SizeRangeFilterIteratorTest extends RealIteratorTestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @dataProvider getAcceptData
|
|
||||||
*/
|
|
||||||
public function testAccept($size, $expected)
|
|
||||||
{
|
|
||||||
$inner = new InnerSizeIterator(self::$files);
|
|
||||||
|
|
||||||
$iterator = new SizeRangeFilterIterator($inner, $size);
|
|
||||||
|
|
||||||
$this->assertIterator($expected, $iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAcceptData()
|
|
||||||
{
|
|
||||||
$lessThan1KGreaterThan05K = array(
|
|
||||||
'.foo',
|
|
||||||
'.git',
|
|
||||||
'foo',
|
|
||||||
'test.php',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array(array(new NumberComparator('< 1K'), new NumberComparator('> 0.5K')), $this->toAbsolute($lessThan1KGreaterThan05K)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InnerSizeIterator extends \ArrayIterator
|
|
||||||
{
|
|
||||||
public function current()
|
|
||||||
{
|
|
||||||
return new \SplFileInfo(parent::current());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFilename()
|
|
||||||
{
|
|
||||||
return parent::current();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isFile()
|
|
||||||
{
|
|
||||||
return $this->current()->isFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSize()
|
|
||||||
{
|
|
||||||
return $this->current()->getSize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,183 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Finder\Tests\Iterator;
|
|
||||||
|
|
||||||
use Symfony\Component\Finder\Iterator\SortableIterator;
|
|
||||||
|
|
||||||
class SortableIteratorTest extends RealIteratorTestCase
|
|
||||||
{
|
|
||||||
public function testConstructor()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
new SortableIterator(new Iterator(array()), 'foobar');
|
|
||||||
$this->fail('__construct() throws an \InvalidArgumentException exception if the mode is not valid');
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException exception if the mode is not valid');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider getAcceptData
|
|
||||||
*/
|
|
||||||
public function testAccept($mode, $expected)
|
|
||||||
{
|
|
||||||
if (!is_callable($mode)) {
|
|
||||||
switch ($mode) {
|
|
||||||
case SortableIterator::SORT_BY_ACCESSED_TIME:
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
|
||||||
touch(self::toAbsolute('.git'));
|
|
||||||
} else {
|
|
||||||
file_get_contents(self::toAbsolute('.git'));
|
|
||||||
}
|
|
||||||
sleep(1);
|
|
||||||
file_get_contents(self::toAbsolute('.bar'));
|
|
||||||
break;
|
|
||||||
case SortableIterator::SORT_BY_CHANGED_TIME:
|
|
||||||
file_put_contents(self::toAbsolute('test.php'), 'foo');
|
|
||||||
sleep(1);
|
|
||||||
file_put_contents(self::toAbsolute('test.py'), 'foo');
|
|
||||||
break;
|
|
||||||
case SortableIterator::SORT_BY_MODIFIED_TIME:
|
|
||||||
file_put_contents(self::toAbsolute('test.php'), 'foo');
|
|
||||||
sleep(1);
|
|
||||||
file_put_contents(self::toAbsolute('test.py'), 'foo');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$inner = new Iterator(self::$files);
|
|
||||||
|
|
||||||
$iterator = new SortableIterator($inner, $mode);
|
|
||||||
|
|
||||||
if (SortableIterator::SORT_BY_ACCESSED_TIME === $mode
|
|
||||||
|| SortableIterator::SORT_BY_CHANGED_TIME === $mode
|
|
||||||
|| SortableIterator::SORT_BY_MODIFIED_TIME === $mode
|
|
||||||
) {
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR && SortableIterator::SORT_BY_MODIFIED_TIME !== $mode) {
|
|
||||||
$this->markTestSkipped('Sorting by atime or ctime is not supported on Windows');
|
|
||||||
}
|
|
||||||
$this->assertOrderedIteratorForGroups($expected, $iterator);
|
|
||||||
} else {
|
|
||||||
$this->assertOrderedIterator($expected, $iterator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAcceptData()
|
|
||||||
{
|
|
||||||
$sortByName = array(
|
|
||||||
'.bar',
|
|
||||||
'.foo',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
'.git',
|
|
||||||
'foo',
|
|
||||||
'foo bar',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'test.php',
|
|
||||||
'test.py',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
);
|
|
||||||
|
|
||||||
$sortByType = array(
|
|
||||||
'.foo',
|
|
||||||
'.git',
|
|
||||||
'foo',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
'.bar',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
'foo bar',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'test.php',
|
|
||||||
'test.py',
|
|
||||||
);
|
|
||||||
|
|
||||||
$customComparison = array(
|
|
||||||
'.bar',
|
|
||||||
'.foo',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
'.git',
|
|
||||||
'foo',
|
|
||||||
'foo bar',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'test.php',
|
|
||||||
'test.py',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
);
|
|
||||||
|
|
||||||
$sortByAccessedTime = array(
|
|
||||||
// For these two files the access time was set to 2005-10-15
|
|
||||||
array('foo/bar.tmp', 'test.php'),
|
|
||||||
// These files were created more or less at the same time
|
|
||||||
array(
|
|
||||||
'.git',
|
|
||||||
'.foo',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
'test.py',
|
|
||||||
'foo',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
'foo bar',
|
|
||||||
),
|
|
||||||
// This file was accessed after sleeping for 1 sec
|
|
||||||
array('.bar'),
|
|
||||||
);
|
|
||||||
|
|
||||||
$sortByChangedTime = array(
|
|
||||||
array(
|
|
||||||
'.git',
|
|
||||||
'.foo',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
'.bar',
|
|
||||||
'foo',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
'foo bar',
|
|
||||||
),
|
|
||||||
array('test.php'),
|
|
||||||
array('test.py'),
|
|
||||||
);
|
|
||||||
|
|
||||||
$sortByModifiedTime = array(
|
|
||||||
array(
|
|
||||||
'.git',
|
|
||||||
'.foo',
|
|
||||||
'.foo/.bar',
|
|
||||||
'.foo/bar',
|
|
||||||
'.bar',
|
|
||||||
'foo',
|
|
||||||
'foo/bar.tmp',
|
|
||||||
'toto',
|
|
||||||
'toto/.git',
|
|
||||||
'foo bar',
|
|
||||||
),
|
|
||||||
array('test.php'),
|
|
||||||
array('test.py'),
|
|
||||||
);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array(SortableIterator::SORT_BY_NAME, $this->toAbsolute($sortByName)),
|
|
||||||
array(SortableIterator::SORT_BY_TYPE, $this->toAbsolute($sortByType)),
|
|
||||||
array(SortableIterator::SORT_BY_ACCESSED_TIME, $this->toAbsolute($sortByAccessedTime)),
|
|
||||||
array(SortableIterator::SORT_BY_CHANGED_TIME, $this->toAbsolute($sortByChangedTime)),
|
|
||||||
array(SortableIterator::SORT_BY_MODIFIED_TIME, $this->toAbsolute($sortByModifiedTime)),
|
|
||||||
array(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, $this->toAbsolute($customComparison)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
4
vendor/symfony/finder/composer.json
vendored
4
vendor/symfony/finder/composer.json
vendored
@@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.5.9|>=7.0.8"
|
"php": ">=7.2.5"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": { "Symfony\\Component\\Finder\\": "" },
|
"psr-4": { "Symfony\\Component\\Finder\\": "" },
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.4-dev"
|
"dev-master": "5.1-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
30
vendor/symfony/finder/phpunit.xml.dist
vendored
30
vendor/symfony/finder/phpunit.xml.dist
vendored
@@ -1,30 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
|
|
||||||
backupGlobals="false"
|
|
||||||
colors="true"
|
|
||||||
bootstrap="vendor/autoload.php"
|
|
||||||
failOnRisky="true"
|
|
||||||
failOnWarning="true"
|
|
||||||
>
|
|
||||||
<php>
|
|
||||||
<ini name="error_reporting" value="-1" />
|
|
||||||
</php>
|
|
||||||
|
|
||||||
<testsuites>
|
|
||||||
<testsuite name="Symfony Finder Component Test Suite">
|
|
||||||
<directory>./Tests/</directory>
|
|
||||||
</testsuite>
|
|
||||||
</testsuites>
|
|
||||||
|
|
||||||
<filter>
|
|
||||||
<whitelist>
|
|
||||||
<directory>./</directory>
|
|
||||||
<exclude>
|
|
||||||
<directory>./Tests</directory>
|
|
||||||
<directory>./vendor</directory>
|
|
||||||
</exclude>
|
|
||||||
</whitelist>
|
|
||||||
</filter>
|
|
||||||
</phpunit>
|
|
||||||
Reference in New Issue
Block a user