Skip to content

Commit

Permalink
Makes verbal expressions compatible with older versions
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Idrinth authored and mihai-vlc committed Dec 21, 2017
1 parent b8c2577 commit 708cfdd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# General Ignores
/vendor
composer.lock
/phpunit/
# IDEs
.idea/
/nbproject/
20 changes: 18 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
language: php
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- hhvm
- nightly
matrix:
include:
- php: "5.3"
dist: precise
git:
#there should rarely be a need to clone 50 deep, so this is just reducing build-time
depth: 5
before_script:
# no need to provide coverage more than once and no need for the speedbump otherwise
- if [[ ${TRAVIS_PHP_VERSION:0:3} != "7.1" ]]; then phpenv config-rm xdebug.ini || true ; fi
# no need to test formatting more than once and php_codesniffer does not work with older php
- if [[ ${TRAVIS_PHP_VERSION:0:3} != "5.6" ]]; then composer remove --dev squizlabs/php_codesniffer ; fi
- composer install
script:
- composer check-style
- composer test
# since it's disabled otherwise...
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.6" ]]; then composer check-style ; fi
- composer test
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "project",
"description": "PHP Regular expressions made easy",
"require": {
"php": ">=5.6"
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "* >=4",
Expand Down
7 changes: 4 additions & 3 deletions src/VerbalExpressions.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,9 @@ public function any($value)
* @return VerbalExpressions
* @throws \InvalidArgumentException
*/
public function range(... $args)
public function range()
{
$args = func_get_args();
$arg_num = count($args);

if ($arg_num%2 != 0) {
Expand Down Expand Up @@ -483,8 +484,8 @@ public function test($value)
// php doesn't have g modifier so we remove it if it's there and call preg_match_all()
if (strpos($this->modifiers, 'g') !== false) {
$this->modifiers = str_replace('g', '', $this->modifiers);

return preg_match_all($this->getRegex(), $value);
$matches = array();//because it's not optional in <5.4
return preg_match_all($this->getRegex(), $value, $matches);
}

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

0 comments on commit 708cfdd

Please sign in to comment.