Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sunrise-php/stream
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.9
Choose a base ref
...
head repository: sunrise-php/stream
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
64 changes: 64 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2
jobs:
php71:
docker:
- image: cimg/php:7.1
steps:
- checkout
- run: php -v
- run: composer install --no-interaction
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php72:
docker:
- image: cimg/php:7.2
steps:
- checkout
- run: php -v
- run: composer install --no-interaction
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php73:
docker:
- image: cimg/php:7.3
steps:
- checkout
- run: php -v
- run: composer install --no-interaction
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php74:
docker:
- image: cimg/php:7.4
steps:
- checkout
- run: php -v
- run: composer install --no-interaction
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php80:
docker:
- image: cimg/php:8.0
steps:
- checkout
- run: php -v
- run: composer install --no-interaction
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
php81:
docker:
- image: cimg/php:8.1
steps:
- checkout
- run: php -v
- run: composer install --no-interaction
- run: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-text
workflows:
version: 2
build:
jobs:
- php71
- php72
- php73
- php74
- php80
- php81
10 changes: 8 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# More info at:
# https://editorconfig.org/

root = true

[*.php]
[*]
charset = utf-8
end_of_line = lf
indent_style = tab
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_size = 2
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
vendor/
composer.lock
/.php_cs.cache
/.phpunit.result.cache
/composer.lock
/coverage.xml
/phpbench.json
/phpcs.xml
/phpunit.xml
/psalm.xml
/vendor/
16 changes: 16 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
build:
environment:
php:
version: '8.0'
nodes:
analysis:
tests:
override:
- php-scrutinizer-run
coverage:
tests:
override:
- command: XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-clover coverage.xml
coverage:
file: coverage.xml
format: clover
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Anatoly Fenric
Copyright (c) 2018 Anatoly Nekhay

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
61 changes: 1 addition & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1 @@
# Stream wrapper for PHP 7.2+ based on PSR-7 & PSR-17

[![Build Status](https://api.travis-ci.com/sunrise-php/stream.svg?branch=master)](https://travis-ci.com/sunrise-php/stream)
[![CodeFactor](https://www.codefactor.io/repository/github/sunrise-php/stream/badge)](https://www.codefactor.io/repository/github/sunrise-php/stream)
[![Latest Stable Version](https://poser.pugx.org/sunrise/stream/v/stable)](https://packagist.org/packages/sunrise/stream)
[![Total Downloads](https://poser.pugx.org/sunrise/stream/downloads)](https://packagist.org/packages/sunrise/stream)
[![License](https://poser.pugx.org/sunrise/stream/license)](https://packagist.org/packages/sunrise/stream)

## Awards

[![SymfonyInsight](https://insight.symfony.com/projects/a6301a76-9b35-49a3-adb1-ebbf59f810f2/big.svg)](https://insight.symfony.com/projects/a6301a76-9b35-49a3-adb1-ebbf59f810f2)

## Installation

```
composer require sunrise/stream
```

## How to use?

```php
use Sunrise\Stream\Stream;
use Sunrise\Stream\StreamFactory;

// creates a new stream without a factory
$stream = new Stream(fopen(...));

// creates a new stream from the given string
$stream = (new StreamFactory)->createStream('Hello, world!');

// creates a new stream from the request body
$stream = (new StreamFactory)->createStreamFromRequestBody();

// creates a new stream from the given filename or URI
$stream = (new StreamFactory)->createStreamFromFile('http://php.net/', 'rb');

// creates a new stream from the given resource
$stream = (new StreamFactory)->createStreamFromResource(fopen(...));

// converts the stream to string
(string) $stream;

// closes the stream
$stream->close();
```

## Test run

```bash
php vendor/bin/phpunit
```

## Api documentation

https://phpdoc.fenric.ru/

## Useful links

https://www.php-fig.org/psr/psr-7/<br>
https://www.php-fig.org/psr/psr-17/
⚠️ This package was **moved** to the [http-message](https://github.com/sunrise-php/http-message) package and is abandoned.
78 changes: 55 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,57 @@
{
"name": "sunrise/stream",
"description": "Sunrise Stream",
"keywords": ["fenric", "sunrise", "stream", "psr-7", "psr-17"],
"homepage": "https://github.com/sunrise-php/stream",
"license": "MIT",
"authors": [{
"name": "Anatoly Fenric",
"email": "anatoly@fenric.ru",
"homepage": "https://anatoly.fenric.ru/"
}],
"require": {
"php": "^7.2",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "7.4.3"
},
"autoload": {
"psr-4": {
"Sunrise\\Stream\\": "src/"
}
}
"name": "sunrise/stream",
"homepage": "https://github.com/sunrise-php/stream",
"description": "Stream wrapper for PHP 7.1+ based on PSR-7 and PSR-17",
"license": "MIT",
"keywords": [
"fenric",
"sunrise",
"http",
"stream",
"psr-7",
"psr-17",
"php7",
"php8"
],
"authors": [
{
"name": "Anatoly Fenric",
"email": "afenric@gmail.com",
"homepage": "https://github.com/fenric"
},
{
"name": "李昀陞 (Peter)",
"email": "peter279k@gmail.com",
"homepage": "https://github.com/peter279k"
}
],
"provide": {
"psr/http-message-implementation": "1.0"
},
"require": {
"php": "^7.1|^8.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "7.5.20|9.5.0",
"sunrise/coding-standard": "1.0.0"
},
"autoload": {
"psr-4": {
"Sunrise\\Stream\\": "src/"
}
},
"scripts": {
"test": [
"phpcs",
"psalm",
"XDEBUG_MODE=coverage phpunit --coverage-text --colors=always"
],
"build": [
"phpdoc -d src/ -t phpdoc/",
"XDEBUG_MODE=coverage phpunit --coverage-html coverage/"
]
},
"abandoned": "sunrise/http-message"
}
7 changes: 7 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<ruleset name="Sunrise Coding Standard">
<rule ref="./vendor/sunrise/coding-standard/ruleset.xml"/>

<file>src</file>
<file>tests</file>
</ruleset>
22 changes: 15 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true">
<testsuites>
<testsuite name="Sunrise Stream Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="sunrise/stream">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
18 changes: 18 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<DocblockTypeContradiction errorLevel="info" />
</issueHandlers>
</psalm>
23 changes: 0 additions & 23 deletions src/Exception/Exception.php

This file was deleted.

18 changes: 0 additions & 18 deletions src/Exception/InvalidArgumentException.php

This file was deleted.

10 changes: 8 additions & 2 deletions src/Exception/UnopenableStreamException.php
Original file line number Diff line number Diff line change
@@ -11,8 +11,14 @@

namespace Sunrise\Stream\Exception;

/**
* Import classes
*/
use RuntimeException;

/**
* UnopenableStreamException
*/
class UnopenableStreamException extends Exception
{}
class UnopenableStreamException extends RuntimeException
{
}
Loading