Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit eac4022

Browse files
committed
Merge branch 'feature/docs' into develop
Close #25 Fixes #24
2 parents 4eca9d8 + 25a582e commit eac4022

21 files changed

+158
-27
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
.*.sw*
77
.*.un~
88
nbproject
9+
doc/html/
910
tmp/
11+
zf-mkdoc-theme/
1012

1113
clover.xml
1214
composer.lock

.travis.yml

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@ language: php
44

55
branches:
66
except:
7-
- /^release-.*$/
7+
- /^release-\d+\.\d+\.\d+.*$/
88
- /^ghgfk-.*$/
99

1010
cache:
1111
directories:
1212
- $HOME/.composer/cache
13+
- $HOME/.local
14+
- zf-mkdoc-theme
15+
16+
env:
17+
global:
18+
- SITE_URL: https://zendframework.github.io/zend-file
19+
- GH_USER_NAME: "Matthew Weier O'Phinney"
20+
- GH_USER_EMAIL: [email protected]
21+
- GH_REF: github.com/zendframework/zend-file.git
22+
- secure: "ULsxLLRxxpphEwpOfpTWzW85g8LLoCsa9M5g2fiWlKhvl+FjfvSTkMmDHCzNq6QSfASpI+MTyZBxj34v8Fqq/U82IXCfoHP1mFYw//5qg6Xm28nVz48chjjCD5eIzKNI6vIdY+S+mhstcAkl3AqXAczsIxK34B6BZQxWOUUnDAn/jJ2bPpyiI/laePt76jel8xeMjNYrnIV9VvwsK9klttEOifMyK1pnGgTf8OvPD4WNaaiFLroE1JGFJJrbnColabFjXIQbKRupGpNp/Cz6Nn0M3I8Da1sSa1zeq4485c2eR61rJ7HXUX769wvPakDgrMjAGcIZGwvzfPqD0ldefXU2gsRpom4p7wUxQGndyQAF3ytUFn5QBz8TRPQ1AIT2uIsd3dblvqFn17HAPSKNihX4F9xkSogp/D5znYYwrZ3hrjZRY9idRJqDYkDV2/VTu1RiKI/SukPj2wTLxQwZttxHFhJapjKDzJ289TekA2ShBewCNR+3gl9uetzb0ir4C8l3TWo40fBjG8SMxan4y48EdOetAoWwjnigTnR0aXA/Mgm0Ly/ide1Xuho12P/cj54EWdmE+5LTUd70O0oBp0sLRZG6S3Wz0jRy4Z7XvbXCaoIBXHcmFjPOyfcmjgh0BBkHM0Ir8Cwe5CgwpaMQnUjw8nRDdG+TC62UczOyoHo="
1323

1424
matrix:
1525
fast_finish: true
@@ -23,6 +33,8 @@ matrix:
2333
- php: 5.6
2434
env:
2535
- EXECUTE_TEST_COVERALLS=true
36+
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
37+
- PATH="$HOME/.local/bin:$PATH"
2638
- php: 5.6
2739
env:
2840
- ZEND_SERVICEMANAGER_VERSION="^2.7.5"
@@ -55,6 +67,10 @@ script:
5567
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi
5668
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit ; fi
5769
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run ; fi
70+
- if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi
71+
72+
after_success:
73+
- if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi
5874

5975
after_script:
6076
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi

CHANGELOG.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ All notable changes to this project will be documented in this file, in reverse
66

77
### Added
88

9-
- Nothing.
9+
- [#25](https://github.com/zendframework/zend-file/pull/25) adds and publishes
10+
documentation to https://zendframework.github.io/zend-file/
1011

1112
### Deprecated
1213

13-
- Nothing.
14+
- [#25](https://github.com/zendframework/zend-file/pull/25) deprecates the
15+
`Zend\File\Transfer` subcomponent. Its functionality is now split between each
16+
of:
17+
- zend-filter, for moving uploaded files to their final location, renaming
18+
them, and potentially transforming them.
19+
- zend-validator, for validating upload succes, file type, hash, etc.
20+
- zend-progressbar, for managing upload status.
1421

1522
### Removed
1623

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
[![Build Status](https://secure.travis-ci.org/zendframework/zend-file.svg?branch=master)](https://secure.travis-ci.org/zendframework/zend-file)
44
[![Coverage Status](https://coveralls.io/repos/zendframework/zend-file/badge.svg?branch=master)](https://coveralls.io/r/zendframework/zend-file?branch=master)
55

6-
`Zend\File` is a component used to manage file transfer and class autoloading.
7-
6+
zend-file provides a `ClassFileLocator` for locating PHP files containing
7+
classes, abstract classes, interfaces, and traits in a specified tree.
88

99
- File issues at https://github.com/zendframework/zend-file/issues
10-
- Documentation is at http://framework.zend.com/manual/current/en/index.html#zend-file
10+
- Documentation is at https://zendframework.github.io/zend-file/

doc/book/class-file-locator.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# ClassFileLocator
2+
3+
`Zend\File\ClassFileLocator` is a PHP [FilterIterator](http://php.net/FilterIterator)
4+
for use with locating files containing PHP classes, interfaces, abstracts, or
5+
traits. As such, it should be used in conjunction with a
6+
[DirectoryIterator](http://php.net/DirectoryIterator) or
7+
[RecursiveDirectoryIterator](http://php.net/RecursiveDirectoryIterator).
8+
9+
Use cases include building class maps for autoloading.
10+
11+
## Usage
12+
13+
The `ClassFileLocator` constructor can take one of:
14+
15+
- a string representing a directory location; if valid, this will be used to
16+
seed a `RecursiveDirectoryIterator` instance.
17+
- a `DirectoryIterator` instance.
18+
- a `RecursiveDirectoryIterator` instance.
19+
20+
In each case, once constructed, iteration will result in a list of files
21+
containing PHP clases, interfaces, abstracts, or traits.
22+
23+
Instead of returning standard [SplFileInfo](http://php.net/SplFileInfo)
24+
instances, the `ClassFileLocator` is configured to cast to
25+
`Zend\File\PhpClassFile` instances, which extend `SplFileInfo`, and provide the
26+
following additional methods:
27+
28+
- `getClasses()`: returns an array of all classes, abstract classes, interfaces,
29+
and traits defined in the file; all names are fully qualified.
30+
- `getNamespaces()`: returns an array of namespaces defined in the file.
31+
32+
> ### Tokenization
33+
>
34+
> The `ClassFileLocator` uses the [tokenizer](http://php.net/tokenizer)
35+
> extension in order to locate items of interest; as such, its operations
36+
> will not execute PHP files it finds.
37+
38+
## Example
39+
40+
The following will spit out a PHP file that returns a class map for the `src/`
41+
directory in which it is run:
42+
43+
```php
44+
<?php
45+
use Zend\File\ClassFileLocator;
46+
47+
$path = realpath(getcwd() . '/src');
48+
49+
$locator = new ClassFileLocator($path);
50+
$map = [];
51+
52+
foreach ($locator as $file) {
53+
$filename = str_replace($path . '/', '', $file->getRealPath());
54+
foreach ($file->getClasses() as $class) {
55+
$map[$class] = $filename;
56+
}
57+
}
58+
59+
printf("<?php\nreturn %s;", var_export($map, true));
60+
```

doc/book/index.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div class="container">
2+
<div class="jumbotron">
3+
<h1>zend-file</h1>
4+
5+
<p>Locate PHP classfiles.</p>
6+
7+
<pre><code class="language-bash">$ composer require zendframework/zend-file</code></pre>
8+
</div>
9+
</div>
10+

doc/book/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../README.md

doc/book/intro.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Introduction
2+
3+
zend-file provides two specific pieces of functionality:
4+
5+
- a `ClassFileLocator`, which can be used to find PHP class files under a given
6+
tree.
7+
- a `Transfer` subcomponent, for managing file uploads and reporting upload
8+
progress.
9+
10+
**The `Transfer` subcomponent is deprecated**, and we recommend using the
11+
file-related functionality in:
12+
13+
- [zend-filter](https://zendframework.github.io/zend-filter/), which provides
14+
functionality around moving uplaoded files to their final locations, renaming
15+
uploaded files, and encrypting and decrypting uploaded files.
16+
- [zend-validator](https://github.com/zendframework/zend-validator/), which
17+
provides functionality around validating uploaded files based on: number of
18+
files uploaded, MIME types and/or extensions, upload status, compression,
19+
hashing, and more.
20+
- [zend-progressbar](https://github.com/zendframework/zend-progressbar/), which
21+
provides functionality for providing file upload status.
22+
23+
If you are determined to use the `Transfer` subcomponent, despite its
24+
deprecation, please see the [Zend Framework 1 documentation on the component](http://framework.zend.com/manual/1.12/en/zend.file.transfer.introduction.html);
25+
you can substitute `Underscore_Separated_Names` for their namespaced equivalents
26+
to adapt the examples to this component.

doc/book/zend.file.class-file-locator.md

-13
This file was deleted.

doc/bookdown.json

-7
This file was deleted.

mkdocs.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
docs_dir: doc/book
2+
site_dir: doc/html
3+
pages:
4+
- index.md
5+
- Intro: intro.md
6+
- ClassFileLocator: class-file-locator.md
7+
site_name: zend-file
8+
site_description: zend-file
9+
repo_url: 'https://github.com/zendframework/zend-file'
10+
copyright: 'Copyright (c) 2016 <a href="http://www.zend.com/">Zend Technologies USA Inc.</a>'

src/Transfer/Adapter/AbstractAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* modifying that should be done in tandem with a rewrite to utilize validator
3131
* and filter chains instead.
3232
*
33-
* @todo Rewrite
33+
* @deprecated since 2.7.0, and scheduled for removal with 3.0.0
3434
*/
3535
abstract class AbstractAdapter implements TranslatorAwareInterface
3636
{

src/Transfer/Adapter/FilterPluginManager.php

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Enforces that filters retrieved are instances of
1919
* FilterInterface. Additionally, it registers a number of default filters.
2020
*
21+
* @deprecated since 2.7.0, and scheduled for removal with 3.0.0
2122
*/
2223
class FilterPluginManager extends BaseManager
2324
{

src/Transfer/Adapter/Http.php

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/**
1818
* File transfer adapter class for the HTTP protocol
1919
*
20+
* @deprecated since 2.7.0, and scheduled for removal with 3.0.0
2021
*/
2122
class Http extends AbstractAdapter
2223
{

src/Transfer/Adapter/ValidatorPluginManager.php

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use Zend\Validator\File;
1313
use Zend\Validator\ValidatorPluginManager as BaseManager;
1414

15+
/**
16+
* @deprecated since 2.7.0, and scheduled for removal with 3.0.0
17+
*/
1518
class ValidatorPluginManager extends BaseManager
1619
{
1720
protected $defaultFileValidationAliases = [

src/Transfer/Exception/BadMethodCallException.php

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
use Zend\File\Exception;
1313

14+
/**
15+
* @deprecated since 2.7.0, and scheduled for removal with 3.0.0
16+
*/
1417
class BadMethodCallException extends Exception\BadMethodCallException implements ExceptionInterface
1518
{
1619
}

src/Transfer/Exception/ExceptionInterface.php

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/**
1515
* Exception class for Zend\File\Transfer
1616
*
17+
* @deprecated since 2.7.0, and scheduled for removal with 3.0.0
1718
*/
1819
interface ExceptionInterface extends FileException
1920
{

src/Transfer/Exception/InvalidArgumentException.php

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
use Zend\File\Exception;
1313

14+
/**
15+
* @deprecated since 2.7.0, and scheduled for removal with 3.0.0
16+
*/
1417
class InvalidArgumentException extends Exception\InvalidArgumentException implements ExceptionInterface
1518
{
1619
}

src/Transfer/Exception/PhpEnvironmentException.php

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
namespace Zend\File\Transfer\Exception;
1111

12+
/**
13+
* @deprecated since 2.7.0, and scheduled for removal with 3.0.0
14+
*/
1215
class PhpEnvironmentException extends RuntimeException
1316
{
1417
}

src/Transfer/Exception/RuntimeException.php

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
use Zend\File\Exception;
1313

14+
/**
15+
* @deprecated since 2.7.0, and scheduled for removal with 3.0.0
16+
*/
1417
class RuntimeException extends Exception\RuntimeException implements ExceptionInterface
1518
{
1619
}

src/Transfer/Transfer.php

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
/**
1313
* Base class for all protocols supporting file transfers
1414
*
15+
* @deprecated since 2.7.0, and scheduled for removal with 3.0.0
1516
*/
1617
class Transfer
1718
{

0 commit comments

Comments
 (0)