Skip to content

Commit

Permalink
cs
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Mar 6, 2015
1 parent e23a7d7 commit 0a1cef7
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 48 deletions.
3 changes: 3 additions & 0 deletions Command/SwaggerDumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($input->getOption('list-only')) {
$data = $this->getResourceList($apiDocs, $output);
$this->dump($data, null, $input, $output);

return;
}

Expand All @@ -75,6 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
throw new \InvalidArgumentException(sprintf('Resource "%s" does not exist.', $resource));
}
$this->dump($data, $resource, $input, $output);

return;
}

Expand Down Expand Up @@ -110,6 +112,7 @@ protected function dump(array $data, $resource, InputInterface $input, OutputInt

if (!$destination) {
$output->writeln($content);

return;
}

Expand Down
2 changes: 1 addition & 1 deletion DataTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DataTypes
/**
* Returns true if the supplied `actualType` value is considered a primitive type. Returns false, otherwise.
*
* @param string $type
* @param string $type
* @return bool
*/
public static function isPrimitive($type)
Expand Down
9 changes: 1 addition & 8 deletions DependencyInjection/SwaggerConfigCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,8 @@

namespace Nelmio\ApiDocBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;


/**
* Compiler pass that configures the SwaggerFormatter instance.
Expand Down Expand Up @@ -55,4 +48,4 @@ public function process(ContainerBuilder $container)
$formatter->addMethodCall('setAuthenticationConfig', array($authentication));
}
}
}
}
6 changes: 4 additions & 2 deletions Extractor/ApiDocExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,8 @@ protected function generateHumanReadableTypes(array $array)
/**
* Creates a human-readable version of the `actualType`. `subType` is taken into account.
*
* @param string $actualType
* @param string $subType
* @param string $actualType
* @param string $subType
* @return string
*/
protected function generateHumanReadableType($actualType, $subType)
Expand All @@ -531,6 +531,7 @@ protected function generateHumanReadableType($actualType, $subType)

if (class_exists($subType)) {
$parts = explode('\\', $subType);

return sprintf('object (%s)', end($parts));
}

Expand All @@ -545,6 +546,7 @@ protected function generateHumanReadableType($actualType, $subType)

if (class_exists($subType)) {
$parts = explode('\\', $subType);

return sprintf('array of objects (%s)', end($parts));
}

Expand Down
5 changes: 2 additions & 3 deletions Extractor/CachingApiDocExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Routing\RouterInterface;

/**
Expand Down Expand Up @@ -65,11 +64,11 @@ public function all()

$data = parent::all();
$this->cache->write(serialize($data), $resources);

return $data;
}

return unserialize(file_get_contents($this->cacheFile));

}
}
}
2 changes: 1 addition & 1 deletion Extractor/HandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface HandlerInterface
* Parse route parameters in order to populate ApiDoc.
*
* @param \Nelmio\ApiDocBundle\Annotation\ApiDoc $annotation
* @param array $annotations
* @param array $annotations
* @param \Symfony\Component\Routing\Route $route
* @param \ReflectionMethod $method
*/
Expand Down
9 changes: 4 additions & 5 deletions Formatter/RequestAwareSwaggerFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Nelmio\ApiDocBundle\Formatter;


use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\Request;

Expand All @@ -33,7 +32,7 @@ class RequestAwareSwaggerFormatter implements FormatterInterface
protected $formatter;

/**
* @param Request $request
* @param Request $request
* @param SwaggerFormatter $formatter
*/
public function __construct(Request $request, SwaggerFormatter $formatter)
Expand All @@ -45,8 +44,8 @@ public function __construct(Request $request, SwaggerFormatter $formatter)
/**
* Format a collection of documentation data.
*
* @param array $collection
* @param null $resource
* @param array $collection
* @param null $resource
* @internal param $array [ApiDoc] $collection
* @return string|array
*/
Expand All @@ -71,4 +70,4 @@ public function formatOne(ApiDoc $annotation)
{
return $this->formatter->formatOne($annotation);
}
}
}
24 changes: 12 additions & 12 deletions Formatter/SwaggerFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
use Nelmio\ApiDocBundle\DataTypes;
use Nelmio\ApiDocBundle\Swagger\ModelRegistry;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Router;
use Symfony\Component\Routing\RouterInterface;

/**
* Produces Swagger-compliant resource lists and API declarations as defined here:
Expand Down Expand Up @@ -79,8 +77,8 @@ public function setAuthenticationConfig(array $config)
*
* If resource is provided, an API declaration for that resource is produced. Otherwise, a resource listing is returned.
*
* @param array|ApiDoc[] $collection
* @param null|string $resource
* @param array|ApiDoc[] $collection
* @param null|string $resource
* @return string|array
*/
public function format(array $collection, $resource = null)
Expand All @@ -95,7 +93,7 @@ public function format(array $collection, $resource = null)
/**
* Formats the collection into Swagger-compliant output.
*
* @param array $collection
* @param array $collection
* @return array
*/
public function produceResourceListing(array $collection)
Expand Down Expand Up @@ -167,8 +165,8 @@ protected function getInfo()
/**
* Format documentation data for one route.
*
* @param ApiDoc $annotation
* return string|array
* @param ApiDoc $annotation
* return string|array
* @throws \BadMethodCallException
*/
public function formatOne(ApiDoc $annotation)
Expand All @@ -179,8 +177,8 @@ public function formatOne(ApiDoc $annotation)
/**
* Formats collection to produce a Swagger-compliant API declaration for the given resource.
*
* @param array $collection
* @param string $resource
* @param array $collection
* @param string $resource
* @return array
*/
protected function produceApiDeclaration(array $collection, $resource)
Expand All @@ -202,7 +200,6 @@ protected function produceApiDeclaration(array $collection, $resource)

$apiBag = array();


foreach ($collection as $item) {

/** @var $apiDoc ApiDoc */
Expand Down Expand Up @@ -373,6 +370,7 @@ protected function normalizeResourcePath($path)
$path = preg_replace('/({.*?})/', '', $path);
$path = trim(preg_replace('/[^0-9a-zA-Z]/', '-', $path), '-');
$path = preg_replace('/-+/', '-', $path);

return $path;
}

Expand All @@ -387,7 +385,7 @@ public function setBasePath($path)
/**
* Formats query parameters to Swagger-compliant form.
*
* @param array $input
* @param array $input
* @return array
*/
protected function deriveQueryParameters(array $input)
Expand Down Expand Up @@ -580,6 +578,7 @@ protected function stripBasePath($path)

$pattern = sprintf('#^%s#', preg_quote($this->basePath));
$subPath = preg_replace($pattern, '', $path);

return $subPath;
}

Expand All @@ -594,6 +593,7 @@ protected function generateNickname($method, $resource)
{
$resource = preg_replace('#/^#', '', $resource);
$resource = $this->normalizeResourcePath($resource);

return sprintf('%s_%s', strtolower($method), $resource);
}
}
}
6 changes: 3 additions & 3 deletions Parser/CollectionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CollectionParser implements ParserInterface, PostParserInterface
/**
* Return true/false whether this class supports parsing the given class.
*
* @param array $item containing the following fields: class, groups. Of which groups is optional
* @param array $item containing the following fields: class, groups. Of which groups is optional
*
* @return boolean
*/
Expand All @@ -47,7 +47,7 @@ public function parse(array $item)

/**
* @param array|string $item The string type of input to parse.
* @param array $parameters The previously-parsed parameters array.
* @param array $parameters The previously-parsed parameters array.
*
* @return array
*/
Expand All @@ -74,4 +74,4 @@ public function postParse(array $item, array $parameters)

return $parameters;
}
}
}
2 changes: 1 addition & 1 deletion Parser/FormErrorsParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FormErrorsParser implements ParserInterface, PostParserInterface
/**
* Return true/false whether this class supports parsing the given class.
*
* @param array $item containing the following fields: class, groups. Of which groups is optional
* @param array $item containing the following fields: class, groups. Of which groups is optional
*
* @return boolean
*/
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/method.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
{% else %}
<input type="hidden" name="header_method" value="{{ methods|join }}" />
{% endif %}

<legend>Headers</legend>

{% if acceptType %}
Expand Down
1 change: 0 additions & 1 deletion Tests/Controller/ApiDocControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace NelmioApiDocBundle\Tests\Controller;
use Nelmio\ApiDocBundle\Tests\WebTestCase;


/**
* Class ApiDocControllerTest
*
Expand Down
1 change: 0 additions & 1 deletion Tests/Extractor/CollectionDirectiveTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Nelmio\ApiDocBundle\Tests\Extractor;

class CollectionDirectiveTest extends \PHPUnit_Framework_TestCase
Expand Down
1 change: 0 additions & 1 deletion Tests/Extractor/TestExtractor.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Nelmio\ApiDocBundle\Tests\Extractor;

use Nelmio\ApiDocBundle\Extractor\ApiDocExtractor;
Expand Down
4 changes: 2 additions & 2 deletions Tests/Fixtures/Controller/ResourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Nelmio\ApiDocBundle\Tests\Fixtures\Controller;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;

class ResourceController
class ResourceController
{
/**
* @ApiDoc(
Expand Down Expand Up @@ -87,4 +87,4 @@ public function updateAnotherResourceAction()
{

}
}
}
2 changes: 1 addition & 1 deletion Tests/Fixtures/app/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,4 @@ test_route_25:
pattern: /with-link
defaults: { _controller: NelmioApiDocTestBundle:Test:withLinkAction }
requirements:
_method: GET
_method: GET
6 changes: 1 addition & 5 deletions Tests/Formatter/SwaggerFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Nelmio\ApiDocBundle\Tests\Formatter;


use Nelmio\ApiDocBundle\Extractor\ApiDocExtractor;
use Nelmio\ApiDocBundle\Formatter\SwaggerFormatter;
use Nelmio\ApiDocBundle\Tests\WebTestCase;


/**
* Class SwaggerFormatterTest
*
Expand Down Expand Up @@ -36,7 +34,6 @@ protected function setUp()
$this->formatter = $container->get('nelmio_api_doc.formatter.swagger_formatter');
}


public function testResourceListing()
{

Expand Down Expand Up @@ -99,7 +96,6 @@ public function testResourceListing()

$this->assertEquals($expected, $actual);


}

/**
Expand Down Expand Up @@ -988,4 +984,4 @@ public function dataTestApiDeclaration()
),
);
}
}
}

0 comments on commit 0a1cef7

Please sign in to comment.