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

Commit 0099987

Browse files
committed
Merging develop to master in preparation for 2.8.0 release.
2 parents 178d21a + c0708e0 commit 0099987

9 files changed

+361
-60
lines changed

.travis.yml

+11-40
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,14 @@ sudo: false
22

33
language: php
44

5-
branches:
6-
except:
7-
- /^release-\d+\.\d+\.\d+.*$/
8-
- /^ghgfk-.*$/
9-
105
cache:
116
directories:
127
- $HOME/.composer/cache
13-
- vendor
14-
- $HOME/.local
15-
- zf-mkdoc-theme
168

179
env:
1810
global:
1911
- COMPOSER_ARGS="--no-interaction"
2012
- COVERAGE_DEPS="satooshi/php-coveralls"
21-
- LEGACY_DEPS="phpunit/phpunit"
22-
- SITE_URL: https://zendframework.github.io/zend-inputfilter
23-
- GH_USER_NAME: "Matthew Weier O'Phinney"
24-
- GH_USER_EMAIL: [email protected]
25-
- GH_REF: github.com/zendframework/zend-inputfilter.git
26-
- secure: "BZ5FxRDnh7Q4KSjnZXBn+vrY0RjZVHUfOcOIVTLR5hIlBRFBz436GbbyyIGAO+YQ8MGPj8Ek+fm/zuDP9gTafG3fNen4dLJOR4dOYmHUNZRgXdLeCpor6W1kaXOQInEs2mpjnsIlSM5s7/IP3QCkaZcj6GBiYuYLXGrH1PJxhE047B8StV3PWpcHi3idRqsdz26oUTH0szD70QNlk0dHqtbzjr9uSk1pRrz8LZW6WuW8yFEq3X1zDEA/XICTXPBk+CEi68wnX8RhXiTvtDpYUnPF3ZkCy6m94PROmBs0UwTPr9MCQShAVSJ0OikFkvEKJgkHNaKce+FqGK5sGcR1asunx87iMsScNKmM/0FrQOqa1pNsv6/jl+n05FZRKbfoK68bnb4YZmOnNAqPiSrF/8oiBfe2tvZVtFmAIkI6uaGD7jP07ljA9JAqtOuTt4u4DX9J2dNYoNF7+F+jtI8/+Ec1wBFvsI/DF02Mw4KYfFfdz5a5+Xzc84MkaFb+hTmAlP8BPh/7RRciL86rCELvQ2zyfwDYk5q4uLJgwg5VjpS/4B2lsjqomXC3iTYUbmdF1Y9ZFE+tyEi/XlyrQOEHisdgrfIf8Itown3S+2vJh15851UtOWs2FQWtAOM/fv4ovLyZwf6adJ0tEUtHsgr+C8NLjSfeY1i6E5QuoOhG9OA="
2713

2814
matrix:
2915
include:
@@ -33,10 +19,7 @@ matrix:
3319
- php: 5.6
3420
env:
3521
- DEPS=locked
36-
- CS_CHECK=true
37-
- TEST_COVERAGE=true
38-
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
39-
- PATH="$HOME/.local/bin:$PATH"
22+
- LEGACY_DEPS="phpunit/phpunit"
4023
- php: 5.6
4124
env:
4225
- DEPS=latest
@@ -46,60 +29,48 @@ matrix:
4629
- php: 7
4730
env:
4831
- DEPS=locked
32+
- LEGACY_DEPS="phpunit/phpunit"
4933
- php: 7
5034
env:
5135
- DEPS=latest
52-
- TEST_COVERAGE=true
5336
- php: 7.1
5437
env:
5538
- DEPS=lowest
5639
- php: 7.1
5740
env:
5841
- DEPS=locked
42+
- CS_CHECK=true
43+
- TEST_COVERAGE=true
5944
- php: 7.1
6045
env:
6146
- DEPS=latest
62-
- php: hhvm
47+
- php: 7.2
6348
env:
6449
- DEPS=lowest
65-
- php: hhvm
50+
- php: 7.2
6651
env:
6752
- DEPS=locked
68-
- php: hhvm
53+
- php: 7.2
6954
env:
7055
- DEPS=latest
71-
allow_failures:
72-
- php: hhvm
7356

7457
before_install:
7558
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
76-
- travis_retry composer self-update
7759

7860
install:
7961
- travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs
80-
- if [[ $TRAVIS_PHP_VERSION =~ ^5.6 ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
62+
- if [[ $LEGACY_DEPS != '' ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
8163
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
82-
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
64+
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update $COMPOSER_ARGS --prefer-lowest --prefer-stable ; fi
8365
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
84-
- stty cols 120
85-
- COLUMNS=120 composer show
66+
- stty cols 120 && composer show
8667

8768
script:
88-
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; fi
89-
- if [[ $TEST_COVERAGE != 'true' ]]; then composer test ; fi
69+
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
9070
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
91-
- 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
92-
93-
after_success:
94-
- if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi
9571

9672
after_script:
9773
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer upload-coverage ; fi
9874

9975
notifications:
10076
email: false
101-
slack:
102-
rooms:
103-
- secure: "Jlr0RxX9sUVOWeo8BK75JlKYnf0Pj/ZD1p3+keEvAO71iB4zVK1OKlUjdARYx8bgEX8aKSun3v6aImu8NwuCrshl3bkXBtADEiQ7ibghi+apHU3A/HGYtiUfwRMmR4+SNXB5qe7RMA5FbKu5j28acea5N4urJqJIDAgQvlZVJrUCsJDpOpwkJ0BlV/UUA7sUvHTs/N3jsUhL+YZdNjirpcrj1LVdwWBs62h25lJ8BvYkGzg4WckP808dSokbfEtAisg/TyxoBFA+GQESvmch0tvQeZBmdrgBJ/t/MRZy8L+u80oXIs26uTnuIxKWtp8p80WPiGdMsJTxyPr1JpIJXVTGYoAzhjGG8ukXXkKxpc4bbhvEm5aPLh0l1RVzzTbp+RaPSaBBqIpEBpAWzzrJMS7owaPMkZzfv/VjUPxawDK7ZIk1Q+VFdeoWdgiKnmr78VtQ8YWeiwKE2FK6JL+UmKMXNSKKJ3Fz4vnlig0tJ+UrqL3LtKLJmqn7+K8rTntPrCIoxKElruazGuKtyUFR/13l6y10mmwtdj14YmENG1OjWDuG+hzrzs0+MwthqSqIADwduyjxu2XE0AbNjCaXqjpwO72zZgfFYtJppaWAS4VF+XpLDy+Ig11RKJccX1bPbMA06Bl32pJieNCFBua2RWnFTK20NMDf/Bht66nFubs="
104-
on_success: change
105-
on_failure: always

CHANGELOG.md

+28-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5-
## 2.7.6 - 2017-12-04
5+
## 2.8.0 - TBD
66

77
### Added
88

9-
- Nothing.
9+
- [#135](https://github.com/zendframework/zend-inputfilter/pull/135) adds
10+
`Zend\InputFilter\OptionalInputFilter`, which allows defining optional sets of
11+
data. This acts like a standard input filter, but is considered valid if no
12+
data, `null` data, or empty data sets are provided to it; if a non-empty data
13+
set is provided, it will run normal validations.
14+
15+
- [#142](https://github.com/zendframework/zend-inputfilter/pull/142) adds
16+
support for PHP 7.2.
1017

1118
### Changed
1219

@@ -18,6 +25,25 @@ All notable changes to this project will be documented in this file, in reverse
1825

1926
### Removed
2027

28+
- [#142](https://github.com/zendframework/zend-inputfilter/pull/142) removes
29+
support for HHVM.
30+
31+
### Fixed
32+
33+
- Nothing.
34+
35+
## 2.7.6 - 2017-12-04
36+
37+
### Added
38+
39+
- Nothing.
40+
41+
### Deprecated
42+
43+
- Nothing.
44+
45+
### Removed
46+
2147
- Nothing.
2248

2349
### Fixed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"php": "^5.6 || ^7.0",
3333
"zendframework/zend-filter": "^2.6",
3434
"zendframework/zend-stdlib": "^2.7 || ^3.0",
35-
"zendframework/zend-validator": "^2.6"
35+
"zendframework/zend-validator": "^2.10.1"
3636
},
3737
"require-dev": {
3838
"phpunit/phpunit": "^5.7.23 || ^6.4.3",

composer.lock

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/book/optional-input-filters.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Optional Input Filters
2+
3+
- Since 2.8.0
4+
5+
Normally, input filters are _required_, which means that if you compose them as
6+
a subset of another input filter (e.g., to validate a subset of a larger set of
7+
data), and no data is provided for that item, or an empty set of data is
8+
provided, then the input filter will consider the data invalid.
9+
10+
If you want to allow a set of data to be empty, you can use
11+
`Zend\InputFilter\OptionalInputFilter`.
12+
13+
To illustrate this, let's consider a form where a user provides profile
14+
information. The user can provide an optional "title" and a required "email",
15+
and _optionally_ details about a project they lead, which will include the
16+
project title and a URL, both of which are required if present.
17+
18+
First, let's create an `OptionalInputFilter` instance for the project data:
19+
20+
```php
21+
$projectFilter = new OptionalInputFilter();
22+
$projectFilter->add([
23+
'name' => 'project_name',
24+
'required' => true,
25+
]);
26+
$projectFilter->add([
27+
'name' => 'url',
28+
'required' => true,
29+
'validators' => [
30+
['type' => 'uri'],
31+
],
32+
]);
33+
```
34+
35+
Now, we'll create our primary input filter:
36+
37+
```php
38+
$profileFilter = new InputFilter();
39+
$profileFilter->add([
40+
'name' => 'title',
41+
'required' => false,
42+
]);
43+
$profileFilter->add([
44+
'name' => 'email',
45+
'required' => true,
46+
'validators' => [
47+
['type' => 'EmailAddress'],
48+
],
49+
]);
50+
51+
// And, finally, compose our project sub-filter:
52+
$profileFilter->add($projectFilter, 'project');
53+
```
54+
55+
With this defined, we can now validate the following sets of data, presented in
56+
JSON for readability:
57+
58+
- Just profile information:
59+
60+
```json
61+
{
62+
"email": "[email protected]",
63+
"title": "Software Developer"
64+
}
65+
```
66+
67+
- `null` project provided:
68+
69+
```json
70+
{
71+
"email": "[email protected]",
72+
"title": "Software Developer",
73+
"project": null
74+
}
75+
```
76+
77+
- Empty project provided:
78+
79+
```json
80+
{
81+
"email": "[email protected]",
82+
"title": "Software Developer",
83+
"project": {}
84+
}
85+
```
86+
87+
- Valid project provided:
88+
89+
```json
90+
{
91+
"email": "[email protected]",
92+
"title": "Software Developer",
93+
"project": {
94+
"project_name": "zend-inputfilter",
95+
"url": "https://github.com/zend-inputfilter",
96+
}
97+
}
98+
```

mkdocs.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ site_dir: docs/html
33
pages:
44
- index.md
55
- Intro: intro.md
6-
- Specifications: specs.md
7-
- Files: file-input.md
6+
- Reference:
7+
- Specifications: specs.md
8+
- Files: file-input.md
9+
- "Optional Input Filters": optional-input-filters.md
810
site_name: zend-inputfilter
911
site_description: zend-inputfilter
1012
repo_url: 'https://github.com/zendframework/zend-inputfilter'

src/InputFilterPluginManager.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ class InputFilterPluginManager extends AbstractPluginManager
2828
* @var string[]
2929
*/
3030
protected $aliases = [
31-
'inputfilter' => InputFilter::class,
32-
'inputFilter' => InputFilter::class,
33-
'InputFilter' => InputFilter::class,
34-
'collection' => CollectionInputFilter::class,
35-
'Collection' => CollectionInputFilter::class,
31+
'inputfilter' => InputFilter::class,
32+
'inputFilter' => InputFilter::class,
33+
'InputFilter' => InputFilter::class,
34+
'collection' => CollectionInputFilter::class,
35+
'Collection' => CollectionInputFilter::class,
36+
'optionalinputfilter' => OptionalInputFilter::class,
37+
'optionalInputFilter' => OptionalInputFilter::class,
38+
'OptionalInputFilter' => OptionalInputFilter::class,
3639
];
3740

3841
/**
@@ -43,9 +46,11 @@ class InputFilterPluginManager extends AbstractPluginManager
4346
protected $factories = [
4447
InputFilter::class => InvokableFactory::class,
4548
CollectionInputFilter::class => InvokableFactory::class,
49+
OptionalInputFilter::class => InvokableFactory::class,
4650
// v2 canonical FQCN
4751
'zendinputfilterinputfilter' => InvokableFactory::class,
4852
'zendinputfiltercollectioninputfilter' => InvokableFactory::class,
53+
'zendinputfilteroptionalinputfilter' => InvokableFactory::class,
4954
];
5055

5156
/**

0 commit comments

Comments
 (0)