Skip to content

Commit 0fb0629

Browse files
authored
Merge pull request #49 from nojimage/support-php84
Support PHP 8.4
2 parents 3f2e31f + 73c34a6 commit 0fb0629

File tree

9 files changed

+64
-71
lines changed

9 files changed

+64
-71
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,27 @@ on:
1010
- '*'
1111
schedule:
1212
- cron: "0 7 1 * *"
13-
branches:
14-
- master
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
1517

1618
jobs:
1719
testsuite:
18-
runs-on: ubuntu-20.04
20+
runs-on: ubuntu-24.04
1921
strategy:
2022
fail-fast: false
2123
matrix:
22-
php-version: ['7.4', '8.0', '8.1', '8.2']
23-
coverage: ['no']
24-
test-tld: ['no']
24+
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
2525
include:
26-
- php-version: '8.2'
27-
coverage: 'coverage'
28-
test-tld: 'no'
29-
- php-version: '8.2'
30-
coverage: 'no'
31-
test-tld: 'test-tld'
26+
- php-version: '8.4'
27+
coverage: true
28+
- php-version: '8.4'
29+
test-tld: true
3230

3331
steps:
3432
- name: Checkout
35-
uses: actions/checkout@v2
33+
uses: actions/checkout@v5
3634

3735
- name: Setup PHP
3836
uses: shivammathur/setup-php@v2
@@ -43,47 +41,46 @@ jobs:
4341

4442
- name: Get composer cache directory
4543
id: composer-cache
46-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
44+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
4745

4846
- name: Cache dependencies
49-
uses: actions/cache@v2
47+
uses: actions/cache@v4
5048
with:
5149
path: ${{ steps.composer-cache.outputs.dir }}
5250
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
5351
restore-keys: ${{ runner.os }}-composer-
5452

5553
- name: Install dependencies
56-
run: composer install --prefer-dist
57-
58-
- name: Setup problem matchers for PHPUnit
59-
if: matrix.php-version == '8.1' || matrix.php-version == '8.2'
60-
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
54+
run: composer install --prefer-dist --no-progress
6155

6256
- name: Run PHPUnit
6357
run: |
64-
if [[ ${{ matrix.coverage }} == 'coverage' ]]; then
58+
if [[ "${{ matrix.coverage }}" == "true" ]]; then
6559
vendor/bin/phpunit --exclude-group deprecated,tld --stderr --verbose --coverage-clover=coverage.xml
66-
elif [[ ${{ matrix.test-tld }} == 'test-tld' ]]; then
60+
elif [[ "${{ matrix.test-tld }}" == "true" ]]; then
6761
vendor/bin/phpunit --group tld --stderr
6862
else
6963
vendor/bin/phpunit --exclude-group deprecated,tld --stderr
7064
fi
7165
7266
- name: Submit code coverage
73-
if: matrix.coverage == 'coverage'
74-
uses: codecov/codecov-action@v1
67+
if: matrix.coverage
68+
uses: codecov/codecov-action@v5
69+
with:
70+
files: coverage.xml
71+
fail_ci_if_error: false
7572

7673
codestyle:
77-
runs-on: ubuntu-20.04
74+
runs-on: ubuntu-24.04
7875

7976
steps:
80-
- uses: actions/checkout@v2
77+
- uses: actions/checkout@v5
8178

8279
- name: Setup PHP
8380
uses: shivammathur/setup-php@v2
8481
with:
85-
php-version: '8.2'
86-
extensions: mbstring, intl, apcu
82+
php-version: '8.4'
83+
extensions: mbstring, intl
8784
coverage: none
8885
tools: cs2pr, phpcs
8986

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
},
4848
"require-dev": {
4949
"ext-json": "*",
50-
"symfony/yaml": "^5.0.0",
50+
"symfony/yaml": "^5.0|^6.0|^7.0",
5151
"phpunit/phpunit": "^9.5",
52-
"twitter/twitter-text": "^3.0.0"
52+
"twitter/twitter-text": "^3.1.0"
5353
},
5454
"autoload": {
5555
"psr-0": {

lib/Twitter/Text/Autolink.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class Autolink
162162
*
163163
* @see __construct()
164164
*
165-
* @return Autolink
165+
* @return static
166166
*/
167167
public static function create($tweet = null, $full_encode = false)
168168
{
@@ -177,9 +177,9 @@ public static function create($tweet = null, $full_encode = false)
177177
*
178178
* @see htmlspecialchars()
179179
*
180-
* @param string $tweet [deprecated] The tweet to be converted.
181-
* @param bool $escape [deprecated] Whether to escape the tweet (default: true).
182-
* @param bool $full_encode [deprecated] Whether to encode all special characters.
180+
* @param string|null $tweet [deprecated] The tweet to be converted.
181+
* @param bool $escape [deprecated] Whether to escape the tweet (default: true).
182+
* @param bool $full_encode [deprecated] Whether to encode all special characters.
183183
*/
184184
public function __construct($tweet = null, $escape = true, $full_encode = false)
185185
{

lib/Twitter/Text/Configuration.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ class Configuration
120120
/**
121121
* construct
122122
*
123-
* @param array $config
123+
* @param array|null $config
124124
*/
125-
public function __construct(array $config = null)
125+
public function __construct(?array $config = null)
126126
{
127127
if ($config === null) {
128128
$config = static::$v3Config;
@@ -156,17 +156,17 @@ public function toArray()
156156
* Create configuration from json string
157157
*
158158
* @param string $json as configuration
159-
* @return Configuration
159+
* @return self
160160
*/
161161
public static function fromJson($json)
162162
{
163-
return new Configuration(json_decode($json, true));
163+
return new self(json_decode($json, true));
164164
}
165165

166166
/**
167167
* Get twitter-text 1.x configuration
168168
*
169-
* @return Configuration
169+
* @return self
170170
*/
171171
public static function v1()
172172
{
@@ -176,7 +176,7 @@ public static function v1()
176176
/**
177177
* Get twitter-text 2.x configuration
178178
*
179-
* @return Configuration
179+
* @return self
180180
*/
181181
public static function v2()
182182
{

lib/Twitter/Text/Extractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Extractor
6161
*
6262
* @see __construct()
6363
*
64-
* @return Extractor
64+
* @return self
6565
*/
6666
public static function create()
6767
{

lib/Twitter/Text/HitHighlighter.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class HitHighlighter
4949
*
5050
* @see __construct()
5151
*
52-
* @return HitHighlighter
52+
* @return self
5353
*/
5454
public static function create($tweet = null, $full_encode = false)
5555
{
@@ -63,9 +63,9 @@ public static function create($tweet = null, $full_encode = false)
6363
*
6464
* @see htmlspecialchars()
6565
*
66-
* @param string $tweet [deprecated] The tweet to be hit highlighted.
67-
* @param bool $escape [deprecated] Whether to escape the tweet (default: true).
68-
* @param bool $full_encode [deprecated] Whether to encode all special characters.
66+
* @param string|null $tweet [deprecated] The tweet to be hit highlighted.
67+
* @param bool $escape [deprecated] Whether to escape the tweet (default: true).
68+
* @param bool $full_encode [deprecated] Whether to encode all special characters.
6969
*/
7070
public function __construct($tweet = null, $escape = true, $full_encode = false)
7171
{
@@ -106,13 +106,11 @@ public function setTag($v)
106106
/**
107107
* Hit highlights the tweet.
108108
*
109-
* @param string $tweet The tweet to be hit highlighted.
110-
* @param array $hits An array containing the start and end index pairs
111-
* for the highlighting.
112-
*
113-
* @return string The hit highlighted tweet.
109+
* @param string|null $tweet The tweet to be hit highlighted.
110+
* @param array|null $hits An array containing the start and end index pairs for the highlighting.
111+
* @return string The hit highlighted tweet.
114112
*/
115-
public function highlight($tweet = null, array $hits = null)
113+
public function highlight($tweet = null, ?array $hits = null)
116114
{
117115
if ($tweet === null) {
118116
$tweet = $this->tweet;

lib/Twitter/Text/Parser.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ class Parser
2727
/**
2828
* Create a Parser
2929
*
30-
* @param Configuration $config
31-
* @return Parser
30+
* @param Configuration|null $config
31+
* @return self
3232
*/
33-
public static function create(Configuration $config = null)
33+
public static function create(?Configuration $config = null)
3434
{
3535
return new self($config);
3636
}
3737

3838
/**
3939
* construct
4040
*
41-
* @param Configuration $config
41+
* @param Configuration|null $config
4242
*/
43-
public function __construct(Configuration $config = null)
43+
public function __construct(?Configuration $config = null)
4444
{
4545
if ($config === null) {
4646
$config = new Configuration();

lib/Twitter/Text/Validator.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,21 @@ class Validator
4040
/**
4141
* Provides fluent method chaining.
4242
*
43-
* @param Configuration $config A Twitter Text Configuration
44-
*
43+
* @param Configuration|null $config A Twitter Text Configuration
44+
* @return self
4545
* @see __construct()
46-
*
47-
* @return Validator
4846
*/
49-
public static function create(Configuration $config = null)
47+
public static function create(?Configuration $config = null)
5048
{
5149
return new self($config);
5250
}
5351

5452
/**
5553
* Reads in a tweet to be parsed and validates it.
5654
*
57-
* @param Configuration $config A Twitter Text Configuration
55+
* @param Configuration|null $config A Twitter Text Configuration
5856
*/
59-
public function __construct(Configuration $config = null)
57+
public function __construct(?Configuration $config = null)
6058
{
6159
$this->setConfiguration($config);
6260
$this->extractor = Extractor::create();
@@ -71,7 +69,7 @@ public function __construct(Configuration $config = null)
7169
* @return Validator
7270
* @throws \InvalidArgumentException
7371
*/
74-
public function setConfiguration(Configuration $config = null)
72+
public function setConfiguration(?Configuration $config = null)
7573
{
7674
if ($config === null) {
7775
// default use v2 config
@@ -98,12 +96,12 @@ public function getConfiguration()
9896
/**
9997
* Check whether a tweet is valid.
10098
*
101-
* @param string $tweet The tweet to validate.
102-
* @param Configuration $config using configuration
99+
* @param string $tweet The tweet to validate.
100+
* @param Configuration|null $config using configuration
103101
* @return boolean Whether the tweet is valid.
104102
* @deprecated instead use \Twitter\Text\Parser::parseText()
105103
*/
106-
public function isValidTweetText($tweet, Configuration $config = null)
104+
public function isValidTweetText($tweet, ?Configuration $config = null)
107105
{
108106

109107
return $this->parseTweet($tweet, $config)->valid;
@@ -212,11 +210,11 @@ public function isValidURL($url, $unicode_domains = true, $require_protocol = tr
212210
* Determines the length of a tweet. Takes shortening of URLs into account.
213211
*
214212
* @param string $tweet The tweet to validate.
215-
* @param Configuration $config using configuration
213+
* @param Configuration|null $config using configuration
216214
* @return int the length of a tweet.
217215
* @deprecated instead use \Twitter\Text\Parser::parseTweet()
218216
*/
219-
public function getTweetLength($tweet, Configuration $config = null)
217+
public function getTweetLength($tweet, ?Configuration $config = null)
220218
{
221219
return $this->parseTweet($tweet, $config)->weightedLength;
222220
}
@@ -247,7 +245,7 @@ protected static function isValidMatch($string, $pattern, $optional = false)
247245
* @param Configuration|null $config using configuration
248246
* @return ParseResults
249247
*/
250-
private function parseTweet($tweet, Configuration $config = null)
248+
private function parseTweet($tweet, ?Configuration $config = null)
251249
{
252250
if ($config === null) {
253251
$config = $this->config;

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
# Set up error reporting:
4-
error_reporting(E_ALL | E_STRICT | E_DEPRECATED);
4+
error_reporting(E_ALL | E_DEPRECATED);
55

66
# Set default timezone to hide warnings:
77
date_default_timezone_set('Europe/London');

0 commit comments

Comments
 (0)