Skip to content

3.x - issue #209 php801 compatibility #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -10,7 +10,3 @@ trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_style = space
indent_size = 2
72 changes: 72 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -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"
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

15 changes: 14 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
12 changes: 9 additions & 3 deletions src/Stringy.php
Original file line number Diff line number Diff line change
@@ -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) {