Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Mar 29, 2018
2 parents f60c217 + 7130425 commit 243075d
Show file tree
Hide file tree
Showing 71 changed files with 533 additions and 437 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ branches:
- /.*/

php:
- 7
- 7.1
- 7.2

Expand All @@ -16,12 +15,10 @@ before_install:
before_script:
- composer self-update
- composer install --no-interaction
- if [[ $TRAVIS_PHP_VERSION = 7.1 ]] || [[ $TRAVIS_PHP_VERSION = 7.2 ]]; then composer global require --dev phpstan/phpstan:0.9.*; fi

script:
- mkdir build
- composer check
- if [[ $TRAVIS_PHP_VERSION = 7.1 ]] || [[ $TRAVIS_PHP_VERSION = 7.2 ]]; then ~/.composer/vendor/bin/phpstan analyse module/*/src/ --level=6 -c phpstan.neon; fi

after_script:
- vendor/bin/phpcov merge build --clover build/clover.xml
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
## CHANGELOG

### 1.8.1

**Features**

* [125: Implement a path which returns a 1px image instead of a redirection](https://github.com/shlinkio/shlink/issues/125)

**Enhancements:**

* [130: Update to Expressive 3](https://github.com/shlinkio/shlink/issues/130)
* [137: Update symfony packages to v4](https://github.com/shlinkio/shlink/issues/137)

**Tasks**

* [131: Drop support for PHP 7](https://github.com/shlinkio/shlink/issues/131)
* [132: Add infection to improve tests](https://github.com/shlinkio/shlink/issues/132)

### 1.7.2

**Bugs:**
Expand Down
48 changes: 28 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
}
],
"require": {
"php": "^7.0",
"acelaya/ze-content-based-error-handler": "^2.0",
"php": "^7.1",
"acelaya/ze-content-based-error-handler": "^2.2",
"cocur/slugify": "^3.0",
"doctrine/annotations": "^1.4",
"doctrine/cache": "^1.6",
Expand All @@ -22,23 +22,23 @@
"doctrine/dbal": "^2.5",
"doctrine/migrations": "^1.4",
"doctrine/orm": "^2.5",
"endroid/qrcode": "^1.7",
"endroid/qr-code": "^1.7",
"firebase/php-jwt": "^4.0",
"guzzlehttp/guzzle": "^6.2",
"http-interop/http-middleware": "^0.4.1",
"mikehaertl/phpwkhtmltopdf": "^2.2",
"monolog/monolog": "^1.21",
"roave/security-advisories": "dev-master",
"symfony/console": "^3.4",
"symfony/filesystem": "^3.0",
"symfony/process": "^3.0",
"symfony/console": "^4.0",
"symfony/filesystem": "^4.0",
"symfony/process": "^4.0",
"theorchard/monolog-cascade": "^0.4",
"zendframework/zend-config": "^3.0",
"zendframework/zend-config-aggregator": "^1.0",
"zendframework/zend-expressive": "^2.0",
"zendframework/zend-expressive-fastroute": "^2.0",
"zendframework/zend-expressive-helpers": "^4.2",
"zendframework/zend-expressive-platesrenderer": "^1.3",
"zendframework/zend-diactoros": "^1.7",
"zendframework/zend-expressive": "^3.0",
"zendframework/zend-expressive-fastroute": "^3.0",
"zendframework/zend-expressive-helpers": "^5.0",
"zendframework/zend-expressive-platesrenderer": "^2.0",
"zendframework/zend-i18n": "^2.7",
"zendframework/zend-inputfilter": "^2.8",
"zendframework/zend-paginator": "^2.6",
Expand All @@ -47,14 +47,16 @@
},
"require-dev": {
"filp/whoops": "^2.0",
"phpunit/dbunit": "^3.0",
"phpunit/phpcov": "^4.0",
"phpunit/phpunit": "^6.0",
"infection/infection": "^0.8.1",
"phpstan/phpstan": "0.9",
"phpunit/phpcov": "^5.0",
"phpunit/phpunit": "^7.0",
"slevomat/coding-standard": "^4.0",
"squizlabs/php_codesniffer": "^3.1 <3.2",
"symfony/dotenv": "^3.4",
"symfony/var-dumper": "^3.0",
"zendframework/zend-expressive-tooling": "^0.4"
"symfony/dotenv": "^4.0",
"symfony/var-dumper": "^4.0",
"zendframework/zend-component-installer": "^2.1",
"zendframework/zend-expressive-tooling": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -84,8 +86,10 @@
"scripts": {
"check": [
"@cs",
"@stan",
"@test",
"@func-test"
"@func-test",
"@infect"
],
"cs": "phpcs",
"cs-fix": "phpcbf",
Expand All @@ -97,13 +101,17 @@
"@test",
"@func-test",
"phpcov merge build --html build/html"
]
],
"stan": "phpstan analyse module/*/src/ --level=6 -c phpstan.neon",
"infect": "infection --threads=4 --min-msi=65 --only-covered --log-verbosity=2",
"infect-show": "infection --threads=4 --min-msi=65 --only-covered --log-verbosity=2 --show-mutations",
"expressive": "expressive"
},
"config": {
"process-timeout": 0,
"sort-packages": true,
"platform": {
"php": "7.0.8"
"php": "7.1.8"
}
}
}
15 changes: 4 additions & 11 deletions config/autoload/dependencies.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,23 @@
use Zend\Expressive;
use Zend\Expressive\Container;
use Zend\Expressive\Helper;
use Zend\Expressive\Middleware;
use Zend\Expressive\Plates;
use Zend\Expressive\Router;
use Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware;
use Zend\Expressive\Template;
use Zend\ServiceManager\Factory\InvokableFactory;
use Zend\Stratigility\Middleware\ErrorHandler;

return [

'dependencies' => [
'factories' => [
Expressive\Application::class => Container\ApplicationFactory::class,
Template\TemplateRendererInterface::class => Plates\PlatesRendererFactory::class,
Router\RouterInterface::class => Router\FastRouteRouterFactory::class,
ErrorHandler::class => Container\ErrorHandlerFactory::class,
ImplicitOptionsMiddleware::class => EmptyResponseImplicitOptionsMiddlewareFactory::class,

Helper\UrlHelper::class => Helper\UrlHelperFactory::class,
Helper\ServerUrlHelper::class => InvokableFactory::class,
],

'aliases' => [
Middleware\ImplicitOptionsMiddleware::class => ImplicitOptionsMiddleware::class,
'delegators' => [
Expressive\Application::class => [
Container\ApplicationConfigInjectionDelegator::class,
],
],
],

Expand Down
2 changes: 2 additions & 0 deletions config/autoload/middleware-pipeline.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
declare(strict_types=1);

use Shlinkio\Shlink\Common\Middleware\LocaleMiddleware;
use Shlinkio\Shlink\Core\Response\NotFoundDelegate;
use Shlinkio\Shlink\Rest\Middleware\BodyParserMiddleware;
use Shlinkio\Shlink\Rest\Middleware\CheckAuthenticationMiddleware;
use Shlinkio\Shlink\Rest\Middleware\CrossDomainMiddleware;
Expand Down Expand Up @@ -48,6 +49,7 @@
'post-routing' => [
'middleware' => [
Expressive\Router\Middleware\DispatchMiddleware::class,
NotFoundDelegate::class,
],
'priority' => 1,
],
Expand Down
8 changes: 6 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Shlinkio\Shlink\Core;
use Shlinkio\Shlink\Rest;
use Zend\ConfigAggregator;
use Zend\Expressive;

/**
* Configuration files are loaded in a specific order. First ``global.php``, then ``*.global.php``.
Expand All @@ -18,8 +19,11 @@
*/

return (new ConfigAggregator\ConfigAggregator([
Zend\Expressive\ConfigProvider::class,
Zend\Expressive\Router\ConfigProvider::class,
Expressive\ConfigProvider::class,
Expressive\Router\ConfigProvider::class,
Expressive\Router\FastRouteRouter\ConfigProvider::class,
Expressive\Plates\ConfigProvider::class,
Expressive\Helper\ConfigProvider::class,
ExpressiveErrorHandler\ConfigProvider::class,
Common\ConfigProvider::class,
Core\ConfigProvider::class,
Expand Down
18 changes: 18 additions & 0 deletions infection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"source": {
"directories": [
"module/*/src"
],
"excludes": []
},
"timeout": 10,
"logs": {
"text": "build/infection/infection-log.txt",
"summary": "build/infection/summary-log.txt",
"debug": "build/infection/debug-log.txt"
},
"tmpDir": "build/infection/temp",
"phpUnit": {
"configDir": "."
}
}
4 changes: 2 additions & 2 deletions module/CLI/src/Command/Install/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function execute(InputInterface $input, OutputInterface $output)
if (! $this->isUpdate) {
$this->io->write('Initializing database...');
if (! $this->runCommand(
'php vendor/bin/doctrine.php orm:schema-tool:create',
'php vendor/bin/doctrine orm:schema-tool:create',
'Error generating database.',
$output
)) {
Expand All @@ -155,7 +155,7 @@ public function execute(InputInterface $input, OutputInterface $output)
// Generate proxies
$this->io->write('Generating proxies...');
if (! $this->runCommand(
'php vendor/bin/doctrine.php orm:generate-proxies',
'php vendor/bin/doctrine orm:generate-proxies',
'Error generating proxies.',
$output
)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class EmptyResponseImplicitOptionsMiddlewareFactory implements FactoryInterface
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
return new ImplicitOptionsMiddleware(new EmptyResponse());
return new ImplicitOptionsMiddleware(function () {
return new EmptyResponse();
});
}
}
10 changes: 5 additions & 5 deletions module/Common/src/Middleware/LocaleMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

namespace Shlinkio\Shlink\Common\Middleware;

use Interop\Http\ServerMiddleware\DelegateInterface;
use Interop\Http\ServerMiddleware\MiddlewareInterface;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface as DelegateInterface;
use Zend\I18n\Translator\Translator;

class LocaleMiddleware implements MiddlewareInterface
Expand All @@ -32,15 +32,15 @@ public function __construct(Translator $translator)
*
* @return Response
*/
public function process(Request $request, DelegateInterface $delegate)
public function process(Request $request, DelegateInterface $delegate): Response
{
if (! $request->hasHeader('Accept-Language')) {
return $delegate->process($request);
return $delegate->handle($request);
}

$locale = $request->getHeaderLine('Accept-Language');
$this->translator->setLocale($this->normalizeLocale($locale));
return $delegate->process($request);
return $delegate->handle($request);
}

/**
Expand Down
33 changes: 33 additions & 0 deletions module/Common/src/Response/PixelResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);

namespace Shlinkio\Shlink\Common\Response;

use Psr\Http\Message\StreamInterface;
use Zend\Diactoros\Response;
use Zend\Diactoros\Stream;

class PixelResponse extends Response
{
private const BASE_64_IMAGE = 'R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==';
private const CONTENT_TYPE = 'image/gif';

public function __construct(int $status = 200, array $headers = [])
{
$headers['content-type'] = self::CONTENT_TYPE;
parent::__construct($this->createBody(), $status, $headers);
}

/**
* Create the message body.
*
* @return StreamInterface
*/
private function createBody(): StreamInterface
{
$body = new Stream('php://temp', 'wb+');
$body->write(\base64_decode(self::BASE_64_IMAGE));
$body->rewind();
return $body;
}
}
27 changes: 2 additions & 25 deletions module/Common/test-func/DbUnit/DatabaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,17 @@

namespace ShlinkioTest\Shlink\Common\DbUnit;

use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\DbUnit\Database\Connection as DbConn;
use PHPUnit\DbUnit\DataSet\IDataSet as DataSet;
use PHPUnit\DbUnit\TestCase;
use PHPUnit\Framework\TestCase;

abstract class DatabaseTestCase extends TestCase
{
const ENTITIES_TO_EMPTY = [];
protected const ENTITIES_TO_EMPTY = [];

/**
* @var EntityManagerInterface
*/
public static $em;
/**
* @var DbConn
*/
private static $conn;

public function getConnection(): DbConn
{
if (isset(self::$conn)) {
return self::$conn;
}

/** @var PDOConnection $pdo */
$pdo = static::$em->getConnection()->getWrappedConnection();
return self::$conn = $this->createDefaultDBConnection($pdo, static::$em->getConnection()->getDatabase());
}

public function getDataSet(): DataSet
{
return $this->createArrayDataSet([]);
}

protected function getEntityManager(): EntityManagerInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function responsePrototypeIsEmptyResponse()
$instance = $this->factory->__invoke(new ServiceManager(), '');

$ref = new \ReflectionObject($instance);
$prop = $ref->getProperty('response');
$prop = $ref->getProperty('responseFactory');
$prop->setAccessible(true);
$this->assertInstanceOf(EmptyResponse::class, $prop->getValue($instance));
$this->assertInstanceOf(EmptyResponse::class, $prop->getValue($instance)());
}
}
Loading

0 comments on commit 243075d

Please sign in to comment.