diff --git a/.editorconfig b/.editorconfig index 1492202b..56f3b6bf 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,3 @@ trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false - -[*.yml] -indent_style = space -indent_size = 2 diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml new file mode 100644 index 00000000..c34731af --- /dev/null +++ b/.github/workflows/qa.yml @@ -0,0 +1,72 @@ +## +# @link https://github.com/shivammathur/setup-php +## + +name: 'Quality assurance' + +'on': + push: + branches: + - '3.x' + - '3.x-*' + pull_request: + branches: + - '3.x' + +jobs: + run: + strategy: + matrix: + operating-system: + - 'ubuntu-latest' + #- 'windows-latest' + #- 'macOS-latest' + php-versions: + - '5.4' + - '5.5' + - '5.6' + - '7.0' + - '7.1' + - '7.2' + - '7.3' + - '7.4' + - '8.0' + - '8.1' + name: 'PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}' + runs-on: '${{ matrix.operating-system }}' + env: + COMPOSER_NO_INTERACTION: '1' + COMPOSER_MEMORY_LIMIT: '-1' + COMPOSER_DISABLE_XDEBUG_WARN: '1' + COMPOSER_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + steps: + - + name: 'Checkout' + uses: 'actions/checkout@v2' + - + name: 'Install PHP' + uses: 'shivammathur/setup-php@v2' + with: + php-version: '${{ matrix.php-versions }}' + extensions: 'intl, mbstring' + env: + COMPOSER_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + - + name: 'Check tools' + run: | + git --version + php -v + php -m + composer --version + - + name: 'composer install' + run: | + composer update + - + name: 'Lint - composer' + run: | + composer validate + - + name: 'Test' + run: | + "$(composer config bin-dir)/phpunit" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3843bdd6..00000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -language: php - -php: - - hhvm - -# This triggers builds to run on the new TravisCI infrastructure. -# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ -sudo: false - -matrix: - fast_finish: true - include: - - php: 5.4 - env: polyfill='true' - - php: 5.4 - env: polyfill='false' - - php: 5.5 - env: polyfill='true' - - php: 5.5 - env: polyfill='false' - - php: 5.6 - env: polyfill='true' - - php: 5.6 - env: polyfill='false' - - php: 7.0 - env: polyfill='true' - - php: 7.0 - env: polyfill='false' - - php: 7.1 - env: polyfill='true' - - php: 7.1 - env: polyfill='false' - -install: travis_retry composer install --no-interaction --prefer-source - -before_script: - - travis_retry composer self-update - - travis_retry composer install --no-interaction --prefer-source - - if [[ $polyfill = 'false' ]]; then travis_retry composer remove symfony/polyfill-mbstring; fi - -script: - - vendor/bin/phpunit - diff --git a/composer.json b/composer.json index 092989f4..a44a3241 100644 --- a/composer.json +++ b/composer.json @@ -14,12 +14,25 @@ "homepage": "http://www.danielstjules.com" } ], + "repositories": { + "phpunit/phpunit": { + "type": "github", + "url": "https://github.com/Sweetchuck/phpunit.git", + "branch": "4.x-php8" + }, + "phpunit/php-file-iterator": { + "type": "github", + "url": "https://github.com/Sweetchuck/php-file-iterator.git", + "branch": "1.4-php8" + } + }, "require": { "php": ">=5.4.0", "symfony/polyfill-mbstring": "~1.1" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "dev-4.x-php8#f7f5b1d9a8c733b2ba8e665b2e8a0f04e208ed9d", + "phpunit/php-file-iterator": "dev-1.4-php8#0bf836b26a9789e7cd634c43dc468428c8fa77d6 as 1.4.5" }, "support": { "issues": "https://github.com/danielstjules/Stringy/issues", diff --git a/src/Stringy.php b/src/Stringy.php index ccb6f5aa..0efc685d 100644 --- a/src/Stringy.php +++ b/src/Stringy.php @@ -267,6 +267,7 @@ public function containsAny($needles, $caseSensitive = true) * * @return int The number of characters in the string, given the encoding */ + #[\ReturnTypeWillChange] public function count() { return $this->length(); @@ -450,6 +451,7 @@ public function getEncoding() * * @return \ArrayIterator An iterator for the characters in the string */ + #[\ReturnTypeWillChange] public function getIterator() { return new ArrayIterator($this->chars()); @@ -716,7 +718,7 @@ public function length() */ public function lines() { - $array = $this->split('[\r\n]{1,2}', $this->str); + $array = $this->split('[\r\n]{1,2}'); for ($i = 0; $i < count($array); $i++) { $array[$i] = static::create($array[$i], $this->encoding); } @@ -847,6 +849,7 @@ public function lowerCaseFirst() * @param mixed $offset The index to check * @return boolean Whether or not the index exists */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { $length = $this->length(); @@ -870,6 +873,7 @@ public function offsetExists($offset) * @throws \OutOfBoundsException If the positive or negative offset does * not exist */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { $offset = (int) $offset; @@ -890,6 +894,7 @@ public function offsetGet($offset) * @param mixed $value Value to set * @throws \Exception When called */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { // Stringy is immutable, cannot directly set char @@ -903,6 +908,7 @@ public function offsetSet($offset, $value) * @param mixed $offset The index of the character * @throws \Exception When called */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { // Don't allow directly modifying the string @@ -1170,7 +1176,7 @@ public function slugify($replacement = '-', $language = 'en') $stringy->str = str_replace('@', $replacement, $stringy); $quotedReplacement = preg_quote($replacement); - $pattern = "/[^a-zA-Z\d\s-_$quotedReplacement]/u"; + $pattern = "/[^a-zA-Z\d\s\-_$quotedReplacement]/u"; $stringy->str = preg_replace($pattern, '', $stringy); return $stringy->toLowerCase()->delimit($replacement) @@ -1277,7 +1283,7 @@ public function split($pattern, $limit = null) // mb_split returns the remaining unsplit string in the last index when // supplying a limit - $limit = ($limit > 0) ? $limit += 1 : -1; + $limit = ($limit > 0) ? $limit + 1 : -1; static $functionExists; if ($functionExists === null) {