Skip to content

Commit

Permalink
Merge pull request #24 from ArthurHoaro/php8-with-ci
Browse files Browse the repository at this point in the history
Support PHP 8.0 and restore CI with Github Actions
  • Loading branch information
ArthurHoaro authored Oct 22, 2023
2 parents b5e4a52 + 51afe7c commit d62a170
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 56 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PHP CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run PHPCS
run: composer run-script cs

- name: Run test suite
run: composer run-script test
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.2.1
v2.0.0
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,23 @@
"sources": "https://github.com/ArthurHoaro/favicon"
},
"require": {
"php": ">=5.6",
"php": "^8.0",
"ext-dom": "*",
"ext-fileinfo": "*"
},
"require-dev": {
"phpunit/phpunit": "~4.8",
"phpunit/phpunit": "^10.0",
"weew/helpers-filesystem": "~1.0",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
"psr-4": {
"Favicon\\": "src/Favicon/"
}
},
"scripts": {
"test": "phpunit tests",
"cs": "phpcs",
"csfix": "phpcbf"
}
}
7 changes: 3 additions & 4 deletions src/Favicon/Favicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function info($url)
$loop = true;
while ($loop && $max_loop-- > 0) {
$headers = $this->dataAccess->retrieveHeader($url);
if (empty($headers) || !array_key_exists(0, $headers)) {
if (empty($headers) || !is_array($headers) || !array_key_exists(0, $headers)) {
return false;
}
$exploded = explode(' ', $headers[0]);
Expand Down Expand Up @@ -152,7 +152,6 @@ public function get($url = '', $type = FaviconDLType::HOTLINK_URL)
$this->url = $url;
}

// Get the base URL without the path for clearer concatenations.
$url = rtrim($this->baseUrl($this->url, true), '/');
$original = $url;

Expand Down Expand Up @@ -214,7 +213,7 @@ private function getFavicon($url, $checkDefault = true)
// Make sure the favicon is an absolute URL.
if ($favicon && filter_var($favicon, FILTER_VALIDATE_URL) === false) {
// Make sure that favicons starting with "/" get concatenated with host instead of full URL
if($favicon[0] === '/') {
if ($favicon[0] === '/') {
$favicon = $this->baseUrl($url) . ltrim($favicon, '/');
} else {
$favicon = rtrim($url, '/') . '/' . ltrim($favicon, '/');
Expand Down Expand Up @@ -408,7 +407,7 @@ public function setUrl($url)
}

/**
* @param DataAccess|\PHPUnit_Framework_MockObject_MockObject $dataAccess
* @param DataAccess $dataAccess
*/
public function setDataAccess($dataAccess)
{
Expand Down
Loading

0 comments on commit d62a170

Please sign in to comment.