Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Commit

Permalink
Improving docblocks and general cleanup, updating travis config.
Browse files Browse the repository at this point in the history
Removing scrutinizer config
  • Loading branch information
stanlemon committed Oct 2, 2014
1 parent 149fe7e commit 2c65e49
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vendor
composer.lock
test-reports
docs
docs
21 changes: 16 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@ php:

matrix:
allow_failures:
- php: 5.3
- php: 5.6
- php: hhvm
include:
- php: hhvm
env: DOCTRINE_VERSION='doctrine/dbal=~2.5@dev doctrine/orm=~2.5@dev doctrine/doctrine-bundle=~1.3@dev'

before_script:
- composer self-update
- sh -c 'if [ "$DOCTRINE_VERSION" != "" ]; then composer require --no-update $DOCTRINE_VERSION; fi;'
- composer update --prefer-source

script: ./vendor/bin/phpunit --coverage-clover=coverage.clover

install:
- composer install --no-interaction --dev --prefer-source
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover

script: ./vendor/bin/phpunit
notifications:
email:
- stosh1985@gmail.com
3 changes: 3 additions & 0 deletions Controller/RestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

class RestController
{
protected $managerFactory;
protected $handler;

public function __construct(
ManagerFactory $managerFactory,
Handler $handler
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Compiler/RegisterResourcePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function process(ContainerBuilder $container)
$expandedNamespace = substr($file->getPath(), strlen($dir) + 1);

// If we are in a sub namespace add a trailing separation
$expandedNamespace = $expandedNamespace == false ? '' : $expandedNamespace . '\\';
$expandedNamespace = $expandedNamespace === false ? '' : $expandedNamespace . '\\';

$className = $baseNamespace . $expandedNamespace . $file->getBasename('.php');

Expand All @@ -48,7 +48,7 @@ public function process(ContainerBuilder $container)
if ($annotation instanceof Resource) {
$name = $annotation->name ?: lcfirst($reflectionClass->getShortName());

$registry->addMethodCall('addClass', [$name, $className]);
$registry->addMethodCall('addClass', array($name, $className));
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Object/Exception/InvalidException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ class InvalidException extends \RuntimeException
{
protected $errors;

/**
* @param string $message
* @param array $errors
*/
public function __construct($message, $errors = array())
{
parent::__construct($message, 0, null);
Expand Down
7 changes: 6 additions & 1 deletion Object/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class Manager
protected $eventDispatcher;
protected $class;

/**
* @param Doctrine $doctrine
* @param EventDispatcher $eventDispatcher
* @param string $class
*/
public function __construct(
Doctrine $doctrine,
EventDispatcher $eventDispatcher,
Expand Down Expand Up @@ -49,7 +54,7 @@ protected function getRepository()

/**
* @param Criteria $criteria
* @return array
* @return SearchResults
*/
public function search(Criteria $criteria)
{
Expand Down
13 changes: 6 additions & 7 deletions Object/Processor.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php
namespace Lemon\RestBundle\Object;

use Doctrine\Bundle\DoctrineBundle\Registry;
use Doctrine\Bundle\DoctrineBundle\Registry as Doctrine;
use Doctrine\ORM\UnitOfWork;
use Metadata\MetadataFactory;

class Processor
{
/**
* @var Registry
* @var \Doctrine\Bundle\DoctrineBundle\Registry
*/
protected $doctrine;
/**
* @var MetadataFactory
* @var \Metadata\MetadataFactory
*/
protected $metadataFactory;

public function __construct(Registry $doctrine, MetadataFactory $metadataFactory)
public function __construct(Doctrine $doctrine, MetadataFactory $metadataFactory)
{
$this->doctrine = $doctrine;
$this->metadataFactory = $metadataFactory;
Expand All @@ -30,8 +30,6 @@ public function process($object, $entity = null)

/**
* @todo Must go beyond second depth
* @todo Must handle one-to-one relationships
* @todo Evaluating missing values should reflect identifier rather than use a get
* @param $object
* @param null $entity
*/
Expand Down Expand Up @@ -141,9 +139,10 @@ protected function processExclusions($object, $entity)

if ($property->getValue($object)) {
foreach ($property->getValue($object) as $i => $value) {
$v = $property->getValue($entity);
$this->processExclusions(
$value,
$property->getValue($entity)[$i]
$v[$i]
);
}
}
Expand Down
12 changes: 12 additions & 0 deletions Object/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ class Registry
{
protected $classes = array();

/**
* @param string $name
* @param string $class
*/
public function addClass($name, $class)
{
if (!class_exists($class)) {
Expand All @@ -18,6 +22,10 @@ public function getClasses()
return $this->classes;
}

/**
* @param string $name
* @return string
*/
public function getClass($name)
{
if (!$this->hasClass($name)) {
Expand All @@ -26,6 +34,10 @@ public function getClass($name)
return $this->classes[$name];
}

/**
* @param string $name
* @return bool
*/
public function hasClass($name)
{
return array_key_exists($name, $this->classes);
Expand Down
11 changes: 9 additions & 2 deletions Request/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use JMS\Serializer\SerializerInterface;
use Negotiation\NegotiatorInterface;
use Negotiation\FormatNegotiatorInterface;

class Handler
{
Expand All @@ -30,14 +30,21 @@ class Handler

public function __construct(
SerializerInterface $serializer,
NegotiatorInterface $negotiator,
FormatNegotiatorInterface $negotiator,
LoggerInterface $logger
) {
$this->serializer = $serializer;
$this->negotiator = $negotiator;
$this->logger = $logger;
}

/**
* @param Request $request
* @param Response $response
* @param string $class
* @param \Closure $callback
* @return Response
*/
public function handle(Request $request, Response $response, $class, $callback)
{
$format = $this->negotiator->getBestFormat(
Expand Down
Loading

0 comments on commit 2c65e49

Please sign in to comment.