Skip to content
Closed
Show file tree
Hide file tree
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
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
push:
pull_request:

jobs:
test:
name: "PHPUnit: PHP ${{ matrix.php }}"

strategy:
matrix:
include:
- php: '8.0'
- php: '8.1'

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer

- name: Install dependencies
run: composer install

- name: Run tests
run: composer phpunit
27 changes: 0 additions & 27 deletions .scrutinizer.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Http request

[![Build Status](https://secure.travis-ci.org/onoi/http-request.svg?branch=master)](http://travis-ci.org/onoi/http-request)
[![Code Coverage](https://scrutinizer-ci.com/g/onoi/http-request/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/onoi/http-request/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/onoi/http-request/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/onoi/http-request/?branch=master)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/onoi/http-request/CI)](https://github.com/onoi/http-request/actions?query=workflow%3ACI)
[![Latest Stable Version](https://poser.pugx.org/onoi/http-request/version.png)](https://packagist.org/packages/onoi/http-request)
[![Packagist download count](https://poser.pugx.org/onoi/http-request/d/total.png)](https://packagist.org/packages/onoi/http-request)
[![Dependency Status](https://www.versioneye.com/php/onoi:http-request/badge.png)](https://www.versioneye.com/php/onoi:http-request)
Expand All @@ -20,7 +18,7 @@ This library provides:

## Requirements

- PHP 5.3 or later
- PHP 8.0 or later

## Installation

Expand All @@ -30,7 +28,7 @@ dependency to your [composer.json][composer].
```json
{
"require": {
"onoi/http-request": "~1.3"
"onoi/http-request": "~2.0"
}
}
```
Expand Down Expand Up @@ -114,6 +112,9 @@ The library provides unit tests that covers the core-functionality normally run

## Release notes

* 2.0.0 (Under development)
- Increased minimum PHP requirement to 8.0

* 1.3.1 (2016-01-14)
- Extended `SocketRequest` to match a possible TLS port

Expand Down
13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
}
],
"require": {
"php": ">=5.3.2",
"php": ">=8.0",
"onoi/cache": "~1.2"
},
"suggest": {
"lib-curl": "Allows making CURL requests"
"lib-curl": "Allows making CURL requests"
},
"extra": {
"branch-alias": {
Expand All @@ -31,10 +31,19 @@
"Onoi\\HttpRequest\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Onoi\\HttpRequest\\Tests\\": "tests/phpunit/Unit",
"Onoi\\HttpRequest\\Tests\\Integration\\": "tests/phpunit/Integration"
}
},
"config": {
"process-timeout": 0
},
"scripts":{
"phpunit": "phpunit -c phpunit.xml.dist"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
}
}
25 changes: 13 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<phpunit backupGlobals="false"
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
cacheTokens="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand All @@ -10,7 +10,13 @@
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="true">
verbose="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="onoi-http-request-unit">
<directory>tests/phpunit/Unit</directory>
Expand All @@ -19,14 +25,9 @@
<directory>tests/phpunit/Integration</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<php>
<const name="WEB_SERVER_HOST" value="localhost" />
<const name="WEB_SERVER_PORT" value="13499" />
<const name="WEB_SERVER_DOCROOT" value="/http-public" />
<const name="WEB_SERVER_HOST" value="localhost"/>
<const name="WEB_SERVER_PORT" value="13499"/>
<const name="WEB_SERVER_DOCROOT" value="/http-public"/>
</php>
</phpunit>
6 changes: 2 additions & 4 deletions src/CachedCurlRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Onoi\HttpRequest;

use CurlHandle;
use Onoi\Cache\Cache;

/**
Expand Down Expand Up @@ -32,11 +33,8 @@ class CachedCurlRequest extends CurlRequest {

/**
* @since 1.0
*
* @param resource $handle
* @param Cache $cache
*/
public function __construct( $handle, Cache $cache ) {
public function __construct( CurlHandle|false $handle, Cache $cache ) {
parent::__construct( $handle );

$this->cache = $cache;
Expand Down
12 changes: 4 additions & 8 deletions src/CurlRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Onoi\HttpRequest;

use CurlHandle;
use InvalidArgumentException;

/**
Expand All @@ -12,10 +13,7 @@
*/
class CurlRequest implements HttpRequest {

/**
* @var resource
*/
private $handle;
private CurlHandle $handle;

/**
* @var array
Expand All @@ -24,12 +22,10 @@ class CurlRequest implements HttpRequest {

/**
* @since 1.0
*
* @param resource $handle
*/
public function __construct( $handle ) {
public function __construct( CurlHandle|false $handle ) {

if ( get_resource_type( $handle ) !== 'curl' ) {
if ( $handle === false ) {
throw new InvalidArgumentException( "Expected a cURL resource type" );
}

Expand Down
16 changes: 6 additions & 10 deletions src/MultiCurlRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

namespace Onoi\HttpRequest;

use InvalidArgumentException;
use Closure;
use CurlMultiHandle;
use InvalidArgumentException;

/**
* @license GNU GPL v2+
Expand All @@ -13,10 +14,7 @@
*/
class MultiCurlRequest implements HttpRequest {

/**
* @var resource
*/
private $handle;
private CurlMultiHandle $handle;

/**
* @var array
Expand All @@ -35,13 +33,11 @@ class MultiCurlRequest implements HttpRequest {

/**
* @since 1.0
*
* @param resource $handle
*/
public function __construct( $handle ) {
public function __construct( CurlMultiHandle|false $handle ) {

if ( get_resource_type( $handle ) !== 'curl_multi' ) {
throw new InvalidArgumentException( "Expected a cURL multi resource type" );
if ( $handle === false ) {
throw new InvalidArgumentException( "Expected a cURL resource type" );
}

$this->handle = $handle;
Expand Down
27 changes: 0 additions & 27 deletions tests/bootstrap.php

This file was deleted.

5 changes: 2 additions & 3 deletions tests/phpunit/Integration/RequestToExternalUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @author mwjames
*/
class RequestToExternalUrlTest extends \PHPUnit_Framework_TestCase {
class RequestToExternalUrlTest extends \PHPUnit\Framework\TestCase {

public function testCachedRequestToExternalUrl() {

Expand All @@ -35,8 +35,7 @@ public function testCachedRequestToExternalUrl() {
$instance->setOption( ONOI_HTTP_REQUEST_RESPONSECACHE_TTL, 42 );
$instance->setOption( ONOI_HTTP_REQUEST_RESPONSECACHE_PREFIX, 'foo' );

$this->assertInternalType(
'string',
$this->assertIsString(
$instance->execute()
);

Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/Integration/RequestToPhpHttpdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @author mwjames
*/
class RequestToPhpHttpdTest extends \PHPUnit_Framework_TestCase {
class RequestToPhpHttpdTest extends \PHPUnit\Framework\TestCase {

private static $pid;

Expand All @@ -25,7 +25,7 @@ class RequestToPhpHttpdTest extends \PHPUnit_Framework_TestCase {
* Options defined in phpunit.xml.dist
* @see https://github.com/vgno/tech.vg.no-1812/blob/master/features/bootstrap/FeatureContext.php
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {

$command = sprintf( 'php -S %s:%d -t %s >/dev/null 2>&1 & echo $!',
WEB_SERVER_HOST,
Expand All @@ -39,7 +39,7 @@ public static function setUpBeforeClass() {
self::$pid = (int) $output[0];
}

public static function tearDownAfterClass() {
public static function tearDownAfterClass(): void {
// exec( 'kill ' . (int) self::$pid );
}

Expand Down
Loading