Permalink
Browse files

Fixed some phpdoc and CS

  • Loading branch information...
stof committed Sep 14, 2012
1 parent d189198 commit a6baab9b4c4361aca51bf90ee47c1586dff3cb0c
@@ -72,7 +72,9 @@ public function removeLeaf(AssetInterface $needle, $graceful = false)
unset($this->clones[$asset], $this->assets[$i]);
return true;
- } elseif ($asset instanceof AssetCollectionInterface && $asset->removeLeaf($needle, true)) {
+ }
+
+ if ($asset instanceof AssetCollectionInterface && $asset->removeLeaf($needle, true)) {
return true;
}
}
@@ -93,7 +95,9 @@ public function replaceLeaf(AssetInterface $needle, AssetInterface $replacement,
$this->assets[$i] = $replacement;
return true;
- } elseif ($asset instanceof AssetCollectionInterface && $asset->replaceLeaf($needle, $replacement, true)) {
+ }
+
+ if ($asset instanceof AssetCollectionInterface && $asset->replaceLeaf($needle, $replacement, true)) {
return true;
}
}
@@ -36,7 +36,10 @@
/**
* Constructor.
*
- * @param array $filters Filters for the asset
+ * @param array $filters Filters for the asset
+ * @param string $sourceRoot The root directory
+ * @param string $sourcePath The asset path
+ * @param array $vars
*/
public function __construct($filters = array(), $sourceRoot = null, $sourcePath = null, array $vars = array())
{
@@ -30,6 +30,7 @@ class FileAsset extends BaseAsset
* @param array $filters An array of filters
* @param string $sourceRoot The source asset root directory
* @param string $sourcePath The source asset path
+ * @param array $vars
*
* @throws \InvalidArgumentException If the supplied root doesn't match the source when guessing the path
*/
@@ -55,8 +56,7 @@ public function __construct($source, $filters = array(), $sourceRoot = null, $so
public function load(FilterInterface $additionalFilter = null)
{
- $source = PathUtils::resolvePath($this->source, $this->getVars(),
- $this->getValues());
+ $source = PathUtils::resolvePath($this->source, $this->getVars(), $this->getValues());
if (!is_file($source)) {
throw new \RuntimeException(sprintf('The source file "%s" does not exist.', $source));
@@ -67,8 +67,7 @@ public function load(FilterInterface $additionalFilter = null)
public function getLastModified()
{
- $source = PathUtils::resolvePath($this->source, $this->getVars(),
- $this->getValues());
+ $source = PathUtils::resolvePath($this->source, $this->getVars(), $this->getValues());
if (!is_file($source)) {
throw new \RuntimeException(sprintf('The source file "%s" does not exist.', $source));
@@ -31,6 +31,7 @@ class GlobAsset extends AssetCollection
* @param string|array $globs A single glob path or array of paths
* @param array $filters An array of filters
* @param string $root The root directory
+ * @param array $vars
*/
public function __construct($globs, $filters = array(), $root = null, array $vars = array())
{
@@ -28,8 +28,10 @@ class HttpAsset extends BaseAsset
/**
* Constructor.
*
- * @param string $sourceUrl The source URL
- * @param array $filters An array of filters
+ * @param string $sourceUrl The source URL
+ * @param array $filters An array of filters
+ * @param Boolean $ignoreErrors
+ * @param array $vars
*
* @throws \InvalidArgumentException If the first argument is not an URL
*/
@@ -53,12 +55,13 @@ public function __construct($sourceUrl, $filters = array(), $ignoreErrors = fals
public function load(FilterInterface $additionalFilter = null)
{
if (false === $content = @file_get_contents(PathUtils::resolvePath(
- $this->sourceUrl, $this->getVars(), $this->getValues()))) {
+ $this->sourceUrl, $this->getVars(), $this->getValues()))
+ ) {
if ($this->ignoreErrors) {
return;
- } else {
- throw new \RuntimeException(sprintf('Unable to load asset from URL "%s"', $this->sourceUrl));
}
+
+ throw new \RuntimeException(sprintf('Unable to load asset from URL "%s"', $this->sourceUrl));
}
$this->doLoad($content, $additionalFilter);
@@ -57,6 +57,8 @@ public function has($name)
*
* @param string $name The asset name
* @param AssetInterface $asset The asset
+ *
+ * @throws \InvalidArgumentException If tthe asset name is invalid
*/
public function set($name, AssetInterface $asset)
{
@@ -30,6 +30,9 @@ class AssetWriter
* Constructor.
*
* @param string $dir The base web directory
+ * @param array $varValues
+ *
+ * @throws \InvalidArgumentException if a variable value is not a string
*/
public function __construct($dir, array $varValues = array())
{
@@ -43,6 +43,8 @@ public function load(ResourceInterface $resource)
/**
* Loads assets from the supplied node.
*
+ * @param \Twig_Node $node
+ *
* @return array An array of asset formulae indexed by name
*/
private function loadNode(\Twig_Node $node)
@@ -40,7 +40,6 @@ class AssetFactory
* Constructor.
*
* @param string $root The default root directory
- * @param string $output The default output string
* @param Boolean $debug Filters prefixed with a "?" will be omitted in debug mode
*/
public function __construct($root, $debug = false)
@@ -286,11 +285,12 @@ protected function parseInput($input, array $options = array())
$path = $input;
$input = $this->root.'/'.$path;
}
+
if (false !== strpos($input, '*')) {
return $this->createGlobAsset($input, $root, $options['vars']);
- } else {
- return $this->createFileAsset($input, $root, $path, $options['vars']);
}
+
+ return $this->createFileAsset($input, $root, $path, $options['vars']);
}
protected function createAssetCollection(array $assets = array(), array $options = array())
@@ -338,6 +338,8 @@ protected function getFilter($name)
* collection itself.
*
* @param AssetCollectionInterface $asset An asset collection
+ *
+ * @return AssetCollectionInterface
*/
private function applyWorkers(AssetCollectionInterface $asset)
{
@@ -121,9 +121,9 @@ public function accept()
if ($file->isDir()) {
return '.' != $name[0];
- } else {
- return null === $this->pattern || 0 < preg_match($this->pattern, $name);
}
+
+ return null === $this->pattern || 0 < preg_match($this->pattern, $name);
}
public function getChildren()
@@ -21,12 +21,14 @@
/**
* Filters all references -- url() and "@import" -- through a callable.
*
- * @param string $content The CSS
- * @param mixed $callback A PHP callable
+ * @param string $content The CSS
+ * @param callable $callback A PHP callable
+ * @param integer $limit
+ * @param integer $count
*
* @return string The filtered CSS
*/
- protected function filterReferences($content, $callback, $limit = -1, & $count = 0)
+ protected function filterReferences($content, $callback, $limit = -1, &$count = 0)
{
$content = $this->filterUrls($content, $callback, $limit, $count);
$content = $this->filterImports($content, $callback, $limit, $count, false);
@@ -38,30 +40,30 @@ protected function filterReferences($content, $callback, $limit = -1, & $count =
/**
* Filters all CSS url()'s through a callable.
*
- * @param string $content The CSS
- * @param mixed $callback A PHP callable
- * @param integer $limit Limit the number of replacements
- * @param integer $count Will be populated with the count
+ * @param string $content The CSS
+ * @param callable $callback A PHP callable
+ * @param integer $limit Limit the number of replacements
+ * @param integer $count Will be populated with the count
*
* @return string The filtered CSS
*/
- protected function filterUrls($content, $callback, $limit = -1, & $count = 0)
+ protected function filterUrls($content, $callback, $limit = -1, &$count = 0)
{
return preg_replace_callback('/url\((["\']?)(?P<url>.*?)(\\1)\)/', $callback, $content, $limit, $count);
}
/**
* Filters all CSS imports through a callable.
*
- * @param string $content The CSS
- * @param mixed $callback A PHP callable
- * @param integer $limit Limit the number of replacements
- * @param integer $count Will be populated with the count
- * @param Boolean $includeUrl Whether to include url() in the pattern
+ * @param string $content The CSS
+ * @param callable $callback A PHP callable
+ * @param integer $limit Limit the number of replacements
+ * @param integer $count Will be populated with the count
+ * @param Boolean $includeUrl Whether to include url() in the pattern
*
* @return string The filtered CSS
*/
- protected function filterImports($content, $callback, $limit = -1, & $count = 0, $includeUrl = true)
+ protected function filterImports($content, $callback, $limit = -1, &$count = 0, $includeUrl = true)
{
$pattern = $includeUrl
? '/@import (?:url\()?(\'|"|)(?P<url>[^\'"\)\n\r]*)\1\)?;?/'
@@ -73,14 +75,14 @@ protected function filterImports($content, $callback, $limit = -1, & $count = 0,
/**
* Filters all IE filters (AlphaImageLoader filter) through a callable.
*
- * @param string $content The CSS
- * @param mixed $callback A PHP callable
- * @param integer $limit Limit the number of replacements
- * @param integer $count Will be populated with the count
+ * @param string $content The CSS
+ * @param callable $callback A PHP callable
+ * @param integer $limit Limit the number of replacements
+ * @param integer $count Will be populated with the count
*
* @return string The filtered CSS
*/
- protected function filterIEFilters($content, $callback, $limit = -1, & $count = 0)
+ protected function filterIEFilters($content, $callback, $limit = -1, &$count = 0)
{
return preg_replace_callback('/src=(["\']?)(?<url>.*?)\\1/', $callback, $content, $limit, $count);
}
@@ -23,6 +23,10 @@ class CallablesFilter implements FilterInterface
private $loader;
private $dumper;
+ /**
+ * @param callable|null $loader
+ * @param callable|null $dumper
+ */
public function __construct($loader = null, $dumper = null)
{
$this->loader = $loader;
@@ -113,12 +113,11 @@ public function filterDump(AssetInterface $asset)
$code = $proc->run();
unlink($input);
- if (0 < $code) {
-
- if (127 === $code) {
- throw new \RuntimeException('Path to node executable could not be resolved.');
- }
+ if (127 === $code) {
+ throw new \RuntimeException('Path to node executable could not be resolved.');
+ }
+ if (0 < $code) {
throw FilterException::fromProcess($proc)->setInput($asset->getContent());
}
@@ -124,7 +124,9 @@ public function filterDump(AssetInterface $asset)
}
throw FilterException::fromProcess($proc)->setInput($asset->getContent());
- } elseif (!file_exists($output)) {
+ }
+
+ if (!file_exists($output)) {
throw new \RuntimeException('Error creating output file.');
}
@@ -95,7 +95,9 @@ protected function compress($content, $type, $options = array())
}
throw FilterException::fromProcess($proc)->setInput($content);
- } elseif (!file_exists($output)) {
+ }
+
+ if (!file_exists($output)) {
throw new \RuntimeException('Error creating output file.');
}

0 comments on commit a6baab9

Please sign in to comment.