Move into nested docroot

This commit is contained in:
Rob Davies 2017-02-13 15:31:17 +00:00
parent 83a0d3a149
commit c8b70abde9
13405 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,199 @@
1.6.0 (2015-10-06)
------------------
* added `vfsStreamWrapper::unregister()`, provided by @malkusch with #114
* fixed #115: incorrect handling of `..` in root directory on PHP 5.5, fix provided by @acoulton with #116
1.5.0 (2015-03-29)
------------------
* implemented #91: `vfsStream::copyFromFileSystem()` should create large file instances
* implemented #92: `vfsStream::copyFromFileSystem()` should respect block devices
* fixed #107: `touch()` does not respect file permissions
* fixed #105: vfs directory structure is not reset after each test
* fixed #104: vfsStream can't handle url encoded pathes
1.4.0 (2014-09-14)
------------------
* implemented #85: Added support for emulating block devices in the virtual filesystem, feature provided by Harris Borawski
* fixed #68: Unlink a non-existing file now triggers a PHP warning
1.3.0 (2014-07-21)
------------------
* implemented #79: possibility to mock large files without large memory footprint, see https://github.com/mikey179/vfsStream/wiki/MockingLargeFiles
* implemented #67: added partial support for text-mode translation flag (i.e., no actual translation of line endings takes place) so it no longer throws an exception (provided by Anthon Pang)
* fixed issue #74: issue with trailing windows path separators (provided by Sebastian Krüger)
* fixed issue #50: difference between real file system and vfs with `RecursiveDirectoryIterator`
* fixed issue #80: touch with no arguments for modification and access time behave incorrect
* deprecated `org\bovigo\vfs\vfsStreamFile::readUntilEnd()`
* deprecated `org\bovigo\vfs\vfsStreamFile::getBytesRead()`
1.2.0 (2013-04-01)
------------------
* implemented issue #34: provide `url()` method on all `vfsStreamContent` instances
* added `org\bovigo\vfs\vfsStreamContent::url()`
* added `org\bovigo\vfs\vfsStreamContent::path()`
* fixed issue #40: flock implementation doesn't work correctly, patch provided by Kamil Dziedzic
* fixed issue #49: call to member function on a non-object when trying to delete a file one above root where a file with same name in root exists
* fixed issue #51: `unlink()` must consider permissions of directory where file is inside, not of the file to unlink itself
* fixed issue #52: `chmod()`, `chown()` and `chgrp()` must consider permissions of directory where file/directory is inside
* fixed issue #53: `chmod()`, `chown()` and `chgrp()` must consider current user and current owner of file/directoy to change
1.1.0 (2012-08-25)
------------------
* implemented issue #11: add support for `streamWrapper::stream_metadata()` vfsStream now supports `touch()`, `chown()`, `chgrp()` and `chmod()`
* implemented issue #33: add support for `stream_truncate()` (provided by https://github.com/nikcorg)
* implemented issue #35: size limit (quota) for VFS
1.0.0 (2012-05-15)
------------------
* raised requirement for PHP version to 5.3.0
* migrated codebase to use namespaces
* changed distribution from PEAR to Composer
* implemented issue #30: support "c" mode for `fopen()`
* fixed issue #31: prohibit aquiring locks when already locked / release lock on `fclose()`
* fixed issue #32: problems when subfolder has same name as folder
* fixed issue #36: `vfsStreamWrapper::stream_open()` should return false while trying to open existing non-writable file, patch provided by Alexander Peresypkin
0.11.2 (2012-01-14)
-------------------
* fixed issue #29: set permissions properly when using `vfsStream::copyFromFileSystem()`, patch provided by predakanga
* fixed failing tests under PHP > 5.3.2
0.11.1 (2011-12-04)
-------------------
* fixed issue #28: `mkdir()` overwrites existing directories/files
0.11.0 (2011-11-29)
-------------------
* implemented issue #20: `vfsStream::create()` removes old structure
* implemented issue #4: possibility to copy structure from existing file system
* fixed issue #23: `unlink()` should not remove any directory
* fixed issue #25: `vfsStreamDirectory::hasChild()` gives false positives for nested paths, patch provided by Andrew Coulton
* fixed issue #26: opening a file for reading only should not update its modification time, reported and initial patch provided by Ludovic Chabant
0.10.1 (2011-08-22)
-------------------
* fixed issue #16: replace `vfsStreamContent` to `vfsStreamContainer` for autocompletion
* fixed issue #17: `vfsStream::create()` has issues with numeric directories, patch provided by mathieuk
0.10.0 (2011-07-22)
-------------------
* added new method `vfsStreamContainer::hasChildren()` and `vfsStreamDirectory::hasChildren()`
* implemented issue #14: less verbose way to initialize vfsStream
* implemented issue #13: remove deprecated method `vfsStreamContent::setFilemtime()`
* implemented issue #6: locking meachanism for files
* ensured that `stream_set_blocking()`, `stream_set_timeout()` and `stream_set_write_buffer()` on vfsStream urls have the same behaviour with PHP 5.2 and 5.3
* implemented issue #10: method to print directory structure
0.9.0 (2011-07-13)
------------------
* implemented feature request issue #7: add support for `fileatime()` and `filectime()`
* fixed issue #3: add support for `streamWrapper::stream_cast()`
* fixed issue #9: resolve path not called everywhere its needed
* deprecated `vfsStreamAbstractContent::setFilemtime()`, use `vfsStreamAbstractContent::lastModified()` instead, will be removed with 0.10.0
0.8.0 (2010-10-08)
------------------
* implemented enhancement #6: use `vfsStream::umask()` to influence initial file mode for files and directories
* implemented enhancement #19: support of .. in the url, patch provided by Guislain Duthieuw
* fixed issue #18: `getChild()` returns NULL when child's name contains parent name
* fixed bug with incomplete error message when accessing non-existing files on root level
0.7.0 (2010-06-08)
------------------
* added new `vfsStream::setup()` method to simplify vfsStream usage
* fixed issue #15: `mkdir()` creates a subfolder in a folder without permissions
0.6.0 (2010-02-15)
------------------
* added support for `$mode` param when opening files, implements enhancement #7 and fixes issue #13
* `vfsStreamWrapper::stream_open()` now evaluates `$options` for `STREAM_REPORT_ERRORS`
0.5.0 (2010-01-25)
------------------
* added support for `rename()`, patch provided by Benoit Aubuchon
* added support for . as directory alias so that `vfs://foo/.` resolves to `vfs://foo`, can be used as workaround for bug #8
0.4.0 (2009-07-13)
------------------
* added support for file modes, users and groups (with restrictions, see http://code.google.com/p/bovigo/wiki/vfsStreamDocsKnownIssues)
* fixed bug #5: `vfsStreamDirectory::addChild()` does not replace child with same name
* fixed bug with `is_writable()` because of missing `stat()` fields, patch provided by Sergey Galkin
0.3.2 (2009-02-16)
------------------
* support trailing slashes on directories in vfsStream urls, patch provided by Gabriel Birke
* fixed bug #4: vfsstream can only be read once, reported by Christoph Bloemer
* enabled multiple iterations at the same time over the same directory
0.3.1 (2008-02-18)
------------------
* fixed path/directory separator issues under linux systems
* fixed uid/gid issues under linux systems
0.3.0 (2008-01-02)
------------------
* added support for `rmdir()`
* added `vfsStream::newDirectory()`, dropped `vfsStreamDirectory::ceate()`
* added new interface `vfsStreamContainer`
* added `vfsStreamContent::at()` which allows code like `$file = vfsStream::newFile('file.txt.')->withContent('foo')->at($otherDir);`
* added `vfsStreamContent::lastModified()`, made `vfsStreamContent::setFilemtime()` an alias for this
* moved from Stubbles development environment to bovigo
* refactorings to reduce crap index of various methods
0.2.0 (2007-12-29)
------------------
* moved `vfsStreamWrapper::PROTOCOL` to `vfsStream::SCHEME`
* added new `vfsStream::url()` method to assist in creating correct vfsStream urls
* added `vfsStream::path()` method as opposite to `vfsStream::url()`
* a call to `vfsStreamWrapper::register()` will now reset the root to null, implemented on request from David Zuelke
* added support for `is_readable()`, `is_dir()`, `is_file()`
* added `vfsStream::newFile()` to be able to do `$file = vfsStream::newFile("foo.txt")->withContent("bar");`
0.1.0 (2007-12-14)
------------------
* Initial release.

27
web/vendor/mikey179/vfsStream/LICENSE vendored Normal file
View file

@ -0,0 +1,27 @@
Copyright (c) 2007-2015, Frank Kleine
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Stubbles nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,8 @@
You can find documentation in the [wiki](https://github.com/mikey179/vfsStream/wiki).
Also you might want to check [vfsStream examples](https://github.com/mikey179/vfsStream-examples).
[![Build Status](https://secure.travis-ci.org/mikey179/vfsStream.png)](http://travis-ci.org/mikey179/vfsStream) [![Coverage Status](https://coveralls.io/repos/mikey179/vfsStream/badge.png?branch=master)](https://coveralls.io/r/mikey179/vfsStream?branch=master)
[![Latest Stable Version](https://poser.pugx.org/mikey179/vfsStream/version.png)](https://packagist.org/packages/mikey179/vfsStream) [![Latest Unstable Version](https://poser.pugx.org/mikey179/vfsStream/v/unstable.png)](//packagist.org/packages/mikey179/vfsStream)

View file

@ -0,0 +1,33 @@
{
"name": "mikey179/vfsStream",
"type": "library",
"homepage": "http://vfs.bovigo.org/",
"description": "Virtual file system to mock the real file system in unit tests.",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Frank Kleine",
"homepage": "http://frankkleine.de/",
"role": "Developer"
}
],
"support": {
"issues": "https://github.com/mikey179/vfsStream/issues",
"source": "https://github.com/mikey179/vfsStream/tree/master",
"wiki": "https://github.com/mikey179/vfsStream/wiki"
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "~4.5"
},
"autoload": {
"psr-0": { "org\\bovigo\\vfs\\": "src/main/php" }
},
"extra": {
"branch-alias": {
"dev-master": "1.6.x-dev"
}
}
}

972
web/vendor/mikey179/vfsStream/composer.lock generated vendored Normal file
View file

@ -0,0 +1,972 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "e3c2dd0d4b4daf3d2c9e0bedd344592a",
"content-hash": "59c3102c5db7e3c4d78a920d4712790d",
"packages": [],
"packages-dev": [
{
"name": "doctrine/instantiator",
"version": "1.0.5",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
"shasum": ""
},
"require": {
"php": ">=5.3,<8.0-DEV"
},
"require-dev": {
"athletic/athletic": "~0.1.8",
"ext-pdo": "*",
"ext-phar": "*",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "ocramius@gmail.com",
"homepage": "http://ocramius.github.com/"
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://github.com/doctrine/instantiator",
"keywords": [
"constructor",
"instantiate"
],
"time": "2015-06-14 21:17:01"
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8",
"reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"suggest": {
"dflydev/markdown": "~1.0",
"erusev/parsedown": "~1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-0": {
"phpDocumentor": [
"src/"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mike van Riel",
"email": "mike.vanriel@naenius.com"
}
],
"time": "2015-02-03 12:10:50"
},
{
"name": "phpspec/prophecy",
"version": "v1.5.0",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/4745ded9307786b730d7a60df5cb5a6c43cf95f7",
"reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"phpdocumentor/reflection-docblock": "~2.0",
"sebastian/comparator": "~1.1"
},
"require-dev": {
"phpspec/phpspec": "~2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
}
},
"autoload": {
"psr-0": {
"Prophecy\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Konstantin Kudryashov",
"email": "ever.zet@gmail.com",
"homepage": "http://everzet.com"
},
{
"name": "Marcello Duarte",
"email": "marcello.duarte@gmail.com"
}
],
"description": "Highly opinionated mocking framework for PHP 5.3+",
"homepage": "https://github.com/phpspec/prophecy",
"keywords": [
"Double",
"Dummy",
"fake",
"mock",
"spy",
"stub"
],
"time": "2015-08-13 10:07:40"
},
{
"name": "phpunit/php-code-coverage",
"version": "2.2.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef1ca6835468857944d5c3b48fa503d5554cff2f",
"reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"phpunit/php-file-iterator": "~1.3",
"phpunit/php-text-template": "~1.2",
"phpunit/php-token-stream": "~1.3",
"sebastian/environment": "^1.3.2",
"sebastian/version": "~1.0"
},
"require-dev": {
"ext-xdebug": ">=2.1.4",
"phpunit/phpunit": "~4"
},
"suggest": {
"ext-dom": "*",
"ext-xdebug": ">=2.2.1",
"ext-xmlwriter": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
"homepage": "https://github.com/sebastianbergmann/php-code-coverage",
"keywords": [
"coverage",
"testing",
"xunit"
],
"time": "2015-09-14 06:51:16"
},
{
"name": "phpunit/php-file-iterator",
"version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0",
"reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "FilterIterator implementation that filters files based on a list of suffixes.",
"homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
"keywords": [
"filesystem",
"iterator"
],
"time": "2015-06-21 13:08:43"
},
{
"name": "phpunit/php-text-template",
"version": "1.2.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-text-template.git",
"reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
"reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Simple template engine.",
"homepage": "https://github.com/sebastianbergmann/php-text-template/",
"keywords": [
"template"
],
"time": "2015-06-21 13:50:34"
},
{
"name": "phpunit/php-timer",
"version": "1.0.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
"reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b",
"reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Utility class for timing",
"homepage": "https://github.com/sebastianbergmann/php-timer/",
"keywords": [
"timer"
],
"time": "2015-06-21 08:01:12"
},
{
"name": "phpunit/php-token-stream",
"version": "1.4.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
"reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Wrapper around PHP's tokenizer extension.",
"homepage": "https://github.com/sebastianbergmann/php-token-stream/",
"keywords": [
"tokenizer"
],
"time": "2015-09-15 10:49:45"
},
{
"name": "phpunit/phpunit",
"version": "4.8.10",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "463163747474815c5ccd4ae12b5b355ec12158e8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/463163747474815c5ccd4ae12b5b355ec12158e8",
"reference": "463163747474815c5ccd4ae12b5b355ec12158e8",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-json": "*",
"ext-pcre": "*",
"ext-reflection": "*",
"ext-spl": "*",
"php": ">=5.3.3",
"phpspec/prophecy": "^1.3.1",
"phpunit/php-code-coverage": "~2.1",
"phpunit/php-file-iterator": "~1.4",
"phpunit/php-text-template": "~1.2",
"phpunit/php-timer": ">=1.0.6",
"phpunit/phpunit-mock-objects": "~2.3",
"sebastian/comparator": "~1.1",
"sebastian/diff": "~1.2",
"sebastian/environment": "~1.3",
"sebastian/exporter": "~1.2",
"sebastian/global-state": "~1.0",
"sebastian/version": "~1.0",
"symfony/yaml": "~2.1|~3.0"
},
"suggest": {
"phpunit/php-invoker": "~1.1"
},
"bin": [
"phpunit"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.8.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "The PHP Unit Testing framework.",
"homepage": "https://phpunit.de/",
"keywords": [
"phpunit",
"testing",
"xunit"
],
"time": "2015-10-01 09:14:30"
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "2.3.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983",
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"php": ">=5.3.3",
"phpunit/php-text-template": "~1.2",
"sebastian/exporter": "~1.2"
},
"require-dev": {
"phpunit/phpunit": "~4.4"
},
"suggest": {
"ext-soap": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"role": "lead"
}
],
"description": "Mock Object library for PHPUnit",
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
"keywords": [
"mock",
"xunit"
],
"time": "2015-10-02 06:51:40"
},
{
"name": "sebastian/comparator",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "937efb279bd37a375bcadf584dec0726f84dbf22"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22",
"reference": "937efb279bd37a375bcadf584dec0726f84dbf22",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"sebastian/diff": "~1.2",
"sebastian/exporter": "~1.2"
},
"require-dev": {
"phpunit/phpunit": "~4.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Provides the functionality to compare PHP values for equality",
"homepage": "http://www.github.com/sebastianbergmann/comparator",
"keywords": [
"comparator",
"compare",
"equality"
],
"time": "2015-07-26 15:48:44"
},
{
"name": "sebastian/diff",
"version": "1.3.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "863df9687835c62aa423a22412d26fa2ebde3fd3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/863df9687835c62aa423a22412d26fa2ebde3fd3",
"reference": "863df9687835c62aa423a22412d26fa2ebde3fd3",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Kore Nordmann",
"email": "mail@kore-nordmann.de"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Diff implementation",
"homepage": "http://www.github.com/sebastianbergmann/diff",
"keywords": [
"diff"
],
"time": "2015-02-22 15:13:53"
},
{
"name": "sebastian/environment",
"version": "1.3.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "6324c907ce7a52478eeeaede764f48733ef5ae44"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6324c907ce7a52478eeeaede764f48733ef5ae44",
"reference": "6324c907ce7a52478eeeaede764f48733ef5ae44",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Provides functionality to handle HHVM/PHP environments",
"homepage": "http://www.github.com/sebastianbergmann/environment",
"keywords": [
"Xdebug",
"environment",
"hhvm"
],
"time": "2015-08-03 06:14:51"
},
{
"name": "sebastian/exporter",
"version": "1.2.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "7ae5513327cb536431847bcc0c10edba2701064e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e",
"reference": "7ae5513327cb536431847bcc0c10edba2701064e",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"sebastian/recursion-context": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Volker Dusch",
"email": "github@wallbash.com"
},
{
"name": "Bernhard Schussek",
"email": "bschussek@2bepublished.at"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
}
],
"description": "Provides the functionality to export PHP variables for visualization",
"homepage": "http://www.github.com/sebastianbergmann/exporter",
"keywords": [
"export",
"exporter"
],
"time": "2015-06-21 07:55:53"
},
{
"name": "sebastian/global-state",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
"reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.2"
},
"suggest": {
"ext-uopz": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
}
],
"description": "Snapshotting of global state",
"homepage": "http://www.github.com/sebastianbergmann/global-state",
"keywords": [
"global state"
],
"time": "2014-10-06 09:23:50"
},
{
"name": "sebastian/recursion-context",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/recursion-context.git",
"reference": "994d4a811bafe801fb06dccbee797863ba2792ba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/994d4a811bafe801fb06dccbee797863ba2792ba",
"reference": "994d4a811bafe801fb06dccbee797863ba2792ba",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Jeff Welch",
"email": "whatthejeff@gmail.com"
},
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Adam Harvey",
"email": "aharvey@php.net"
}
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2015-06-21 08:04:50"
},
{
"name": "sebastian/version",
"version": "1.0.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/version.git",
"reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
"reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
"shasum": ""
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2015-06-21 13:59:46"
},
{
"name": "symfony/yaml",
"version": "v2.7.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/31cb2ad0155c95b88ee55fe12bc7ff92232c1770",
"reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
}
},
"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": "2015-09-14 14:14:09"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.3.0"
},
"platform-dev": []
}

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
printerClass="PHPUnit_TextUI_ResultPrinter"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="true">
<testsuites>
<testsuite>
<directory suffix="TestCase.php">./src/test/php</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src/main/php</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="docs/coverage" charset="UTF-8"
yui="true" highlight="false"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="docs/phpunit/clover.xml"/>
<log type="junit" target="docs/phpunit/junit.xml" logIncompleteSkipped="false"/>
<log type="testdox-html" target="docs/phpunit/testdox.html"/>
</logging>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="error_reporting" value="30719"/> <!-- E_ALL | E_STRICT -->
</php>
</phpunit>

View file

@ -0,0 +1,36 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs;
/**
* Directory container.
*/
class DotDirectory extends vfsStreamDirectory
{
/**
* returns iterator for the children
*
* @return vfsStreamContainerIterator
*/
public function getIterator()
{
return new \ArrayIterator(array());
}
/**
* checks whether dir is a dot dir
*
* @return bool
*/
public function isDot()
{
return true;
}
}
?>

View file

@ -0,0 +1,87 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs;
/**
* Represents a quota for disk space.
*
* @since 1.1.0
* @internal
*/
class Quota
{
/**
* unlimited quota
*/
const UNLIMITED = -1;
/**
* quota in bytes
*
* A value of -1 is treated as unlimited.
*
* @type int
*/
private $amount;
/**
* constructor
*
* @param int $amount quota in bytes
*/
public function __construct($amount)
{
$this->amount = $amount;
}
/**
* create with unlimited space
*
* @return Quota
*/
public static function unlimited()
{
return new self(self::UNLIMITED);
}
/**
* checks if a quota is set
*
* @return bool
*/
public function isLimited()
{
return self::UNLIMITED < $this->amount;
}
/**
* checks if given used space exceeda quota limit
*
*
* @param int $usedSpace
* @return int
*/
public function spaceLeft($usedSpace)
{
if (self::UNLIMITED === $this->amount) {
return $usedSpace;
}
if ($usedSpace >= $this->amount) {
return 0;
}
$spaceLeft = $this->amount - $usedSpace;
if (0 >= $spaceLeft) {
return 0;
}
return $spaceLeft;
}
}
?>

View file

@ -0,0 +1,71 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs\content;
/**
* Interface for actual file contents.
*
* @since 1.3.0
*/
interface FileContent
{
/**
* returns actual content
*
* @return string
*/
public function content();
/**
* returns size of content
*
* @return int
*/
public function size();
/**
* reads the given amount of bytes from content
*
* @param int $count
* @return string
*/
public function read($count);
/**
* seeks to the given offset
*
* @param int $offset
* @param int $whence
* @return bool
*/
public function seek($offset, $whence);
/**
* checks whether pointer is at end of file
*
* @return bool
*/
public function eof();
/**
* writes an amount of data
*
* @param string $data
* @return amount of written bytes
*/
public function write($data);
/**
* Truncates a file to a given length
*
* @param int $size length to truncate file to
* @return bool
*/
public function truncate($size);
}

View file

@ -0,0 +1,167 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs\content;
/**
* File content implementation to mock large files.
*
* When content is written via write() the data will be written into the
* positions according to the current offset.
* When content is read via read() it will use the already written data. If no
* data is written at the offsets to read those offsets will be filled with
* spaces.
* Please note that accessing the whole content via content() will deliver a
* string with the length of the originally defined size. It is not advisable to
* do so with large sizes, except you have enough memory and time. :-)
*
* @since 1.3.0
*/
class LargeFileContent extends SeekableFileContent implements FileContent
{
/**
* byte array of written content
*
* @type char[]
*/
private $content = array();
/**
* file size in bytes
*
* @type int
*/
private $size;
/**
* constructor
*
* @param int $size file size in bytes
*/
public function __construct($size)
{
$this->size = $size;
}
/**
* create large file with given size in kilobyte
*
* @param int $kilobyte
* @return LargeFileContent
*/
public static function withKilobytes($kilobyte)
{
return new self($kilobyte * 1024);
}
/**
* create large file with given size in megabyte
*
* @param int $megabyte
* @return LargeFileContent
*/
public static function withMegabytes($megabyte)
{
return self::withKilobytes($megabyte * 1024);
}
/**
* create large file with given size in gigabyte
*
* @param int $gigabyte
* @return LargeFileContent
*/
public static function withGigabytes($gigabyte)
{
return self::withMegabytes($gigabyte * 1024);
}
/**
* returns actual content
*
* @return string
*/
public function content()
{
return $this->doRead(0, $this->size);
}
/**
* returns size of content
*
* @return int
*/
public function size()
{
return $this->size;
}
/**
* actual reading of given byte count starting at given offset
*
* @param int $offset
* @param int $count
*/
protected function doRead($offset, $count)
{
if (($offset + $count) > $this->size) {
$count = $this->size - $offset;
}
$result = '';
for ($i = 0; $i < $count; $i++) {
if (isset($this->content[$i + $offset])) {
$result .= $this->content[$i + $offset];
} else {
$result .= ' ';
}
}
return $result;
}
/**
* actual writing of data with specified length at given offset
*
* @param string $data
* @param int $offset
* @param int $length
*/
protected function doWrite($data, $offset, $length)
{
for ($i = 0; $i < $length; $i++) {
$this->content[$i + $offset] = $data{$i};
}
if ($offset >= $this->size) {
$this->size += $length;
} elseif (($offset + $length) > $this->size) {
$this->size = $offset + $length;
}
}
/**
* Truncates a file to a given length
*
* @param int $size length to truncate file to
* @return bool
*/
public function truncate($size)
{
$this->size = $size;
foreach (array_filter(array_keys($this->content),
function($pos) use ($size)
{
return $pos >= $size;
}
) as $removePos) {
unset($this->content[$removePos]);
}
return true;
}
}

View file

@ -0,0 +1,129 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs\content;
/**
* Default implementation for file contents based on simple strings.
*
* @since 1.3.0
*/
abstract class SeekableFileContent implements FileContent
{
/**
* current position within content
*
* @type int
*/
private $offset = 0;
/**
* reads the given amount of bytes from content
*
* @param int $count
* @return string
*/
public function read($count)
{
$data = $this->doRead($this->offset, $count);
$this->offset += $count;
return $data;
}
/**
* actual reading of given byte count starting at given offset
*
* @param int $offset
* @param int $count
*/
protected abstract function doRead($offset, $count);
/**
* seeks to the given offset
*
* @param int $offset
* @param int $whence
* @return bool
*/
public function seek($offset, $whence)
{
switch ($whence) {
case SEEK_CUR:
$this->offset += $offset;
return true;
case SEEK_END:
$this->offset = $this->size() + $offset;
return true;
case SEEK_SET:
$this->offset = $offset;
return true;
default:
return false;
}
return false;
}
/**
* checks whether pointer is at end of file
*
* @return bool
*/
public function eof()
{
return $this->size() <= $this->offset;
}
/**
* writes an amount of data
*
* @param string $data
* @return amount of written bytes
*/
public function write($data)
{
$dataLength = strlen($data);
$this->doWrite($data, $this->offset, $dataLength);
$this->offset += $dataLength;
return $dataLength;
}
/**
* actual writing of data with specified length at given offset
*
* @param string $data
* @param int $offset
* @param int $length
*/
protected abstract function doWrite($data, $offset, $length);
/**
* for backwards compatibility with vfsStreamFile::bytesRead()
*
* @return int
* @deprecated
*/
public function bytesRead()
{
return $this->offset;
}
/**
* for backwards compatibility with vfsStreamFile::readUntilEnd()
*
* @return string
* @deprecated
*/
public function readUntilEnd()
{
return substr($this->content(), $this->offset);
}
}

View file

@ -0,0 +1,97 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs\content;
/**
* Default implementation for file contents based on simple strings.
*
* @since 1.3.0
*/
class StringBasedFileContent extends SeekableFileContent implements FileContent
{
/**
* actual content
*
* @type string
*/
private $content;
/**
* constructor
*
* @param string $content
*/
public function __construct($content)
{
$this->content = $content;
}
/**
* returns actual content
*
* @return string
*/
public function content()
{
return $this->content;
}
/**
* returns size of content
*
* @return int
*/
public function size()
{
return strlen($this->content);
}
/**
* actual reading of length starting at given offset
*
* @param int $offset
* @param int $count
*/
protected function doRead($offset, $count)
{
return substr($this->content, $offset, $count);
}
/**
* actual writing of data with specified length at given offset
*
* @param string $data
* @param int $offset
* @param int $length
*/
protected function doWrite($data, $offset, $length)
{
$this->content = substr($this->content, 0, $offset)
. $data
. substr($this->content, $offset + $length);
}
/**
* Truncates a file to a given length
*
* @param int $size length to truncate file to
* @return bool
*/
public function truncate($size)
{
if ($size > $this->size()) {
// Pad with null-chars if we're "truncating up"
$this->content .= str_repeat("\0", $size - $this->size());
} else {
$this->content = substr($this->content, 0, $size);
}
return true;
}
}

View file

@ -0,0 +1,462 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs;
use org\bovigo\vfs\content\LargeFileContent;
use org\bovigo\vfs\visitor\vfsStreamVisitor;
/**
* Some utility methods for vfsStream.
*
* @api
*/
class vfsStream
{
/**
* url scheme
*/
const SCHEME = 'vfs';
/**
* owner: root
*/
const OWNER_ROOT = 0;
/**
* owner: user 1
*/
const OWNER_USER_1 = 1;
/**
* owner: user 2
*/
const OWNER_USER_2 = 2;
/**
* group: root
*/
const GROUP_ROOT = 0;
/**
* group: user 1
*/
const GROUP_USER_1 = 1;
/**
* group: user 2
*/
const GROUP_USER_2 = 2;
/**
* initial umask setting
*
* @type int
*/
protected static $umask = 0000;
/**
* switch whether dotfiles are enabled in directory listings
*
* @type bool
*/
private static $dotFiles = true;
/**
* prepends the scheme to the given URL
*
* @param string $path path to translate to vfsStream url
* @return string
*/
public static function url($path)
{
return self::SCHEME . '://' . str_replace('\\', '/', $path);
}
/**
* restores the path from the url
*
* @param string $url vfsStream url to translate into path
* @return string
*/
public static function path($url)
{
// remove line feeds and trailing whitespaces and path separators
$path = trim($url, " \t\r\n\0\x0B/\\");
$path = substr($path, strlen(self::SCHEME . '://'));
$path = str_replace('\\', '/', $path);
// replace double slashes with single slashes
$path = str_replace('//', '/', $path);
return urldecode($path);
}
/**
* sets new umask setting and returns previous umask setting
*
* If no value is given only the current umask setting is returned.
*
* @param int $umask new umask setting
* @return int
* @since 0.8.0
*/
public static function umask($umask = null)
{
$oldUmask = self::$umask;
if (null !== $umask) {
self::$umask = $umask;
}
return $oldUmask;
}
/**
* helper method for setting up vfsStream in unit tests
*
* Instead of
* vfsStreamWrapper::register();
* vfsStreamWrapper::setRoot(vfsStream::newDirectory('root'));
* you can simply do
* vfsStream::setup()
* which yields the same result. Additionally, the method returns the
* freshly created root directory which you can use to make further
* adjustments to it.
*
* Assumed $structure contains an array like this:
* <code>
* array('Core' = array('AbstractFactory' => array('test.php' => 'some text content',
* 'other.php' => 'Some more text content',
* 'Invalid.csv' => 'Something else',
* ),
* 'AnEmptyFolder' => array(),
* 'badlocation.php' => 'some bad content',
* )
* )
* </code>
* the resulting directory tree will look like this:
* <pre>
* root
* \- Core
* |- badlocation.php
* |- AbstractFactory
* | |- test.php
* | |- other.php
* | \- Invalid.csv
* \- AnEmptyFolder
* </pre>
* Arrays will become directories with their key as directory name, and
* strings becomes files with their key as file name and their value as file
* content.
*
* @param string $rootDirName name of root directory
* @param int $permissions file permissions of root directory
* @param array $structure directory structure to add under root directory
* @return \org\bovigo\vfs\vfsStreamDirectory
* @since 0.7.0
* @see https://github.com/mikey179/vfsStream/issues/14
* @see https://github.com/mikey179/vfsStream/issues/20
*/
public static function setup($rootDirName = 'root', $permissions = null, array $structure = array())
{
vfsStreamWrapper::register();
return self::create($structure, vfsStreamWrapper::setRoot(self::newDirectory($rootDirName, $permissions)));
}
/**
* creates vfsStream directory structure from an array and adds it to given base dir
*
* Assumed $structure contains an array like this:
* <code>
* array('Core' = array('AbstractFactory' => array('test.php' => 'some text content',
* 'other.php' => 'Some more text content',
* 'Invalid.csv' => 'Something else',
* ),
* 'AnEmptyFolder' => array(),
* 'badlocation.php' => 'some bad content',
* )
* )
* </code>
* the resulting directory tree will look like this:
* <pre>
* baseDir
* \- Core
* |- badlocation.php
* |- AbstractFactory
* | |- test.php
* | |- other.php
* | \- Invalid.csv
* \- AnEmptyFolder
* </pre>
* Arrays will become directories with their key as directory name, and
* strings becomes files with their key as file name and their value as file
* content.
*
* If no baseDir is given it will try to add the structure to the existing
* root directory without replacing existing childs except those with equal
* names.
*
* @param array $structure directory structure to add under root directory
* @param vfsStreamDirectory $baseDir base directory to add structure to
* @return vfsStreamDirectory
* @throws \InvalidArgumentException
* @since 0.10.0
* @see https://github.com/mikey179/vfsStream/issues/14
* @see https://github.com/mikey179/vfsStream/issues/20
*/
public static function create(array $structure, vfsStreamDirectory $baseDir = null)
{
if (null === $baseDir) {
$baseDir = vfsStreamWrapper::getRoot();
}
if (null === $baseDir) {
throw new \InvalidArgumentException('No baseDir given and no root directory set.');
}
return self::addStructure($structure, $baseDir);
}
/**
* helper method to create subdirectories recursively
*
* @param array $structure subdirectory structure to add
* @param vfsStreamDirectory $baseDir directory to add the structure to
* @return vfsStreamDirectory
*/
protected static function addStructure(array $structure, vfsStreamDirectory $baseDir)
{
foreach ($structure as $name => $data) {
$name = (string) $name;
if (is_array($data) === true) {
self::addStructure($data, self::newDirectory($name)->at($baseDir));
} elseif (is_string($data) === true) {
$matches = null;
preg_match('/^\[(.*)\]$/', $name, $matches);
if ($matches !== array()) {
self::newBlock($matches[1])->withContent($data)->at($baseDir);
} else {
self::newFile($name)->withContent($data)->at($baseDir);
}
}
}
return $baseDir;
}
/**
* copies the file system structure from given path into the base dir
*
* If no baseDir is given it will try to add the structure to the existing
* root directory without replacing existing childs except those with equal
* names.
* File permissions are copied as well.
* Please note that file contents will only be copied if their file size
* does not exceed the given $maxFileSize which defaults to 1024 KB. In case
* the file is larger file content will be mocked, see
* https://github.com/mikey179/vfsStream/wiki/MockingLargeFiles.
*
* @param string $path path to copy the structure from
* @param vfsStreamDirectory $baseDir directory to add the structure to
* @param int $maxFileSize maximum file size of files to copy content from
* @return vfsStreamDirectory
* @throws \InvalidArgumentException
* @since 0.11.0
* @see https://github.com/mikey179/vfsStream/issues/4
*/
public static function copyFromFileSystem($path, vfsStreamDirectory $baseDir = null, $maxFileSize = 1048576)
{
if (null === $baseDir) {
$baseDir = vfsStreamWrapper::getRoot();
}
if (null === $baseDir) {
throw new \InvalidArgumentException('No baseDir given and no root directory set.');
}
$dir = new \DirectoryIterator($path);
foreach ($dir as $fileinfo) {
switch (filetype($fileinfo->getPathname())) {
case 'file':
if ($fileinfo->getSize() <= $maxFileSize) {
$content = file_get_contents($fileinfo->getPathname());
} else {
$content = new LargeFileContent($fileinfo->getSize());
}
self::newFile(
$fileinfo->getFilename(),
octdec(substr(sprintf('%o', $fileinfo->getPerms()), -4))
)
->withContent($content)
->at($baseDir);
break;
case 'dir':
if (!$fileinfo->isDot()) {
self::copyFromFileSystem(
$fileinfo->getPathname(),
self::newDirectory(
$fileinfo->getFilename(),
octdec(substr(sprintf('%o', $fileinfo->getPerms()), -4))
)->at($baseDir),
$maxFileSize
);
}
break;
case 'block':
self::newBlock(
$fileinfo->getFilename(),
octdec(substr(sprintf('%o', $fileinfo->getPerms()), -4))
)->at($baseDir);
break;
}
}
return $baseDir;
}
/**
* returns a new file with given name
*
* @param string $name name of file to create
* @param int $permissions permissions of file to create
* @return vfsStreamFile
*/
public static function newFile($name, $permissions = null)
{
return new vfsStreamFile($name, $permissions);
}
/**
* returns a new directory with given name
*
* If the name contains slashes, a new directory structure will be created.
* The returned directory will always be the parent directory of this
* directory structure.
*
* @param string $name name of directory to create
* @param int $permissions permissions of directory to create
* @return vfsStreamDirectory
*/
public static function newDirectory($name, $permissions = null)
{
if ('/' === $name{0}) {
$name = substr($name, 1);
}
$firstSlash = strpos($name, '/');
if (false === $firstSlash) {
return new vfsStreamDirectory($name, $permissions);
}
$ownName = substr($name, 0, $firstSlash);
$subDirs = substr($name, $firstSlash + 1);
$directory = new vfsStreamDirectory($ownName, $permissions);
self::newDirectory($subDirs, $permissions)->at($directory);
return $directory;
}
/**
* returns a new block with the given name
*
* @param string $name name of the block device
* @param int $permissions permissions of block to create
* @return vfsStreamBlock
*/
public static function newBlock($name, $permissions = null)
{
return new vfsStreamBlock($name, $permissions);
}
/**
* returns current user
*
* If the system does not support posix_getuid() the current user will be root (0).
*
* @return int
*/
public static function getCurrentUser()
{
return function_exists('posix_getuid') ? posix_getuid() : self::OWNER_ROOT;
}
/**
* returns current group
*
* If the system does not support posix_getgid() the current group will be root (0).
*
* @return int
*/
public static function getCurrentGroup()
{
return function_exists('posix_getgid') ? posix_getgid() : self::GROUP_ROOT;
}
/**
* use visitor to inspect a content structure
*
* If the given content is null it will fall back to use the current root
* directory of the stream wrapper.
*
* Returns given visitor for method chaining comfort.
*
* @param vfsStreamVisitor $visitor the visitor who inspects
* @param vfsStreamContent $content directory structure to inspect
* @return vfsStreamVisitor
* @throws \InvalidArgumentException
* @since 0.10.0
* @see https://github.com/mikey179/vfsStream/issues/10
*/
public static function inspect(vfsStreamVisitor $visitor, vfsStreamContent $content = null)
{
if (null !== $content) {
return $visitor->visit($content);
}
$root = vfsStreamWrapper::getRoot();
if (null === $root) {
throw new \InvalidArgumentException('No content given and no root directory set.');
}
return $visitor->visitDirectory($root);
}
/**
* sets quota to given amount of bytes
*
* @param int $bytes
* @since 1.1.0
*/
public static function setQuota($bytes)
{
vfsStreamWrapper::setQuota(new Quota($bytes));
}
/**
* checks if vfsStream lists dotfiles in directory listings
*
* @return bool
* @since 1.3.0
*/
public static function useDotfiles()
{
return self::$dotFiles;
}
/**
* disable dotfiles in directory listings
*
* @since 1.3.0
*/
public static function disableDotfiles()
{
self::$dotFiles = false;
}
/**
* enable dotfiles in directory listings
*
* @since 1.3.0
*/
public static function enableDotfiles()
{
self::$dotFiles = true;
}
}

View file

@ -0,0 +1,419 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs;
/**
* Base stream contents container.
*/
abstract class vfsStreamAbstractContent implements vfsStreamContent
{
/**
* name of the container
*
* @type string
*/
protected $name;
/**
* type of the container
*
* @type string
*/
protected $type;
/**
* timestamp of last access
*
* @type int
*/
protected $lastAccessed;
/**
* timestamp of last attribute modification
*
* @type int
*/
protected $lastAttributeModified;
/**
* timestamp of last modification
*
* @type int
*/
protected $lastModified;
/**
* permissions for content
*
* @type int
*/
protected $permissions;
/**
* owner of the file
*
* @type int
*/
protected $user;
/**
* owner group of the file
*
* @type int
*/
protected $group;
/**
* path to to this content
*
* @type string
*/
private $parentPath;
/**
* constructor
*
* @param string $name
* @param int $permissions optional
*/
public function __construct($name, $permissions = null)
{
$this->name = $name;
$time = time();
if (null === $permissions) {
$permissions = $this->getDefaultPermissions() & ~vfsStream::umask();
}
$this->lastAccessed = $time;
$this->lastAttributeModified = $time;
$this->lastModified = $time;
$this->permissions = $permissions;
$this->user = vfsStream::getCurrentUser();
$this->group = vfsStream::getCurrentGroup();
}
/**
* returns default permissions for concrete implementation
*
* @return int
* @since 0.8.0
*/
protected abstract function getDefaultPermissions();
/**
* returns the file name of the content
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* renames the content
*
* @param string $newName
*/
public function rename($newName)
{
$this->name = $newName;
}
/**
* checks whether the container can be applied to given name
*
* @param string $name
* @return bool
*/
public function appliesTo($name)
{
if ($name === $this->name) {
return true;
}
$segment_name = $this->name.'/';
return (strncmp($segment_name, $name, strlen($segment_name)) == 0);
}
/**
* returns the type of the container
*
* @return int
*/
public function getType()
{
return $this->type;
}
/**
* sets the last modification time of the stream content
*
* @param int $filemtime
* @return $this
*/
public function lastModified($filemtime)
{
$this->lastModified = $filemtime;
return $this;
}
/**
* returns the last modification time of the stream content
*
* @return int
*/
public function filemtime()
{
return $this->lastModified;
}
/**
* sets last access time of the stream content
*
* @param int $fileatime
* @return $this
* @since 0.9
*/
public function lastAccessed($fileatime)
{
$this->lastAccessed = $fileatime;
return $this;
}
/**
* returns the last access time of the stream content
*
* @return int
* @since 0.9
*/
public function fileatime()
{
return $this->lastAccessed;
}
/**
* sets the last attribute modification time of the stream content
*
* @param int $filectime
* @return $this
* @since 0.9
*/
public function lastAttributeModified($filectime)
{
$this->lastAttributeModified = $filectime;
return $this;
}
/**
* returns the last attribute modification time of the stream content
*
* @return int
* @since 0.9
*/
public function filectime()
{
return $this->lastAttributeModified;
}
/**
* adds content to given container
*
* @param vfsStreamContainer $container
* @return $this
*/
public function at(vfsStreamContainer $container)
{
$container->addChild($this);
return $this;
}
/**
* change file mode to given permissions
*
* @param int $permissions
* @return $this
*/
public function chmod($permissions)
{
$this->permissions = $permissions;
$this->lastAttributeModified = time();
clearstatcache();
return $this;
}
/**
* returns permissions
*
* @return int
*/
public function getPermissions()
{
return $this->permissions;
}
/**
* checks whether content is readable
*
* @param int $user id of user to check for
* @param int $group id of group to check for
* @return bool
*/
public function isReadable($user, $group)
{
if ($this->user === $user) {
$check = 0400;
} elseif ($this->group === $group) {
$check = 0040;
} else {
$check = 0004;
}
return (bool) ($this->permissions & $check);
}
/**
* checks whether content is writable
*
* @param int $user id of user to check for
* @param int $group id of group to check for
* @return bool
*/
public function isWritable($user, $group)
{
if ($this->user === $user) {
$check = 0200;
} elseif ($this->group === $group) {
$check = 0020;
} else {
$check = 0002;
}
return (bool) ($this->permissions & $check);
}
/**
* checks whether content is executable
*
* @param int $user id of user to check for
* @param int $group id of group to check for
* @return bool
*/
public function isExecutable($user, $group)
{
if ($this->user === $user) {
$check = 0100;
} elseif ($this->group === $group) {
$check = 0010;
} else {
$check = 0001;
}
return (bool) ($this->permissions & $check);
}
/**
* change owner of file to given user
*
* @param int $user
* @return $this
*/
public function chown($user)
{
$this->user = $user;
$this->lastAttributeModified = time();
return $this;
}
/**
* checks whether file is owned by given user
*
* @param int $user
* @return bool
*/
public function isOwnedByUser($user)
{
return $this->user === $user;
}
/**
* returns owner of file
*
* @return int
*/
public function getUser()
{
return $this->user;
}
/**
* change owner group of file to given group
*
* @param int $group
* @return $this
*/
public function chgrp($group)
{
$this->group = $group;
$this->lastAttributeModified = time();
return $this;
}
/**
* checks whether file is owned by group
*
* @param int $group
* @return bool
*/
public function isOwnedByGroup($group)
{
return $this->group === $group;
}
/**
* returns owner group of file
*
* @return int
*/
public function getGroup()
{
return $this->group;
}
/**
* sets parent path
*
* @param string $parentPath
* @internal only to be set by parent
* @since 1.2.0
*/
public function setParentPath($parentPath)
{
$this->parentPath = $parentPath;
}
/**
* returns path to this content
*
* @return string
* @since 1.2.0
*/
public function path()
{
if (null === $this->parentPath) {
return $this->name;
}
return $this->parentPath . '/' . $this->name;
}
/**
* returns complete vfsStream url for this content
*
* @return string
* @since 1.2.0
*/
public function url()
{
return vfsStream::url($this->path());
}
}
?>

View file

@ -0,0 +1,34 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs;
/**
* Block container.
*
* @api
*/
class vfsStreamBlock extends vfsStreamFile
{
/**
* constructor
*
* @param string $name
* @param int $permissions optional
*/
public function __construct($name, $permissions = null)
{
if (empty($name)) {
throw new vfsStreamException('Name of Block device was empty');
}
parent::__construct($name, $permissions);
$this->type = vfsStreamContent::TYPE_BLOCK;
}
}

View file

@ -0,0 +1,62 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs;
/**
* Interface for stream contents that are able to store other stream contents.
*/
interface vfsStreamContainer extends \IteratorAggregate
{
/**
* adds child to the directory
*
* @param vfsStreamContent $child
*/
public function addChild(vfsStreamContent $child);
/**
* removes child from the directory
*
* @param string $name
* @return bool
*/
public function removeChild($name);
/**
* checks whether the container contains a child with the given name
*
* @param string $name
* @return bool
*/
public function hasChild($name);
/**
* returns the child with the given name
*
* @param string $name
* @return vfsStreamContent
*/
public function getChild($name);
/**
* checks whether directory contains any children
*
* @return bool
* @since 0.10.0
*/
public function hasChildren();
/**
* returns a list of children for this directory
*
* @return vfsStreamContent[]
*/
public function getChildren();
}
?>

View file

@ -0,0 +1,94 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs;
/**
* Iterator for children of a directory container.
*/
class vfsStreamContainerIterator implements \Iterator
{
/**
* list of children from container to iterate over
*
* @type vfsStreamContent[]
*/
protected $children;
/**
* constructor
*
* @param vfsStreamContent[] $children
*/
public function __construct(array $children)
{
$this->children = $children;
if (vfsStream::useDotfiles()) {
array_unshift($this->children, new DotDirectory('.'), new DotDirectory('..'));
}
reset($this->children);
}
/**
* resets children pointer
*/
public function rewind()
{
reset($this->children);
}
/**
* returns the current child
*
* @return vfsStreamContent
*/
public function current()
{
$child = current($this->children);
if (false === $child) {
return null;
}
return $child;
}
/**
* returns the name of the current child
*
* @return string
*/
public function key()
{
$child = current($this->children);
if (false === $child) {
return null;
}
return $child->getName();
}
/**
* iterates to next child
*/
public function next()
{
next($this->children);
}
/**
* checks if the current value is valid
*
* @return bool
*/
public function valid()
{
return (false !== current($this->children));
}
}
?>

View file

@ -0,0 +1,214 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs;
/**
* Interface for stream contents.
*/
interface vfsStreamContent
{
/**
* stream content type: file
*
* @see getType()
*/
const TYPE_FILE = 0100000;
/**
* stream content type: directory
*
* @see getType()
*/
const TYPE_DIR = 0040000;
/**
* stream content type: symbolic link
*
* @see getType();
*/
#const TYPE_LINK = 0120000;
/**
* stream content type: block
*
* @see getType()
*/
const TYPE_BLOCK = 0060000;
/**
* returns the file name of the content
*
* @return string
*/
public function getName();
/**
* renames the content
*
* @param string $newName
*/
public function rename($newName);
/**
* checks whether the container can be applied to given name
*
* @param string $name
* @return bool
*/
public function appliesTo($name);
/**
* returns the type of the container
*
* @return int
*/
public function getType();
/**
* returns size of content
*
* @return int
*/
public function size();
/**
* sets the last modification time of the stream content
*
* @param int $filemtime
* @return vfsStreamContent
*/
public function lastModified($filemtime);
/**
* returns the last modification time of the stream content
*
* @return int
*/
public function filemtime();
/**
* adds content to given container
*
* @param vfsStreamContainer $container
* @return vfsStreamContent
*/
public function at(vfsStreamContainer $container);
/**
* change file mode to given permissions
*
* @param int $permissions
* @return vfsStreamContent
*/
public function chmod($permissions);
/**
* returns permissions
*
* @return int
*/
public function getPermissions();
/**
* checks whether content is readable
*
* @param int $user id of user to check for
* @param int $group id of group to check for
* @return bool
*/
public function isReadable($user, $group);
/**
* checks whether content is writable
*
* @param int $user id of user to check for
* @param int $group id of group to check for
* @return bool
*/
public function isWritable($user, $group);
/**
* checks whether content is executable
*
* @param int $user id of user to check for
* @param int $group id of group to check for
* @return bool
*/
public function isExecutable($user, $group);
/**
* change owner of file to given user
*
* @param int $user
* @return vfsStreamContent
*/
public function chown($user);
/**
* checks whether file is owned by given user
*
* @param int $user
* @return bool
*/
public function isOwnedByUser($user);
/**
* returns owner of file
*
* @return int
*/
public function getUser();
/**
* change owner group of file to given group
*
* @param int $group
* @return vfsStreamContent
*/
public function chgrp($group);
/**
* checks whether file is owned by group
*
* @param int $group
* @return bool
*/
public function isOwnedByGroup($group);
/**
* returns owner group of file
*
* @return int
*/
public function getGroup();
/**
* sets parent path
*
* @param string $parentPath
* @internal only to be set by parent
* @since 1.2.0
*/
public function setParentPath($parentPath);
/**
* returns path to this content
*
* @return string
* @since 1.2.0
*/
public function path();
/**
* returns complete vfsStream url for this content
*
* @return string
* @since 1.2.0
*/
public function url();
}
?>

View file

@ -0,0 +1,267 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs;
/**
* Directory container.
*
* @api
*/
class vfsStreamDirectory extends vfsStreamAbstractContent implements vfsStreamContainer
{
/**
* list of directory children
*
* @type vfsStreamContent[]
*/
protected $children = array();
/**
* constructor
*
* @param string $name
* @param int $permissions optional
* @throws vfsStreamException
*/
public function __construct($name, $permissions = null)
{
if (strstr($name, '/') !== false) {
throw new vfsStreamException('Directory name can not contain /.');
}
$this->type = vfsStreamContent::TYPE_DIR;
parent::__construct($name, $permissions);
}
/**
* returns default permissions for concrete implementation
*
* @return int
* @since 0.8.0
*/
protected function getDefaultPermissions()
{
return 0777;
}
/**
* returns size of directory
*
* The size of a directory is always 0 bytes. To calculate the summarized
* size of all children in the directory use sizeSummarized().
*
* @return int
*/
public function size()
{
return 0;
}
/**
* returns summarized size of directory and its children
*
* @return int
*/
public function sizeSummarized()
{
$size = 0;
foreach ($this->children as $child) {
if ($child->getType() === vfsStreamContent::TYPE_DIR) {
$size += $child->sizeSummarized();
} else {
$size += $child->size();
}
}
return $size;
}
/**
* renames the content
*
* @param string $newName
* @throws vfsStreamException
*/
public function rename($newName)
{
if (strstr($newName, '/') !== false) {
throw new vfsStreamException('Directory name can not contain /.');
}
parent::rename($newName);
}
/**
* sets parent path
*
* @param string $parentPath
* @internal only to be set by parent
* @since 1.2.0
*/
public function setParentPath($parentPath)
{
parent::setParentPath($parentPath);
foreach ($this->children as $child) {
$child->setParentPath($this->path());
}
}
/**
* adds child to the directory
*
* @param vfsStreamContent $child
*/
public function addChild(vfsStreamContent $child)
{
$child->setParentPath($this->path());
$this->children[$child->getName()] = $child;
$this->updateModifications();
}
/**
* removes child from the directory
*
* @param string $name
* @return bool
*/
public function removeChild($name)
{
foreach ($this->children as $key => $child) {
if ($child->appliesTo($name)) {
$child->setParentPath(null);
unset($this->children[$key]);
$this->updateModifications();
return true;
}
}
return false;
}
/**
* updates internal timestamps
*/
protected function updateModifications()
{
$time = time();
$this->lastAttributeModified = $time;
$this->lastModified = $time;
}
/**
* checks whether the container contains a child with the given name
*
* @param string $name
* @return bool
*/
public function hasChild($name)
{
return ($this->getChild($name) !== null);
}
/**
* returns the child with the given name
*
* @param string $name
* @return vfsStreamContent
*/
public function getChild($name)
{
$childName = $this->getRealChildName($name);
foreach ($this->children as $child) {
if ($child->getName() === $childName) {
return $child;
}
if ($child->appliesTo($childName) === true && $child->hasChild($childName) === true) {
return $child->getChild($childName);
}
}
return null;
}
/**
* helper method to detect the real child name
*
* @param string $name
* @return string
*/
protected function getRealChildName($name)
{
if ($this->appliesTo($name) === true) {
return self::getChildName($name, $this->name);
}
return $name;
}
/**
* helper method to calculate the child name
*
* @param string $name
* @param string $ownName
* @return string
*/
protected static function getChildName($name, $ownName)
{
if ($name === $ownName) {
return $name;
}
return substr($name, strlen($ownName) + 1);
}
/**
* checks whether directory contains any children
*
* @return bool
* @since 0.10.0
*/
public function hasChildren()
{
return (count($this->children) > 0);
}
/**
* returns a list of children for this directory
*
* @return vfsStreamContent[]
*/
public function getChildren()
{
return array_values($this->children);
}
/**
* returns iterator for the children
*
* @return vfsStreamContainerIterator
*/
public function getIterator()
{
return new vfsStreamContainerIterator($this->children);
}
/**
* checks whether dir is a dot dir
*
* @return bool
*/
public function isDot()
{
if ('.' === $this->name || '..' === $this->name) {
return true;
}
return false;
}
}
?>

View file

@ -0,0 +1,20 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs;
/**
* Exception for vfsStream errors.
*
* @api
*/
class vfsStreamException extends \Exception
{
// intentionally empty
}
?>

View file

@ -0,0 +1,394 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs;
use org\bovigo\vfs\content\FileContent;
use org\bovigo\vfs\content\StringBasedFileContent;
/**
* File container.
*
* @api
*/
class vfsStreamFile extends vfsStreamAbstractContent
{
/**
* content of the file
*
* @type FileContent
*/
private $content;
/**
* Resource id which exclusively locked this file
*
* @type string
*/
protected $exclusiveLock;
/**
* Resources ids which currently holds shared lock to this file
*
* @type bool[string]
*/
protected $sharedLock = array();
/**
* constructor
*
* @param string $name
* @param int $permissions optional
*/
public function __construct($name, $permissions = null)
{
$this->content = new StringBasedFileContent(null);
$this->type = vfsStreamContent::TYPE_FILE;
parent::__construct($name, $permissions);
}
/**
* returns default permissions for concrete implementation
*
* @return int
* @since 0.8.0
*/
protected function getDefaultPermissions()
{
return 0666;
}
/**
* checks whether the container can be applied to given name
*
* @param string $name
* @return bool
*/
public function appliesTo($name)
{
return ($name === $this->name);
}
/**
* alias for withContent()
*
* @param string $content
* @return vfsStreamFile
* @see withContent()
*/
public function setContent($content)
{
return $this->withContent($content);
}
/**
* sets the contents of the file
*
* Setting content with this method does not change the time when the file
* was last modified.
*
* @param string]FileContent $content
* @return vfsStreamFile
* @throws \InvalidArgumentException
*/
public function withContent($content)
{
if (is_string($content)) {
$this->content = new StringBasedFileContent($content);
} elseif ($content instanceof FileContent) {
$this->content = $content;
} else {
throw new \InvalidArgumentException('Given content must either be a string or an instance of org\bovigo\vfs\content\FileContent');
}
return $this;
}
/**
* returns the contents of the file
*
* Getting content does not change the time when the file
* was last accessed.
*
* @return string
*/
public function getContent()
{
return $this->content->content();
}
/**
* simply open the file
*
* @since 0.9
*/
public function open()
{
$this->content->seek(0, SEEK_SET);
$this->lastAccessed = time();
}
/**
* open file and set pointer to end of file
*
* @since 0.9
*/
public function openForAppend()
{
$this->content->seek(0, SEEK_END);
$this->lastAccessed = time();
}
/**
* open file and truncate content
*
* @since 0.9
*/
public function openWithTruncate()
{
$this->open();
$this->content->truncate(0);
$time = time();
$this->lastAccessed = $time;
$this->lastModified = $time;
}
/**
* reads the given amount of bytes from content
*
* Using this method changes the time when the file was last accessed.
*
* @param int $count
* @return string
*/
public function read($count)
{
$this->lastAccessed = time();
return $this->content->read($count);
}
/**
* returns the content until its end from current offset
*
* Using this method changes the time when the file was last accessed.
*
* @return string
* @deprecated since 1.3.0
*/
public function readUntilEnd()
{
$this->lastAccessed = time();
return $this->content->readUntilEnd();
}
/**
* writes an amount of data
*
* Using this method changes the time when the file was last modified.
*
* @param string $data
* @return amount of written bytes
*/
public function write($data)
{
$this->lastModified = time();
return $this->content->write($data);
}
/**
* Truncates a file to a given length
*
* @param int $size length to truncate file to
* @return bool
* @since 1.1.0
*/
public function truncate($size)
{
$this->content->truncate($size);
$this->lastModified = time();
return true;
}
/**
* checks whether pointer is at end of file
*
* @return bool
*/
public function eof()
{
return $this->content->eof();
}
/**
* returns the current position within the file
*
* @return int
* @deprecated since 1.3.0
*/
public function getBytesRead()
{
return $this->content->bytesRead();
}
/**
* seeks to the given offset
*
* @param int $offset
* @param int $whence
* @return bool
*/
public function seek($offset, $whence)
{
return $this->content->seek($offset, $whence);
}
/**
* returns size of content
*
* @return int
*/
public function size()
{
return $this->content->size();
}
/**
* locks file for
*
* @param resource|vfsStreamWrapper $resource
* @param int $operation
* @return bool
* @since 0.10.0
* @see https://github.com/mikey179/vfsStream/issues/6
* @see https://github.com/mikey179/vfsStream/issues/40
*/
public function lock($resource, $operation)
{
if ((LOCK_NB & $operation) == LOCK_NB) {
$operation = $operation - LOCK_NB;
}
// call to lock file on the same file handler firstly releases the lock
$this->unlock($resource);
if (LOCK_EX === $operation) {
if ($this->isLocked()) {
return false;
}
$this->setExclusiveLock($resource);
} elseif(LOCK_SH === $operation) {
if ($this->hasExclusiveLock()) {
return false;
}
$this->addSharedLock($resource);
}
return true;
}
/**
* Removes lock from file acquired by given resource
*
* @param resource|vfsStreamWrapper $resource
* @see https://github.com/mikey179/vfsStream/issues/40
*/
public function unlock($resource) {
if ($this->hasExclusiveLock($resource)) {
$this->exclusiveLock = null;
}
if ($this->hasSharedLock($resource)) {
unset($this->sharedLock[$this->getResourceId($resource)]);
}
}
/**
* Set exlusive lock on file by given resource
*
* @param resource|vfsStreamWrapper $resource
* @see https://github.com/mikey179/vfsStream/issues/40
*/
protected function setExclusiveLock($resource) {
$this->exclusiveLock = $this->getResourceId($resource);
}
/**
* Add shared lock on file by given resource
*
* @param resource|vfsStreamWrapper $resource
* @see https://github.com/mikey179/vfsStream/issues/40
*/
protected function addSharedLock($resource) {
$this->sharedLock[$this->getResourceId($resource)] = true;
}
/**
* checks whether file is locked
*
* @param resource|vfsStreamWrapper $resource
* @return bool
* @since 0.10.0
* @see https://github.com/mikey179/vfsStream/issues/6
* @see https://github.com/mikey179/vfsStream/issues/40
*/
public function isLocked($resource = null)
{
return $this->hasSharedLock($resource) || $this->hasExclusiveLock($resource);
}
/**
* checks whether file is locked in shared mode
*
* @param resource|vfsStreamWrapper $resource
* @return bool
* @since 0.10.0
* @see https://github.com/mikey179/vfsStream/issues/6
* @see https://github.com/mikey179/vfsStream/issues/40
*/
public function hasSharedLock($resource = null)
{
if (null !== $resource) {
return isset($this->sharedLock[$this->getResourceId($resource)]);
}
return !empty($this->sharedLock);
}
/**
* Returns unique resource id
*
* @param resource|vfsStreamWrapper $resource
* @return string
* @see https://github.com/mikey179/vfsStream/issues/40
*/
public function getResourceId($resource) {
if (is_resource($resource)) {
$data = stream_get_meta_data($resource);
$resource = $data['wrapper_data'];
}
return spl_object_hash($resource);
}
/**
* checks whether file is locked in exclusive mode
*
* @param resource|vfsStreamWrapper $resource
* @return bool
* @since 0.10.0
* @see https://github.com/mikey179/vfsStream/issues/6
* @see https://github.com/mikey179/vfsStream/issues/40
*/
public function hasExclusiveLock($resource = null)
{
if (null !== $resource) {
return $this->exclusiveLock === $this->getResourceId($resource);
}
return null !== $this->exclusiveLock;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,65 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs\visitor;
use org\bovigo\vfs\vfsStreamContent;
use org\bovigo\vfs\vfsStreamBlock;
/**
* Abstract base class providing an implementation for the visit() method.
*
* @since 0.10.0
* @see https://github.com/mikey179/vfsStream/issues/10
*/
abstract class vfsStreamAbstractVisitor implements vfsStreamVisitor
{
/**
* visit a content and process it
*
* @param vfsStreamContent $content
* @return vfsStreamVisitor
* @throws \InvalidArgumentException
*/
public function visit(vfsStreamContent $content)
{
switch ($content->getType()) {
case vfsStreamContent::TYPE_BLOCK:
$this->visitBlockDevice($content);
break;
case vfsStreamContent::TYPE_FILE:
$this->visitFile($content);
break;
case vfsStreamContent::TYPE_DIR:
if (!$content->isDot()) {
$this->visitDirectory($content);
}
break;
default:
throw new \InvalidArgumentException('Unknown content type ' . $content->getType() . ' for ' . $content->getName());
}
return $this;
}
/**
* visit a block device and process it
*
* @param vfsStreamBlock $block
* @return vfsStreamVisitor
*/
public function visitBlockDevice(vfsStreamBlock $block)
{
return $this->visitFile($block);
}
}
?>

View file

@ -0,0 +1,108 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs\visitor;
use org\bovigo\vfs\vfsStreamContent;
use org\bovigo\vfs\vfsStreamDirectory;
use org\bovigo\vfs\vfsStreamFile;
use org\bovigo\vfs\vfsStreamBlock;
/**
* Visitor which traverses a content structure recursively to print it to an output stream.
*
* @since 0.10.0
* @see https://github.com/mikey179/vfsStream/issues/10
*/
class vfsStreamPrintVisitor extends vfsStreamAbstractVisitor
{
/**
* target to write output to
*
* @type resource
*/
protected $out;
/**
* current depth in directory tree
*
* @type int
*/
protected $depth;
/**
* constructor
*
* If no file pointer given it will fall back to STDOUT.
*
* @param resource $out optional
* @throws \InvalidArgumentException
* @api
*/
public function __construct($out = STDOUT)
{
if (is_resource($out) === false || get_resource_type($out) !== 'stream') {
throw new \InvalidArgumentException('Given filepointer is not a resource of type stream');
}
$this->out = $out;
}
/**
* visit a file and process it
*
* @param vfsStreamFile $file
* @return vfsStreamPrintVisitor
*/
public function visitFile(vfsStreamFile $file)
{
$this->printContent($file->getName());
return $this;
}
/**
* visit a block device and process it
*
* @param vfsStreamBlock $block
* @return vfsStreamPrintVisitor
*/
public function visitBlockDevice(vfsStreamBlock $block)
{
$name = '[' . $block->getName() . ']';
$this->printContent($name);
return $this;
}
/**
* visit a directory and process it
*
* @param vfsStreamDirectory $dir
* @return vfsStreamPrintVisitor
*/
public function visitDirectory(vfsStreamDirectory $dir)
{
$this->printContent($dir->getName());
$this->depth++;
foreach ($dir as $child) {
$this->visit($child);
}
$this->depth--;
return $this;
}
/**
* helper method to print the content
*
* @param string $name
*/
protected function printContent($name)
{
fwrite($this->out, str_repeat(' ', $this->depth) . '- ' . $name . "\n");
}
}
?>

View file

@ -0,0 +1,112 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs\visitor;
use org\bovigo\vfs\vfsStreamDirectory;
use org\bovigo\vfs\vfsStreamFile;
use org\bovigo\vfs\vfsStreamBlock;
/**
* Visitor which traverses a content structure recursively to create an array structure from it.
*
* @since 0.10.0
* @see https://github.com/mikey179/vfsStream/issues/10
*/
class vfsStreamStructureVisitor extends vfsStreamAbstractVisitor
{
/**
* collected structure
*
* @type array
*/
protected $structure = array();
/**
* poiting to currently iterated directory
*
* @type array
*/
protected $current;
/**
* constructor
*
* @api
*/
public function __construct()
{
$this->reset();
}
/**
* visit a file and process it
*
* @param vfsStreamFile $file
* @return vfsStreamStructureVisitor
*/
public function visitFile(vfsStreamFile $file)
{
$this->current[$file->getName()] = $file->getContent();
return $this;
}
/**
* visit a block device and process it
*
* @param vfsStreamBlock $block
* @return vfsStreamStructureVisitor
*/
public function visitBlockDevice(vfsStreamBlock $block)
{
$this->current['[' . $block->getName() . ']'] = $block->getContent();
return $this;
}
/**
* visit a directory and process it
*
* @param vfsStreamDirectory $dir
* @return vfsStreamStructureVisitor
*/
public function visitDirectory(vfsStreamDirectory $dir)
{
$this->current[$dir->getName()] = array();
$tmp =& $this->current;
$this->current =& $tmp[$dir->getName()];
foreach ($dir as $child) {
$this->visit($child);
}
$this->current =& $tmp;
return $this;
}
/**
* returns structure of visited contents
*
* @return array
* @api
*/
public function getStructure()
{
return $this->structure;
}
/**
* resets structure so visitor could be reused
*
* @return vfsStreamStructureVisitor
*/
public function reset()
{
$this->structure = array();
$this->current =& $this->structure;
return $this;
}
}
?>

View file

@ -0,0 +1,56 @@
<?php
/**
* This file is part of vfsStream.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package org\bovigo\vfs
*/
namespace org\bovigo\vfs\visitor;
use org\bovigo\vfs\vfsStreamContent;
use org\bovigo\vfs\vfsStreamDirectory;
use org\bovigo\vfs\vfsStreamFile;
use org\bovigo\vfs\vfsStreamBlock;
/**
* Interface for a visitor to work on a vfsStream content structure.
*
* @since 0.10.0
* @see https://github.com/mikey179/vfsStream/issues/10
*/
interface vfsStreamVisitor
{
/**
* visit a content and process it
*
* @param vfsStreamContent $content
* @return vfsStreamVisitor
*/
public function visit(vfsStreamContent $content);
/**
* visit a file and process it
*
* @param vfsStreamFile $file
* @return vfsStreamVisitor
*/
public function visitFile(vfsStreamFile $file);
/**
* visit a directory and process it
*
* @param vfsStreamDirectory $dir
* @return vfsStreamVisitor
*/
public function visitDirectory(vfsStreamDirectory $dir);
/**
* visit a block device and process it
*
* @param vfsStreamBlock $block
* @return vfsStreamVisitor
*/
public function visitBlockDevice(vfsStreamBlock $block);
}
?>