From a00533afd58d77843c2033143e66fa772c14ef19 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 31 Aug 2020 13:01:45 +1200 Subject: [PATCH 1/2] WIP - add PHP 8 support. --- .travis.yml | 10 +++++++--- composer.json | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index efd73665..560d99e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,15 @@ language: php sudo: false -php: - - 7.4 +matrix: + include: + - php: 7.4 + - php: nightly + env: + - COMPOSER_ARG="--ignore-platform-reqs" before_install: - - composer install + - composer install $COMPOSER_ARG script: - composer test diff --git a/composer.json b/composer.json index dbdf950a..c3ee64d4 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "issues": "https://github.com/oscarotero/Embed/issues" }, "require": { - "php": "^7.4", + "php": "^7.4 || ^8", "ext-curl": "*", "ext-dom": "*", "ext-mbstring": "*", From c2c62b357d6e55a51ba6bd19755f051571ade862 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 31 Aug 2020 13:25:10 +1200 Subject: [PATCH 2/2] FIX: Rename match() to matchPattern() match is a reserved word in PHP8. This function appears to be an internal rather than public API so hopefully renaming it is okay. --- src/Adapters/Archive/Detectors/Code.php | 2 +- src/Adapters/CadenaSer/Detectors/Code.php | 2 +- src/Adapters/Flickr/Detectors/Code.php | 2 +- src/Adapters/Github/Detectors/Code.php | 2 +- src/Adapters/ImageShack/Api.php | 4 ++-- src/Adapters/Pinterest/Detectors/Code.php | 2 +- src/Adapters/Sassmeister/Detectors/Code.php | 2 +- src/Adapters/Snipplr/Detectors/Code.php | 2 +- src/Adapters/Wikipedia/Api.php | 2 +- src/Adapters/Youtube/Detectors/Feeds.php | 2 +- src/functions.php | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Adapters/Archive/Detectors/Code.php b/src/Adapters/Archive/Detectors/Code.php index c6afd83b..ad5f5da3 100644 --- a/src/Adapters/Archive/Detectors/Code.php +++ b/src/Adapters/Archive/Detectors/Code.php @@ -15,7 +15,7 @@ public function detect(): ?EmbedCode $uri = $this->extractor->getUri(); $path = $uri->getPath(); - if (!match('/details/*', $path)) { + if (!matchPattern('/details/*', $path)) { return null; } diff --git a/src/Adapters/CadenaSer/Detectors/Code.php b/src/Adapters/CadenaSer/Detectors/Code.php index 9bb8bd6a..2221c606 100644 --- a/src/Adapters/CadenaSer/Detectors/Code.php +++ b/src/Adapters/CadenaSer/Detectors/Code.php @@ -21,7 +21,7 @@ private function fallback(): ?EmbedCode { $uri = $this->extractor->getUri(); - if (!match('/audio/*', $uri->getPath())) { + if (!matchPattern('/audio/*', $uri->getPath())) { return null; } diff --git a/src/Adapters/Flickr/Detectors/Code.php b/src/Adapters/Flickr/Detectors/Code.php index 86c148e6..fb377a6e 100644 --- a/src/Adapters/Flickr/Detectors/Code.php +++ b/src/Adapters/Flickr/Detectors/Code.php @@ -21,7 +21,7 @@ private function fallback(): ?EmbedCode { $uri = $this->extractor->getUri(); - if (!match('/photos/*', $uri->getPath())) { + if (!matchPattern('/photos/*', $uri->getPath())) { return null; } diff --git a/src/Adapters/Github/Detectors/Code.php b/src/Adapters/Github/Detectors/Code.php index a579ace6..ffaf0e0c 100644 --- a/src/Adapters/Github/Detectors/Code.php +++ b/src/Adapters/Github/Detectors/Code.php @@ -21,7 +21,7 @@ private function fallback(): ?EmbedCode $uri = $this->extractor->getUri(); $path = $uri->getPath(); - if (!match('/*/*/blob/*', $path)) { + if (!matchPattern('/*/*/blob/*', $path)) { return null; } diff --git a/src/Adapters/ImageShack/Api.php b/src/Adapters/ImageShack/Api.php index 1a199f2f..305b7bf9 100644 --- a/src/Adapters/ImageShack/Api.php +++ b/src/Adapters/ImageShack/Api.php @@ -15,10 +15,10 @@ protected function fetchData(): array { $uri = $this->extractor->getUri(); - if (!match('/i/*', $uri->getPath())) { + if (!matchPattern('/i/*', $uri->getPath())) { $uri = $this->extractor->getRequest()->getUri(); - if (!match('/i/*', $uri->getPath())) { + if (!matchPattern('/i/*', $uri->getPath())) { return []; } } diff --git a/src/Adapters/Pinterest/Detectors/Code.php b/src/Adapters/Pinterest/Detectors/Code.php index a2b81071..2bcdd356 100644 --- a/src/Adapters/Pinterest/Detectors/Code.php +++ b/src/Adapters/Pinterest/Detectors/Code.php @@ -20,7 +20,7 @@ private function fallback(): ?EmbedCode { $uri = $this->extractor->getUri(); - if (!match('/pin/*', $uri->getPath())) { + if (!matchPattern('/pin/*', $uri->getPath())) { return null; } diff --git a/src/Adapters/Sassmeister/Detectors/Code.php b/src/Adapters/Sassmeister/Detectors/Code.php index 5236f927..c28586a1 100644 --- a/src/Adapters/Sassmeister/Detectors/Code.php +++ b/src/Adapters/Sassmeister/Detectors/Code.php @@ -20,7 +20,7 @@ private function fallback(): ?EmbedCode { $uri = $this->extractor->getUri(); - if (!match('/gist/*', $uri->getPath())) { + if (!matchPattern('/gist/*', $uri->getPath())) { return null; } diff --git a/src/Adapters/Snipplr/Detectors/Code.php b/src/Adapters/Snipplr/Detectors/Code.php index 4df3e89e..73ca6427 100644 --- a/src/Adapters/Snipplr/Detectors/Code.php +++ b/src/Adapters/Snipplr/Detectors/Code.php @@ -20,7 +20,7 @@ private function fallback(): ?EmbedCode { $uri = $this->extractor->getUri(); - if (!match('/view/*', $uri->getPath())) { + if (!matchPattern('/view/*', $uri->getPath())) { return null; } diff --git a/src/Adapters/Wikipedia/Api.php b/src/Adapters/Wikipedia/Api.php index 8f134bd1..cbfd4437 100644 --- a/src/Adapters/Wikipedia/Api.php +++ b/src/Adapters/Wikipedia/Api.php @@ -15,7 +15,7 @@ protected function fetchData(): array { $uri = $this->extractor->getUri(); - if (!match('/wiki/*', $uri->getPath())) { + if (!matchPattern('/wiki/*', $uri->getPath())) { return []; } diff --git a/src/Adapters/Youtube/Detectors/Feeds.php b/src/Adapters/Youtube/Detectors/Feeds.php index 91318664..2e173835 100644 --- a/src/Adapters/Youtube/Detectors/Feeds.php +++ b/src/Adapters/Youtube/Detectors/Feeds.php @@ -23,7 +23,7 @@ private function fallback(): array { $uri = $this->extractor->getUri(); - if (!match('/channel/*', $uri->getPath())) { + if (!matchPattern('/channel/*', $uri->getPath())) { return []; } diff --git a/src/functions.php b/src/functions.php index 35aebfa2..94aec684 100644 --- a/src/functions.php +++ b/src/functions.php @@ -116,7 +116,7 @@ function cleanPath(string $path): string return $path; } -function match(string $pattern, string $subject): bool +function matchPattern(string $pattern, string $subject): bool { $pattern = str_replace('\\*', '.*', preg_quote($pattern, '|'));