Improved coding styles

This commit is contained in:
Alejandro Celaya 2017-10-12 10:13:20 +02:00
parent fbeb959317
commit c422a14c5c
219 changed files with 473 additions and 26 deletions

View File

@ -46,6 +46,7 @@
"require-dev": {
"filp/whoops": "^2.0",
"phpunit/phpunit": "^6.0",
"slevomat/coding-standard": "^4.0",
"squizlabs/php_codesniffer": "^3.1",
"symfony/var-dumper": "^3.0",
"vlucas/phpdotenv": "^2.2",

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\Common;
return [

View File

@ -4,11 +4,11 @@ declare(strict_types=1);
use Shlinkio\Shlink\Common\Factory\EmptyResponseImplicitOptionsMiddlewareFactory;
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\Template;
use Zend\Expressive\Helper;
use Zend\ServiceManager\Factory\InvokableFactory;
use Zend\Stratigility\Middleware\ErrorHandler;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\Common;
return [

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\Common\Middleware\LocaleMiddleware;
use Shlinkio\Shlink\Rest\Middleware\BodyParserMiddleware;
use Shlinkio\Shlink\Rest\Middleware\CheckAuthenticationMiddleware;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
return [
'phpwkhtmltopdf' => [

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
return [
'preview_generation' => [

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use Zend\Expressive\Router\FastRouteRouter;
return [

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
return [

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\Common;
return [

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\Common;
use Shlinkio\Shlink\Core\Service\UrlShortener;

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
return [

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Interop\Container\ContainerInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use Acelaya\ExpressiveErrorHandler;
use Shlinkio\Shlink\CLI;
use Shlinkio\Shlink\Common;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use Dotenv\Dotenv;
use Zend\ServiceManager\ServiceManager;

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\CLI\Command;
use Shlinkio\Shlink\Common;
@ -22,7 +24,7 @@ return [
Command\Tag\CreateTagCommand::class,
Command\Tag\RenameTagCommand::class,
Command\Tag\DeleteTagsCommand::class,
]
],
],
];

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\CLI\Command;
use Shlinkio\Shlink\CLI\Factory\ApplicationFactory;
@ -46,12 +47,12 @@ return [
Command\Shortcode\GeneratePreviewCommand::class => [
Service\ShortUrlService::class,
PreviewGenerator::class,
'translator'
'translator',
],
Command\Visit\ProcessVisitsCommand::class => [
Service\VisitService::class,
IpLocationResolver::class,
'translator'
'translator',
],
Command\Config\GenerateCharsetCommand::class => ['translator'],
Command\Config\GenerateSecretCommand::class => ['translator'],

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
return [
'translator' => [

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Api;
use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Api;
use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Api;
use Shlinkio\Shlink\Rest\Entity\ApiKey;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Config;
use Shlinkio\Shlink\Core\Service\UrlShortener;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Config;
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Install;
use Shlinkio\Shlink\CLI\Install\ConfigCustomizerPluginManagerInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Shortcode;
use Shlinkio\Shlink\Common\Exception\PreviewGenerationException;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Shortcode;
use Shlinkio\Shlink\Core\Exception\InvalidUrlException;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Shortcode;
use Shlinkio\Shlink\Common\Util\DateRange;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Shortcode;
use Shlinkio\Shlink\Common\Paginator\Adapter\PaginableRepositoryAdapter;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Shortcode;
use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Tag;
use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Tag;
use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Tag;
use Shlinkio\Shlink\Core\Entity\Tag;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Tag;
use Shlinkio\Shlink\Core\Exception\EntityDoesNotExistException;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Visit;
use Shlinkio\Shlink\Common\Exception\WrongIpException;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI;
use Zend\Config\Factory;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Factory;
use Interop\Container\ContainerInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Factory;
use Interop\Container\ContainerInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install;
use Shlinkio\Shlink\CLI\Install\Plugin\ConfigCustomizerPluginInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install;
use Psr\Container\ContainerInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Symfony\Component\Console\Exception\RuntimeException;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Acelaya\ZsmAnnotatedServices\Annotation as DI;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin\Factory;
use Interop\Container\ContainerInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
@ -42,7 +44,7 @@ class UrlShortenerConfigCustomizerPlugin extends AbstractConfigCustomizerPlugin
'Character set for generated short codes (leave empty to autogenerate one)',
null,
true
) ?: str_shuffle(UrlShortener::DEFAULT_CHARS)
) ?: str_shuffle(UrlShortener::DEFAULT_CHARS),
]);
}
}

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Model;
use Zend\Stdlib\ArraySerializableInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Api;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Api;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Api;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Config;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Install;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Shortcode;
use PHPUnit\Framework\TestCase;
@ -63,7 +65,7 @@ class GeneratePreviewCommandTest extends TestCase
$this->previewGenerator->generatePreview('http://baz.com/something')->shouldBeCalledTimes(1);
$this->commandTester->execute([
'command' => 'shortcode:process-previews'
'command' => 'shortcode:process-previews',
]);
}
@ -83,7 +85,7 @@ class GeneratePreviewCommandTest extends TestCase
->shouldBeCalledTimes(count($items));
$this->commandTester->execute([
'command' => 'shortcode:process-previews'
'command' => 'shortcode:process-previews',
]);
$output = $this->commandTester->getDisplay();
$this->assertEquals(count($items), substr_count($output, 'Error'));

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Shortcode;
use PHPUnit\Framework\TestCase;
@ -27,7 +29,7 @@ class GenerateShortcodeCommandTest extends TestCase
$this->urlShortener = $this->prophesize(UrlShortener::class);
$command = new GenerateShortcodeCommand($this->urlShortener->reveal(), Translator::factory([]), [
'schema' => 'http',
'hostname' => 'foo.com'
'hostname' => 'foo.com',
]);
$app = new Application();
$app->add($command);
@ -44,7 +46,7 @@ class GenerateShortcodeCommandTest extends TestCase
$this->commandTester->execute([
'command' => 'shortcode:generate',
'longUrl' => 'http://domain.com/foo/bar'
'longUrl' => 'http://domain.com/foo/bar',
]);
$output = $this->commandTester->getDisplay();
$this->assertTrue(strpos($output, 'http://foo.com/abc123') > 0);
@ -60,7 +62,7 @@ class GenerateShortcodeCommandTest extends TestCase
$this->commandTester->execute([
'command' => 'shortcode:generate',
'longUrl' => 'http://domain.com/invalid'
'longUrl' => 'http://domain.com/invalid',
]);
$output = $this->commandTester->getDisplay();
$this->assertTrue(

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Shortcode;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Shortcode;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Shortcode;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Tag;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Tag;
use PHPUnit\Framework\TestCase;

View File

@ -1,10 +1,12 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Tag;
use PHPUnit\Framework\TestCase;
use Prophecy\Prophecy\MethodProphecy;
use Prophecy\Prophecy\ObjectProphecy;
use Shlinkio\Shlink\CLI\Command\Tag\ListTagsCommand;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Entity\Tag;
use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface;
use Symfony\Component\Console\Application;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Tag;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Visit;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Factory;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Factory;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Install\Plugin;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Install\Plugin;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Install\Plugin\Factory;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Install\Plugin;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Install\Plugin;
use PHPUnit\Framework\TestCase;

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
use Doctrine\Common\Cache\Cache;
use Doctrine\ORM\EntityManager;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common;
/**

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common;
use Zend\Config\Factory;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Entity;
use Doctrine\ORM\Mapping as ORM;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Exception;
interface ExceptionInterface

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Exception;
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Exception;
class PreviewGenerationException extends RuntimeException

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Exception;
class RuntimeException extends \RuntimeException implements ExceptionInterface

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Exception;
class WrongIpException extends RuntimeException

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Factory;
use Doctrine\Common\Cache;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Factory;
use Interop\Container\ContainerInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Factory;
use Interop\Container\ContainerInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Factory;
use Doctrine\Common\Cache\ArrayCache;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Factory;
use Cascade\Cascade;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Factory;
use Interop\Container\ContainerInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Image;
use mikehaertl\wkhtmlto\Image;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Image;
use Interop\Container\ContainerInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Image;
use Zend\ServiceManager\ServiceLocatorInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Image;
use Interop\Container\ContainerInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Middleware;
use Interop\Http\ServerMiddleware\DelegateInterface;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Paginator\Adapter;
use Shlinkio\Shlink\Common\Repository\PaginableRepositoryInterface;
@ -32,7 +34,7 @@ class PaginableRepositoryAdapter implements AdapterInterface
$orderBy = null
) {
$this->paginableRepository = $paginableRepository;
$this->searchTerm = trim(strip_tags($searchTerm));
$this->searchTerm = $searchTerm !== null ? trim(strip_tags($searchTerm)) : null;
$this->orderBy = $orderBy;
$this->tags = $tags;
}

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Paginator\Util;
use Zend\Paginator\Paginator;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Repository;
interface PaginableRepositoryInterface

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Response;
use Endroid\QrCode\QrCode;

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Service;
use GuzzleHttp\Client;
@ -27,7 +29,7 @@ class IpLocationResolver implements IpLocationResolverInterface
{
try {
$response = $this->httpClient->get(sprintf(self::SERVICE_PATTERN, $ipAddress));
return json_decode($response->getBody(), true);
return json_decode((string) $response->getBody(), true);
} catch (GuzzleException $e) {
throw WrongIpException::fromIpAddress($ipAddress, $e);
}

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Service;
interface IpLocationResolverInterface

View File

@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Service;
use mikehaertl\wkhtmlto\Image;

Some files were not shown because too many files have changed in this diff Show More