Skip to content

Commit

Permalink
CS Fix & PHPDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
jubianchi committed Jan 28, 2014
1 parent fd5d9d5 commit 7022976
Show file tree
Hide file tree
Showing 18 changed files with 378 additions and 73 deletions.
5 changes: 3 additions & 2 deletions Command/AtoumCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ protected function execute(InputInterface $input, OutputInterface $output)

$bundles = $input->getArgument('bundles');
if (count($bundles) > 0) {
$self = $this;
foreach ($bundles as $k => $bundleName) {
$bundles[$k] = $this->extractBundleConfigurationFromKernel($bundleName);
}
Expand All @@ -71,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

foreach ($bundles as $bundle) {
$directories = array_filter($bundle->getDirectories(), function($dir) {
$directories = array_filter($bundle->getDirectories(), function ($dir) {
return is_dir($dir);
});

Expand Down Expand Up @@ -129,6 +128,8 @@ protected function getAtoumArguments()
/**
* @param string $name name
*
* @throws \LogicException
*
* @return BundleConfiguration
*/
public function extractBundleConfigurationFromKernel($name)
Expand Down
14 changes: 11 additions & 3 deletions DependencyInjection/Compiler/BundleDirectoriesResolverPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
*/
class BundleDirectoriesResolverPass implements CompilerPassInterface
{
/**
* @param ContainerBuilder $container
*
* @throws \LogicException
*/
public function process(ContainerBuilder $container)
{
$bundles = $container->getParameter('kernel.bundles');
Expand All @@ -28,9 +33,12 @@ public function process(ContainerBuilder $container)
$rc = new \ReflectionClass($bundles[$bundleName]);
$directory = dirname($rc->getFileName());

$directories = array_map(function($v) use ($directory) {
return $directory.'/'.$v;
}, $data['directories']);
$directories = array_map(
function ($v) use ($directory) {
return $directory.'/'.$v;
},
$data['directories']
);

$definition = new Definition(
$container->getParameter('atoum.configuration.bundle.class'),
Expand Down
6 changes: 2 additions & 4 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$tb = new TreeBuilder();
$tb = new TreeBuilder();

return $tb
->root('atoum_atoum')
Expand All @@ -41,8 +41,6 @@ public function getConfigTreeBuilder()
->end()
->end()
->end()
;

return $tb;
;
}
}
27 changes: 24 additions & 3 deletions DomCrawler/DOMNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@

class DOMNode
{
/**
* @var \DOMNode|\Symfony\Component\DomCrawler\Crawler
*/
protected $node;

/**
* @param \DOMNode|\Symfony\Component\DomCrawler\Crawler $node
*
* @throws \InvalidArgumentException
*/
public function __construct($node)
{
if (($node instanceof Crawler || $node instanceof \DOMNode) === false) {
Expand All @@ -16,18 +24,29 @@ public function __construct($node)
$this->node = $node;
}

/**
* @return \DOMNode|\Symfony\Component\DomCrawler\Crawler
*/
public function getNode()
{
return $this->node;
}

/**
* @return string
*/
public function text()
{
$node = $this->getNode();

return $node instanceof \DOMNode ? $node->nodeValue : $node->text();
}

/**
* @param string $attribute
*
* @return null|string
*/
public function attr($attribute)
{
$node = $this->getNode();
Expand All @@ -37,8 +56,7 @@ public function attr($attribute)
$value = $node->getAttribute($attribute);
} else {
foreach ($node as $item) {
if ($item->hasAttribute($attribute))
{
if ($item->hasAttribute($attribute)) {
$value = $node->attr($attribute);
}

Expand All @@ -49,10 +67,13 @@ public function attr($attribute)
return $value;
}

/**
* @return \Symfony\Component\DomCrawler\Crawler
*/
public function children()
{
$node = $this->getNode();

return $node instanceof \DOMNode ? new Crawler($node->childNodes) : $node->children();
}
}
}
16 changes: 16 additions & 0 deletions Test/Asserters/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

class Crawler extends asserters\object
{
/**
* @param mixed $value
* @param bool $checkType
*
* @return $this
*/
public function setWith($value, $checkType = false)
{
parent::setWith($value, $checkType);
Expand All @@ -21,13 +27,23 @@ public function setWith($value, $checkType = false)
return $this;
}

/**
* @param string $element
*
* @return $this
*/
public function hasElement($element)
{
$asserter = new Element($this->generator, $this);

return $asserter->setWith($this->valueIsSet()->value->filter($element), $element);
}

/**
* @param mixed $value
*
* @return bool
*/
protected static function isCrawler($value)
{
return ($value instanceof \Symfony\Component\DomCrawler\Crawler);
Expand Down
Loading

0 comments on commit 7022976

Please sign in to comment.