Skip to content

Commit

Permalink
Merge pull request #110 from t0mmy742/psr12
Browse files Browse the repository at this point in the history
PSR-12 + fully-qualified function calls
  • Loading branch information
l0gicgate committed Jan 3, 2020
2 parents 9c597e8 + cb10cf4 commit f4be120
Show file tree
Hide file tree
Showing 29 changed files with 139 additions and 22 deletions.
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: php

dist: trusty

matrix:
include:
- php: 7.2
Expand All @@ -17,10 +15,10 @@ before_script:
- composer install -n

script:
- if [[ "$ANALYSIS" != 'true' ]]; then vendor/bin/phpunit ; fi
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/phpunit --coverage-clover clover.xml ; fi
- vendor/bin/phpunit
- vendor/bin/phpcs
- vendor/bin/phpstan analyse src
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/phpcs ; fi
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/phpstan analyse src ; fi

after_success:
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/php-coveralls --coverage_clover=clover.xml -v ; fi
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,22 @@
}
],
"require": {
"php": "^7.2",
"ext-SimpleXML": "*",
"ext-fileinfo": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-SimpleXML": "*",
"php": "^7.2",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"adriansuter/php-autoload-override": "v0.1-beta",
"laminas/laminas-diactoros": "^2.0",
"nyholm/psr7": "^1.0",
"php-http/psr7-integration-tests": "dev-master",
"phpstan/phpstan": "^0.10.3",
"phpunit/phpunit": "^8.5",
"php-http/psr7-integration-tests": "dev-master",
"squizlabs/php_codesniffer": "^3.3.2",
"laminas/laminas-diactoros": "^2.0"
"squizlabs/php_codesniffer": "^3.5"
},
"provide": {
"psr/http-factory": "^1.0"
Expand All @@ -66,5 +67,8 @@
"phpunit": "phpunit",
"phpcs": "phpcs",
"phpstan": "phpstan analyse src --memory-limit=-1"
}
},
"config": {
"sort-packages": true
}
}
4 changes: 2 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<arg name="colors"/>

<!-- inherit rules from: -->
<rule ref="PSR2"/>
<rule ref="PSR12"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>

<!-- Paths to check -->
<file>src</file>
<file>tests</file>
</ruleset>
</ruleset>
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
colors="true"
bootstrap="tests/bootstrap.php"
>
Expand Down
1 change: 1 addition & 0 deletions src/Factory/DecoratedResponseFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions src/Factory/DecoratedServerRequestFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions src/Factory/DecoratedUriFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
21 changes: 20 additions & 1 deletion src/Response.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -15,6 +16,24 @@
use Psr\Http\Message\StreamInterface;
use RuntimeException;

use function basename;
use function in_array;
use function is_array;
use function is_resource;
use function is_string;
use function json_encode;
use function json_last_error;
use function json_last_error_msg;
use function mime_content_type;
use function preg_replace;
use function rawurlencode;
use function sprintf;
use function stream_get_meta_data;
use function strlen;
use function substr;

use const JSON_ERROR_NONE;

class Response implements ResponseInterface
{
/**
Expand All @@ -32,7 +51,7 @@ class Response implements ResponseInterface
*
* @var string
*/
const EOL = "\r\n";
public const EOL = "\r\n";

/**
* @param ResponseInterface $response
Expand Down
17 changes: 17 additions & 0 deletions src/ServerRequest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -15,6 +16,22 @@
use Psr\Http\Message\UriInterface;
use RuntimeException;

use function array_merge;
use function count;
use function explode;
use function is_array;
use function is_null;
use function is_object;
use function json_decode;
use function libxml_clear_errors;
use function libxml_disable_entity_loader;
use function libxml_use_internal_errors;
use function parse_str;
use function preg_split;
use function property_exists;
use function simplexml_load_string;
use function strtolower;

class ServerRequest implements ServerRequestInterface
{
/**
Expand Down
1 change: 1 addition & 0 deletions src/Uri.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions tests/Assets/PhpFunctionOverrides.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions tests/Providers/LaminasDiactorosPsr17FactoryProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions tests/Providers/NyholmPsr17FactoryProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions tests/Providers/Psr17FactoryProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
1 change: 1 addition & 0 deletions tests/Providers/ZendDiactorosPsr17FactoryProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand Down
4 changes: 4 additions & 0 deletions tests/Psr7Integration/Laminas/ResponseTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -14,6 +15,9 @@
use Slim\Http\Factory\DecoratedResponseFactory;
use Slim\Tests\Http\Providers\LaminasDiactorosPsr17FactoryProvider;

use function define;
use function defined;

class ResponseTest extends ResponseIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
4 changes: 4 additions & 0 deletions tests/Psr7Integration/Laminas/ServerRequestTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -14,6 +15,9 @@
use Slim\Http\Factory\DecoratedServerRequestFactory;
use Slim\Tests\Http\Providers\LaminasDiactorosPsr17FactoryProvider;

use function define;
use function defined;

class ServerRequestTest extends ServerRequestIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
4 changes: 4 additions & 0 deletions tests/Psr7Integration/Laminas/UriTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -14,6 +15,9 @@
use Slim\Http\Factory\DecoratedUriFactory;
use Slim\Tests\Http\Providers\LaminasDiactorosPsr17FactoryProvider;

use function define;
use function defined;

class UriTest extends UriIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
4 changes: 4 additions & 0 deletions tests/Psr7Integration/Nyholm/ResponseTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -14,6 +15,9 @@
use Slim\Http\Factory\DecoratedResponseFactory;
use Slim\Tests\Http\Providers\NyholmPsr17FactoryProvider;

use function define;
use function defined;

class ResponseTest extends ResponseIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
4 changes: 4 additions & 0 deletions tests/Psr7Integration/Nyholm/ServerRequestTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -14,6 +15,9 @@
use Slim\Http\Factory\DecoratedServerRequestFactory;
use Slim\Tests\Http\Providers\NyholmPsr17FactoryProvider;

use function define;
use function defined;

class ServerRequestTest extends ServerRequestIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
4 changes: 4 additions & 0 deletions tests/Psr7Integration/Nyholm/UriTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -14,6 +15,9 @@
use Slim\Http\Factory\DecoratedUriFactory;
use Slim\Tests\Http\Providers\NyholmPsr17FactoryProvider;

use function define;
use function defined;

class UriTest extends UriIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
4 changes: 4 additions & 0 deletions tests/Psr7Integration/Zend/ResponseTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -14,6 +15,9 @@
use Slim\Tests\Http\Providers\ZendDiactorosPsr17FactoryProvider;
use Zend\Diactoros\StreamFactory;

use function define;
use function defined;

class ResponseTest extends ResponseIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
4 changes: 4 additions & 0 deletions tests/Psr7Integration/Zend/ServerRequestTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -14,6 +15,9 @@
use Slim\Tests\Http\Providers\ZendDiactorosPsr17FactoryProvider;
use Zend\Diactoros\StreamFactory;

use function define;
use function defined;

class ServerRequestTest extends ServerRequestIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
4 changes: 4 additions & 0 deletions tests/Psr7Integration/Zend/UriTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -14,6 +15,9 @@
use Slim\Tests\Http\Providers\ZendDiactorosPsr17FactoryProvider;
use Zend\Diactoros\StreamFactory;

use function define;
use function defined;

class UriTest extends UriIntegrationTest
{
public static function setUpBeforeClass(): void
Expand Down
14 changes: 12 additions & 2 deletions tests/ResponseTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Slim Framework (https://slimframework.com)
*
Expand All @@ -15,6 +16,15 @@
use Slim\Http\Response;
use Slim\Tests\Http\Providers\Psr17FactoryProvider;

use function chr;
use function fclose;
use function fopen;
use function is_resource;
use function json_decode;
use function property_exists;

use const JSON_HEX_AMP;

class ResponseTest extends TestCase
{
public function testDisableSetter()
Expand Down Expand Up @@ -639,8 +649,8 @@ public function testWithInvalidJsonThrowsException()
{
$this->expectException(RuntimeException::class);

$data = ['foo' => 'bar'.chr(233)];
$this->assertEquals('bar'.chr(233), $data['foo']);
$data = ['foo' => 'bar' . chr(233)];
$this->assertEquals('bar' . chr(233), $data['foo']);

foreach ($this->factoryProviders as $factoryProvider) {
/** @var Psr17FactoryProvider $provider */
Expand Down
Loading

0 comments on commit f4be120

Please sign in to comment.