From 2417f4ab35c942e959a49ed3023b451eb4ed62f1 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 4 Nov 2022 02:52:02 +0100 Subject: [PATCH] composer: Remove Stringy It is abandoned and incompatible with PHP 8.1: Return type of Stringy\Stringy::count() should either be compatible with Countable::count(): int --- composer.json | 2 +- composer.lock | 62 +---------------------------------- src/helpers/View.php | 3 +- src/spouts/reddit/reddit2.php | 4 +-- 4 files changed, 5 insertions(+), 66 deletions(-) diff --git a/composer.json b/composer.json index 8b1bc8ad82..90f0ea7057 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,6 @@ "ext-gd": "*", "bcosca/fatfree-core": "^3.8", "bramus/router": "^1.6", - "danielstjules/stringy": "^3.1", "fossar/guzzle-transcoder": "^0.2.0", "fossar/htmlawed": "^1.2.4.1", "guzzlehttp/guzzle": "^7.0", @@ -22,6 +21,7 @@ "php-http/guzzle7-adapter": "^1.0", "simplepie/simplepie": "^1.6", "smottt/wideimage": "^1.1", + "symfony/polyfill-php80": "^1.26", "violet/streaming-json-encoder": "^1.1", "willwashburn/phpamo": "^1.0" }, diff --git a/composer.lock b/composer.lock index 829a2e6662..524b9b99b3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d40c27cb00f556fbc09cda8b97c3b839", + "content-hash": "addac21b8ab587c0685f3285c3b2b2ed", "packages": [ { "name": "bcosca/fatfree-core", @@ -158,66 +158,6 @@ ], "time": "2022-02-21T13:15:14+00:00" }, - { - "name": "danielstjules/stringy", - "version": "3.1.0", - "source": { - "type": "git", - "url": "https://github.com/danielstjules/Stringy.git", - "reference": "df24ab62d2d8213bbbe88cc36fc35a4503b4bd7e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/danielstjules/Stringy/zipball/df24ab62d2d8213bbbe88cc36fc35a4503b4bd7e", - "reference": "df24ab62d2d8213bbbe88cc36fc35a4503b4bd7e", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "symfony/polyfill-mbstring": "~1.1" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "autoload": { - "files": [ - "src/Create.php" - ], - "psr-4": { - "Stringy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Daniel St. Jules", - "email": "danielst.jules@gmail.com", - "homepage": "http://www.danielstjules.com" - } - ], - "description": "A string manipulation library with multibyte support", - "homepage": "https://github.com/danielstjules/Stringy", - "keywords": [ - "UTF", - "helpers", - "manipulation", - "methods", - "multibyte", - "string", - "utf-8", - "utility", - "utils" - ], - "support": { - "issues": "https://github.com/danielstjules/Stringy/issues", - "source": "https://github.com/danielstjules/Stringy" - }, - "time": "2017-06-12T01:10:27+00:00" - }, { "name": "fossar/guzzle-transcoder", "version": "0.2.3", diff --git a/src/helpers/View.php b/src/helpers/View.php index 23523e9a85..cc43b49a0f 100644 --- a/src/helpers/View.php +++ b/src/helpers/View.php @@ -4,7 +4,6 @@ use function Http\Response\send; use Psr\Http\Message\ResponseInterface; -use Stringy\Stringy as S; /** * Helper class for rendering template @@ -39,7 +38,7 @@ public function getBaseUrl() { // base url in config.ini file $base = $this->configuration->baseUrl; if ($base !== '') { - $base = (string) S::create($base)->ensureRight('/'); + $base = str_ends_with($base, '/') ? $base : ($base . '/'); } else { // auto generate base url $protocol = 'http'; if ((isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || diff --git a/src/spouts/reddit/reddit2.php b/src/spouts/reddit/reddit2.php index d1df4378dc..559f3403a6 100644 --- a/src/spouts/reddit/reddit2.php +++ b/src/spouts/reddit/reddit2.php @@ -10,7 +10,6 @@ use helpers\WebClient; use Psr\Http\Message\ResponseInterface; use spouts\Item; -use Stringy\Stringy as S; /** * Spout for fetching from reddit @@ -87,7 +86,8 @@ public function load(array $params) { $url = UriResolver::resolve(new Uri('https://www.reddit.com/'), new Uri($params['url'])); $this->htmlUrl = (string) $url; // and that the path ends with .json (Reddit does not seem to recogize Accept header) - $url = $url->withPath((string) S::create($url->getPath())->ensureRight('.json')); + $path = $url->getPath(); + $url = $url->withPath(str_ends_with($path, '.json') ? $path : ($path . '.json')); $response = $this->sendRequest((string) $url); $json = json_decode((string) $response->getBody(), true);