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
+3 -1
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,
]
],
],
];
+3 -2
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'],
+2
View File
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
return [
'translator' => [
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Api;
use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Api;
use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Api;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Config;
use Shlinkio\Shlink\Core\Service\UrlShortener;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Config;
use Shlinkio\Shlink\Common\Util\StringUtilsTrait;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Install;
use Shlinkio\Shlink\CLI\Install\ConfigCustomizerPluginManagerInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Shortcode;
use Shlinkio\Shlink\Common\Exception\PreviewGenerationException;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Shortcode;
use Shlinkio\Shlink\Core\Exception\InvalidUrlException;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Shortcode;
use Shlinkio\Shlink\Common\Util\DateRange;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Shortcode;
use Shlinkio\Shlink\Common\Paginator\Adapter\PaginableRepositoryAdapter;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Shortcode;
use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Tag;
use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Tag;
use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Tag;
use Shlinkio\Shlink\Core\Entity\Tag;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Tag;
use Shlinkio\Shlink\Core\Exception\EntityDoesNotExistException;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Command\Visit;
use Shlinkio\Shlink\Common\Exception\WrongIpException;
+2
View File
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI;
use Zend\Config\Factory;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Factory;
use Interop\Container\ContainerInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Factory;
use Interop\Container\ContainerInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install;
use Shlinkio\Shlink\CLI\Install\Plugin\ConfigCustomizerPluginInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install;
use Psr\Container\ContainerInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Symfony\Component\Console\Exception\RuntimeException;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Acelaya\ZsmAnnotatedServices\Annotation as DI;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin\Factory;
use Interop\Container\ContainerInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Install\Plugin;
use Shlinkio\Shlink\CLI\Model\CustomizableAppConfig;
@@ -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),
]);
}
}
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\CLI\Model;
use Zend\Stdlib\ArraySerializableInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Api;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Api;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Api;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Config;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Install;
use PHPUnit\Framework\TestCase;
@@ -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'));
@@ -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(
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Shortcode;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Shortcode;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Shortcode;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Tag;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Tag;
use PHPUnit\Framework\TestCase;
@@ -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;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Tag;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Command\Visit;
use PHPUnit\Framework\TestCase;
+2
View File
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Factory;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Factory;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Install\Plugin;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Install\Plugin;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Install\Plugin\Factory;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Install\Plugin;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Install\Plugin;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
use Doctrine\Common\Cache\Cache;
use Doctrine\ORM\EntityManager;
+2
View File
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common;
/**
+2
View File
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common;
use Zend\Config\Factory;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Entity;
use Doctrine\ORM\Mapping as ORM;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Exception;
interface ExceptionInterface
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Exception;
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Exception;
class PreviewGenerationException extends RuntimeException
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Exception;
class RuntimeException extends \RuntimeException implements ExceptionInterface
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Exception;
class WrongIpException extends RuntimeException
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Factory;
use Doctrine\Common\Cache;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Factory;
use Interop\Container\ContainerInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Factory;
use Interop\Container\ContainerInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Factory;
use Doctrine\Common\Cache\ArrayCache;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Factory;
use Cascade\Cascade;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Factory;
use Interop\Container\ContainerInterface;
+2
View File
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Image;
use mikehaertl\wkhtmlto\Image;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Image;
use Interop\Container\ContainerInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Image;
use Zend\ServiceManager\ServiceLocatorInterface;
+2
View File
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Image;
use Interop\Container\ContainerInterface;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Middleware;
use Interop\Http\ServerMiddleware\DelegateInterface;
@@ -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;
}
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Paginator\Util;
use Zend\Paginator\Paginator;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Repository;
interface PaginableRepositoryInterface
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Response;
use Endroid\QrCode\QrCode;
@@ -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);
}
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Service;
interface IpLocationResolverInterface
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Service;
use mikehaertl\wkhtmlto\Image;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Service;
use Shlinkio\Shlink\Common\Exception\PreviewGenerationException;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Template\Extension;
use League\Plates\Engine;
+2
View File
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Util;
class DateRange
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Util;
use Zend\Diactoros\Response;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common\Util;
trait StringUtilsTrait
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Factory;
use Doctrine\Common\Cache\ApcuCache;
@@ -88,11 +90,11 @@ class CacheFactoryTest extends TestCase
$servers = [
[
'host' => '1.2.3.4',
'port' => 123
'port' => 123,
],
[
'host' => '4.3.2.1',
'port' => 321
'port' => 321,
],
];
/** @var MemcachedCache $instance */
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Factory;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Factory;
use Doctrine\ORM\EntityManager;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Factory;
use Monolog\Logger;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Factory;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Image;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Image;
use mikehaertl\wkhtmlto\Image;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Middleware;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Paginator;
use PHPUnit\Framework\TestCase;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Service;
use GuzzleHttp\Client;
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Service;
use mikehaertl\wkhtmlto\Image;
@@ -35,7 +37,7 @@ class PreviewGeneratorTest extends TestCase
Image::class => function () {
return $this->image->reveal();
},
]
],
]), $this->filesystem->reveal(), 'dir');
}
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Common\Template\Extension;
use League\Plates\Engine;

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