Skip to content

Commit 708cfdd

Browse files
Idrinthmihai-vlc
authored andcommitted
Makes verbal expressions compatible with older versions
* fixing #28 makes VerbalExpressions compatible with 5.3-5.5 as well * fixing requirements in composer.json * just to re-trigger a build let's pray travis doesn't fail downloading a php-version this time.
1 parent b8c2577 commit 708cfdd

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
# General Ignores
12
/vendor
23
composer.lock
34
/phpunit/
5+
# IDEs
46
.idea/
7+
/nbproject/

.travis.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
language: php
22
php:
3+
- '5.4'
4+
- '5.5'
35
- '5.6'
46
- '7.0'
7+
- '7.1'
8+
- '7.2'
59
- hhvm
610
- nightly
11+
matrix:
12+
include:
13+
- php: "5.3"
14+
dist: precise
15+
git:
16+
#there should rarely be a need to clone 50 deep, so this is just reducing build-time
17+
depth: 5
718
before_script:
19+
# no need to provide coverage more than once and no need for the speedbump otherwise
20+
- if [[ ${TRAVIS_PHP_VERSION:0:3} != "7.1" ]]; then phpenv config-rm xdebug.ini || true ; fi
21+
# no need to test formatting more than once and php_codesniffer does not work with older php
22+
- if [[ ${TRAVIS_PHP_VERSION:0:3} != "5.6" ]]; then composer remove --dev squizlabs/php_codesniffer ; fi
823
- composer install
924
script:
10-
- composer check-style
11-
- composer test
25+
# since it's disabled otherwise...
26+
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.6" ]]; then composer check-style ; fi
27+
- composer test

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "project",
55
"description": "PHP Regular expressions made easy",
66
"require": {
7-
"php": ">=5.6"
7+
"php": ">=5.3"
88
},
99
"require-dev": {
1010
"phpunit/phpunit": "* >=4",

src/VerbalExpressions.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,9 @@ public function any($value)
297297
* @return VerbalExpressions
298298
* @throws \InvalidArgumentException
299299
*/
300-
public function range(... $args)
300+
public function range()
301301
{
302+
$args = func_get_args();
302303
$arg_num = count($args);
303304

304305
if ($arg_num%2 != 0) {
@@ -483,8 +484,8 @@ public function test($value)
483484
// php doesn't have g modifier so we remove it if it's there and call preg_match_all()
484485
if (strpos($this->modifiers, 'g') !== false) {
485486
$this->modifiers = str_replace('g', '', $this->modifiers);
486-
487-
return preg_match_all($this->getRegex(), $value);
487+
$matches = array();//because it's not optional in <5.4
488+
return preg_match_all($this->getRegex(), $value, $matches);
488489
}
489490

490491
return (bool) preg_match($this->getRegex(), $value);

0 commit comments

Comments
 (0)