Skip to content

Commit

Permalink
Merge pull request #174 from alexdebril/issue/173
Browse files Browse the repository at this point in the history
strict_types usage
  • Loading branch information
alexdebril authored Apr 20, 2018
2 parents d914221 + 962fb75 commit f6d246f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 33 deletions.
18 changes: 9 additions & 9 deletions Controller/StreamController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace Debril\RssAtomBundle\Controller;

Expand Down Expand Up @@ -28,7 +28,7 @@ class StreamController extends Controller
* @return Response
* @throws \Exception
*/
public function indexAction(Request $request, FeedContentProviderInterface $provider, FeedIo $feedIo)
public function indexAction(Request $request, FeedContentProviderInterface $provider, FeedIo $feedIo) : Response
{
$options = $request->attributes->get('_route_params');
$this->setModifiedSince($request);
Expand All @@ -47,7 +47,7 @@ public function indexAction(Request $request, FeedContentProviderInterface $prov
*
* @return \DateTime
*/
protected function getModifiedSince()
protected function getModifiedSince() : \DateTime
{
if (is_null($this->since)) {
$this->since = new \DateTime('@0');
Expand All @@ -61,7 +61,7 @@ protected function getModifiedSince()
*
* @return $this
*/
protected function setModifiedSince(Request $request)
protected function setModifiedSince(Request $request) : self
{
$this->since = new \DateTime();
if ($request->headers->has('If-Modified-Since')) {
Expand All @@ -88,7 +88,7 @@ protected function setModifiedSince(Request $request)
*
* @throws \Exception
*/
protected function createStreamResponse(array $options, $format, FeedContentProviderInterface $provider, FeedIo $feedIo)
protected function createStreamResponse(array $options, string $format, FeedContentProviderInterface $provider, FeedIo $feedIo) : Response
{
$content = $this->getContent($options, $provider);

Expand All @@ -110,7 +110,7 @@ protected function createStreamResponse(array $options, $format, FeedContentProv
* @param string $format
* @return $this
*/
protected function setFeedHeaders(Response $response, FeedInterface $feed, $format)
protected function setFeedHeaders(Response $response, FeedInterface $feed, string $format) : self
{
$contentType =
'json' == $format ?
Expand Down Expand Up @@ -140,7 +140,7 @@ protected function setFeedHeaders(Response $response, FeedInterface $feed, $form
*
* @throws \Exception
*/
protected function getContent(array $options, $provider)
protected function getContent(array $options, FeedContentProviderInterface $provider) : FeedInterface
{
try {
return $provider->getFeedContent($options);
Expand All @@ -154,15 +154,15 @@ protected function getContent(array $options, $provider)
*
* @return bool
*/
protected function mustForceRefresh()
protected function mustForceRefresh() : bool
{
return $this->container->getParameter('debril_rss_atom.force_refresh');
}

/**
* @return boolean true if the feed must be private
*/
protected function isPrivate()
protected function isPrivate() : bool
{
return $this->container->getParameter('debril_rss_atom.private_feeds');
}
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace Debril\RssAtomBundle\DependencyInjection;

Expand All @@ -15,7 +15,7 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder() : TreeBuilder
{
$treeBuilder = new TreeBuilder();

Expand Down
18 changes: 9 additions & 9 deletions DependencyInjection/DebrilRssAtomExtension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace Debril\RssAtomBundle\DependencyInjection;

Expand Down Expand Up @@ -36,7 +36,7 @@ class DebrilRssAtomExtension extends Extension implements CompilerPassInterface
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container) : void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
Expand All @@ -56,7 +56,7 @@ public function load(array $configs, ContainerBuilder $container)
* @param array $config
* @return $this
*/
protected function setDateFormats(ContainerBuilder $container, array $config)
protected function setDateFormats(ContainerBuilder $container, array $config) : self
{
$dateFormats = isset($config['date_formats']) ?
array_merge($this->defaultDateFormats, $config['date_formats']):
Expand All @@ -71,20 +71,20 @@ protected function setDateFormats(ContainerBuilder $container, array $config)
}

/**
* @param ContainerBuilder $builder
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container) : void
{
$this->setDefinition($container, 'logger', 'Psr\Log\NullLogger');
}

/**
* @param ContainerBuilder $container
* @param $serviceName
* @param $className
* @return $this
* @param string $serviceName
* @param string $className
* @return DebrilRssAtomExtension
*/
protected function setDefinition(ContainerBuilder $container, $serviceName, $className)
protected function setDefinition(ContainerBuilder $container, string $serviceName, string $className) : self
{
if ( ! $container->has($serviceName) ) {
$container->setDefinition($serviceName, new Definition($className));
Expand Down
12 changes: 6 additions & 6 deletions Provider/DoctrineFeedContentProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/**
* Feed aggregator for Symfony.
Expand Down Expand Up @@ -42,7 +42,7 @@ public function __construct(Registry $doctrine)
*
* @return string
*/
public function getRepositoryName()
public function getRepositoryName() : string
{
return $this->repositoryName;
}
Expand All @@ -54,7 +54,7 @@ public function getRepositoryName()
*
* @return DoctrineFeedContentProvider
*/
public function setRepositoryName($repositoryName)
public function setRepositoryName(string $repositoryName) : self
{
$this->repositoryName = $repositoryName;

Expand All @@ -68,7 +68,7 @@ public function setRepositoryName($repositoryName)
*
* @throws FeedNotFoundException
*/
public function getFeedContent(array $options)
public function getFeedContent(array $options) : FeedInterface
{
// fetch feed from data repository
$feed = $this->getDoctrine()
Expand Down Expand Up @@ -96,9 +96,9 @@ public function getDoctrine()
/**
* @param array $options
*
* @return mixed
* @return string
*/
public function getIdFromOptions(array $options)
public function getIdFromOptions(array $options) : string
{
$optionsResolver = new OptionsResolver();
$optionsResolver->setRequired('id');
Expand Down
4 changes: 2 additions & 2 deletions Provider/FeedContentProviderInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/**
* RssAtomBundle.
Expand Down Expand Up @@ -26,5 +26,5 @@ interface FeedContentProviderInterface
*
* @return FeedInterface
*/
public function getFeedContent(array $options);
public function getFeedContent(array $options) : FeedInterface;
}
9 changes: 5 additions & 4 deletions Provider/MockProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/**
* RssAtomBundle.
Expand All @@ -14,6 +14,7 @@
use FeedIo\Feed;
use FeedIo\Feed\Item;
use Debril\RssAtomBundle\Exception\FeedException\FeedNotFoundException;
use FeedIo\FeedInterface;

/**
* Class MockProvider.
Expand All @@ -23,11 +24,11 @@ class MockProvider implements FeedContentProviderInterface
/**
* @param array $options
*
* @return Feed
* @return FeedInterface
*
* @throws FeedNotFoundException
*/
public function getFeedContent(array $options)
public function getFeedContent(array $options) : FeedInterface
{
$feed = new Feed();

Expand All @@ -51,7 +52,7 @@ public function getFeedContent(array $options)
* @param Feed $feed
* @return Feed
*/
protected function addItem(Feed $feed)
protected function addItem(Feed $feed) : FeedInterface
{
$item = new Item();

Expand Down
2 changes: 1 addition & 1 deletion Tests/Provider/MockProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function tearDown()
*/
public function testGetContent()
{
$options = array('id' => 1);
$options = array('id' => 'some id');
$feed = $this->object->getFeedContent($options);

$this->assertInstanceOf('FeedIo\FeedInterface', $feed);
Expand Down

0 comments on commit f6d246f

Please sign in to comment.