Skip to content

Commit 0d27507

Browse files
Douglas Greenshieldsgsdevme
authored andcommitted
build: apply phpstan to project
1 parent 44e18bb commit 0d27507

15 files changed

+48
-14
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ before_script: composer install --dev --prefer-source
1010

1111
script:
1212
- vendor/bin/phpunit -v
13+
- vendor/bin/phpstan analyse . --level 8
1314

1415
dist: xenial
1516

Cache/CacheInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function get($key);
2121
*
2222
* @param string $key
2323
* @param string $value
24+
* @return void
2425
**/
2526
public function set($key, $value);
2627
}

Cache/NullCache.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class NullCache implements CacheInterface
1212
**/
1313
public function get($key)
1414
{
15+
return null;
1516
}
1617

1718
/**

Cache/ObjectCache.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,10 @@ class ObjectCache implements ObjectCacheInterface
1616
private $cache;
1717

1818
/**
19-
* @var SerializerInterface
19+
* @var OEmbedSerializerInterface
2020
**/
2121
private $serializer;
2222

23-
/**
24-
* @param CacheInterface $cache
25-
* @param OEmbedSerializerInterface $serializer
26-
**/
2723
public function __construct(CacheInterface $cache, OEmbedSerializerInterface $serializer)
2824
{
2925
$this->cache = $cache;

Cache/ObjectCacheInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public function get($key);
2222
*
2323
* @param string $key
2424
* @param OEmbedInterface $oEmbed
25+
* @return void
2526
**/
2627
public function set($key, OEmbedInterface $oEmbed);
2728
}

Client/GuzzleClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class GuzzleClient extends AbstractClient
1313
{
1414
/**
15-
* @var \GuzzleHttp\ClientInterface
15+
* @var \GuzzleHttp\ClientInterface|null
1616
*/
1717
private $guzzle;
1818

@@ -58,7 +58,7 @@ public function fetchEmbed(ProviderInterface $provider, string $mediaId, array $
5858
return (new OEmbedFactory())->createFromJson((string) $response->getBody(), $provider);
5959
}
6060

61-
private function getGuzzle()
61+
private function getGuzzle(): \GuzzleHttp\ClientInterface
6262
{
6363
if (null === $this->guzzle) {
6464
$this->guzzle = new Guzzle([

Command/FetchOEmbedCommand.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Markup\OEmbedBundle\Command;
44

55
use Markup\OEmbedBundle\Exception\OEmbedUnavailableException;
6+
use Markup\OEmbedBundle\Service\OEmbedService;
67
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
78
use Symfony\Component\Console\Input\InputArgument;
89
use Symfony\Component\Console\Input\InputInterface;
@@ -13,6 +14,9 @@
1314
*/
1415
class FetchOEmbedCommand extends ContainerAwareCommand
1516
{
17+
/**
18+
* @return void
19+
*/
1620
protected function configure()
1721
{
1822
$this
@@ -24,18 +28,22 @@ protected function configure()
2428

2529
protected function execute(InputInterface $input, OutputInterface $output)
2630
{
31+
/** @var string $provider */
2732
$provider = $input->getArgument('provider');
33+
/** @var string $mediaId */
2834
$mediaId = $input->getArgument('media_id');
2935

3036
$output->writeln(sprintf('Looking up oEmbed data for media ID %s from the provider "%s".', $mediaId, $provider));
3137

3238
$startTime = microtime(true);
3339
try {
34-
$oEmbed = $this->getContainer()->get('markup_oembed')->fetchOEmbed($provider, $mediaId);
40+
/** @var OEmbedService $oEmbedService */
41+
$oEmbedService = $this->getContainer()->get('markup_oembed');
42+
$oEmbed = $oEmbedService->fetchOEmbed($provider, $mediaId);
3543
} catch (OEmbedUnavailableException $e) {
3644
$output->writeln(sprintf('<error>Could not fetch the oEmbed data. Reported error: %s</error>', $e->getMessage()));
3745

38-
return;
46+
return 1;
3947
}
4048

4149
$output->writeln(
@@ -50,5 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5058
}
5159
$output->writeln(sprintf($format, $key, $value));
5260
}
61+
62+
return 0;
5363
}
5464
}

DependencyInjection/MarkupOEmbedExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class MarkupOEmbedExtension extends Extension
1717
{
1818
/**
19-
* {@inheritDoc}
19+
* @return void
2020
*/
2121
public function load(array $configs, ContainerBuilder $container)
2222
{
@@ -38,6 +38,7 @@ public function load(array $configs, ContainerBuilder $container)
3838
*
3939
* @param array $config
4040
* @param ContainerBuilder $container
41+
* @return void
4142
**/
4243
private function loadProviders(array $config, ContainerBuilder $container)
4344
{
@@ -56,6 +57,7 @@ private function loadProviders(array $config, ContainerBuilder $container)
5657
*
5758
* @param array $config
5859
* @param ContainerBuilder $container
60+
* @return void
5961
**/
6062
private function loadSquashRenderingErrors(array $config, ContainerBuilder $container)
6163
{
@@ -67,6 +69,7 @@ private function loadSquashRenderingErrors(array $config, ContainerBuilder $cont
6769
*
6870
* @param array $config
6971
* @param ContainerBuilder $container
72+
* @return void
7073
**/
7174
private function loadCacheServices(array $config, ContainerBuilder $container)
7275
{

Exception/ProviderNotFoundException.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88
class ProviderNotFoundException extends \RuntimeException implements ExceptionInterface
99
{
10+
/**
11+
* @param string $providerName
12+
*/
1013
public function __construct($providerName)
1114
{
1215
parent::__construct(sprintf('The oEmbed provider "%s" could not be found.', $providerName));

OEmbed/OEmbed.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88
class OEmbed implements OEmbedInterface
99
{
10+
/**
11+
* @var array<string>
12+
*/
1013
private static $knownTypes = ['photo', 'video', 'link', 'rich'];
1114

1215
/**
@@ -22,7 +25,7 @@ class OEmbed implements OEmbedInterface
2225
private $properties;
2326

2427
/**
25-
* @var string
28+
* @var string|null
2629
**/
2730
private $embedProperty;
2831

0 commit comments

Comments
 (0)