Skip to content

Commit

Permalink
Fix PHPDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Aug 15, 2023
1 parent 22db58a commit f85ef38
Show file tree
Hide file tree
Showing 118 changed files with 351 additions and 48 deletions.
1 change: 0 additions & 1 deletion src/Phug/Ast/Ast/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ public function findChildren(callable $callback, $depth = null, $level = null)
$level = $level ?: 0;

foreach ($this->children as $child) {

/** @var NodeInterface $child */
if ($child->is($callback)) {
yield $child;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Phug\Parser\Node\AssignmentNode;
use Phug\Parser\Node\AttributeNode;
use Phug\Parser\NodeInterface;
use Phug\Util\AttributesStorage;
use Phug\Util\OrderableInterface;
use SplObjectStorage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Phug\Formatter\ElementInterface;
use Phug\Parser\Node\AttributeNode;
use Phug\Parser\NodeInterface;
use Phug\Util\OrderableInterface;

class AttributeNodeCompiler extends AbstractNodeCompiler
{
Expand Down
2 changes: 1 addition & 1 deletion src/Phug/Compiler/Compiler/NodeCompilerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
interface NodeCompilerInterface
{
/**
* @param $nodeList
* @param $nodeList
* @param ElementInterface $parent
*
* @return array
Expand Down
13 changes: 8 additions & 5 deletions src/Phug/Formatter/Formatter/AbstractFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ protected function getDebugInfo($element)
/**
* @param string|ElementInterface $element
* @param bool $noDebug
* @param $element
* @param $element
*
* @return string
*/
Expand Down Expand Up @@ -460,13 +460,16 @@ protected function formatDynamicValue($formattedName, $value)
return 'null';
}

if ($value instanceof ExpressionElement &&
in_array(($code = strtolower($value->getValue())), ['true', 'false', 'null', 'undefined'])
) {
return $code;
if ($value instanceof ExpressionElement) {
$code = strtolower($value->getValue());

if (in_array($code, ['true', 'false', 'null', 'undefined'])) {
return $code;
}
}

$code = $this->formatAssignmentValue($value);

if ($value instanceof ExpressionElement && $value->isEscaped()) {
return $this->exportHelper('array_escape', [$formattedName, $code]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Phug/Formatter/Formatter/Format/XmlFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ protected function formatMarkupElement(MarkupElement $element)

/**
* @param AssignmentContainerInterface|AttributesInterface|mixed $markup
* @param Closure(OrderedValue, OrderedValue): int $sorter
* @param Closure(OrderedValue, OrderedValue): int $sorter
*
* @return list<string>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function ($attributeAssignments) {
return function (&$attributes, $name, $value) use ($attributeAssignments) {
if (isset($name) && $name !== '') {
$result = $attributeAssignments($attributes, $name, $value);
if (($result !== null && $result !== false && ($result !== '' || $name !== 'class'))) {
if ($result !== null && $result !== false && ($result !== '' || $name !== 'class')) {
$attributes[$name] = $result;
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/Phug/Lexer/Lexer/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ public function scan($scanners, array $options = [])
$scanners = $this->filterScanners($scanners);

foreach ($scanners as $scanner) {

/** @var ScannerInterface $scanner */
$success = false;
foreach ($scanner->scan($this, $options) as $token) {
Expand All @@ -267,7 +266,7 @@ public function scan($scanners, array $options = [])
* If the second argument is true, it will throw an exception if none of the scanners
* produced any valid tokens. The reading also stops when the end of the input as been reached.
*
* @param $scanners
* @param $scanners
* @param bool $required
*
* @throws LexerException
Expand Down Expand Up @@ -346,9 +345,9 @@ public function createToken($className)
* in scanners as you can simply return it's value without having to check for it to be null.
*
*
* @param $className
* @param $pattern
* @param null $modifiers
* @param class-string $className
* @param string $pattern
* @param string|null $modifiers
*
* @return iterable
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Phug/Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ public function parse($input, $path = null)

foreach ($expandingNodes as $expandingNode) {
$current = $expandingNode;
while ($outerNode = $expandingNode->getOuterNode()) {

while ($outerNode = $expandingNode->getOuterNode()) {
/** @var NodeInterface $expandedNode */
$expandedNode = $outerNode;
$current->setOuterNode(null);
Expand Down
5 changes: 3 additions & 2 deletions src/Phug/Parser/Parser/Event/NodeEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Phug\Event;
use Phug\Parser\NodeInterface;
use Phug\ParserEvent;

class NodeEvent extends Event
{
Expand All @@ -12,8 +13,8 @@ class NodeEvent extends Event
/**
* NodeEvent constructor.
*
* @param $name
* @param NodeInterface $node
* @param ParserEvent::* $name
* @param NodeInterface $node
*/
public function __construct($name, NodeInterface $node)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Phug/Reader/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ public function peek($length = null, $start = null)
*
* Notice that ^ is automatically prepended to the pattern.
*
* @param string $pattern the regular expression without slashes or modifiers.
* @param string $modifiers the modifiers for the regular expression.
* @param string $ignoredSuffixes characters that are scanned, but don't end up in the consume length.
* @param string $pattern the regular expression without slashes or modifiers.
* @param string|null $modifiers the modifiers for the regular expression.
* @param string|null $ignoredSuffixes characters that are scanned, but don't end up in the consume length.
*
* @throws ReaderException
*
Expand Down
2 changes: 1 addition & 1 deletion src/Phug/Renderer/Renderer/CacheInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface CacheInterface
/**
* Return the cached file path after cache optional process.
*
* @param $path
* @param string $path
* @param string $input pug input
* @param callable $rendered method to compile the source into PHP
* @param bool $success
Expand Down
3 changes: 3 additions & 0 deletions src/Phug/Renderer/Renderer/Partial/Debug/DebuggerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ private function getRendererException($error, $code, $line, $offset, $source, $s

/**
* @return bool
*
* @codeCoverageIgnore
*/
private function hasColorSupport()
Expand All @@ -200,6 +201,7 @@ private function hasColorSupport()

/**
* @return bool
*
* @codeCoverageIgnore
*/
private function hasStdOutVt100Support()
Expand All @@ -211,6 +213,7 @@ private function hasStdOutVt100Support()

/**
* @return bool
*
* @codeCoverageIgnore
*/
private function isStdOutATTY()
Expand Down
4 changes: 2 additions & 2 deletions src/Phug/Renderer/Renderer/Profiler/LinkDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ private function initProperties($name, $events)
foreach ([
['current', EndLexEvent::class, 'lexing', [
'background' => '#7200c4',
'color' => 'white',
'color' => 'white',
]],
['current', HtmlEvent::class, 'rendering', [
'background' => '#648481',
'color' => 'white',
'color' => 'white',
]],
['previous', CompileEvent::class, '%s', [
'background' => '#ffff78',
Expand Down
1 change: 1 addition & 0 deletions src/Phug/Util/Util/OrderedValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Class OrderedValue.
*
* @template T
*
* @template-implements ValueTrait<T>
*/
class OrderedValue implements OrderableInterface
Expand Down
4 changes: 0 additions & 4 deletions src/Phug/Util/Util/Partial/OrderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

namespace Phug\Util\Partial;

use ArrayAccess;
use ArrayObject;
use Phug\Util\Collection;

trait OrderTrait
{
/**
Expand Down
1 change: 0 additions & 1 deletion tests/Phug/AbstractCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ protected function enableJsPhpize()
});

$compiler->attach(CompilerEvent::OUTPUT, function (Compiler\Event\OutputEvent $event) use ($compiler) {

/** @var JsPhpize $jsPhpize */
$jsPhpize = $compiler->getOption('jsphpize_engine');
$dependencies = $jsPhpize->compileDependencies();
Expand Down
4 changes: 4 additions & 0 deletions tests/Phug/Adapter/FileAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,9 @@ public function testCacheRenderString()
* @covers \Phug\Renderer\Adapter\FileAdapter::cacheDirectory
* @covers \Phug\Renderer\Adapter\FileAdapter::getCacheDirectory
* @covers \Phug\Renderer\Partial\Debug\DebuggerTrait::getDebuggedException
*
* @expectedException \RuntimeException
*
* @expectedExceptionCode 5
*/
public function testMissingDirectory()
Expand All @@ -594,7 +596,9 @@ public function testMissingDirectory()
* @covers \Phug\Renderer\Adapter\FileAdapter::cacheDirectory
* @covers \Phug\Renderer\Adapter\FileAdapter::cache
* @covers \Phug\Renderer\Adapter\FileAdapter::displayCached
*
* @expectedException \RuntimeException
*
* @expectedExceptionCode 6
*/
public function testReadOnlyDirectory()
Expand Down
8 changes: 8 additions & 0 deletions tests/Phug/Ast/NodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public function testGetChildAt()

/**
* @covers ::getChildAt
*
* @expectedException \Phug\AstException
*/
public function testGetChildAtWithInvalidOffset()
Expand Down Expand Up @@ -309,6 +310,7 @@ public function testRemoveChildAt()

/**
* @covers ::removeChildAt
*
* @expectedException \Phug\AstException
*/
public function testRemoveChildAtWithInvalidOffset()
Expand Down Expand Up @@ -447,7 +449,9 @@ public function testFindChildren()

/**
* @covers ::insertBefore
*
* @expectedException \Phug\AstException
*
* @expectedExceptionMessage Failed to insert before: Passed child is not a child of element to insert in
*/
public function testInsertBeforeWithBadSibling()
Expand Down Expand Up @@ -481,7 +485,9 @@ public function testInsertBefore()

/**
* @covers ::insertAfter
*
* @expectedException \Phug\AstException
*
* @expectedExceptionMessage Failed to insert after: Passed child is not a child of element to insert in
*/
public function testInsertAfterWithBadSibling()
Expand Down Expand Up @@ -562,7 +568,9 @@ public function testGetIterator()

/**
* @covers ::offsetSet
*
* @expectedException \InvalidArgumentException
*
* @expectedExceptionMessage Argument 2 passed to Node->offsetSet needs to be instance of Phug\Ast\NodeInterface
*/
public function testOffsetSetInvalidArgument()
Expand Down
2 changes: 2 additions & 0 deletions tests/Phug/CasesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public function caseProvider()

/**
* @group cases
*
* @dataProvider caseProvider
*
* @covers ::compileFile
* @covers ::render
*/
Expand Down
8 changes: 8 additions & 0 deletions tests/Phug/CliTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function finishTest()

/**
* @group cli
*
* @covers ::getCustomMethods
*/
public function testGetCustomMethods()
Expand Down Expand Up @@ -73,6 +74,7 @@ public function testGetCustomMethods()

/**
* @group cli
*
* @covers ::convertToKebabCase
* @covers ::convertToCamelCase
* @covers ::getNamedArgumentBySpaceDelimiter
Expand Down Expand Up @@ -104,6 +106,7 @@ public function testRun()

/**
* @group cli
*
* @covers ::convertToKebabCase
* @covers ::convertToCamelCase
* @covers ::execute
Expand Down Expand Up @@ -158,6 +161,7 @@ public function testListAvailableMethods()

/**
* @group cli
*
* @covers ::convertToKebabCase
* @covers ::convertToCamelCase
* @covers ::execute
Expand All @@ -175,6 +179,7 @@ public function testCallableActions()

/**
* @group cli
*
* @covers ::convertToKebabCase
* @covers ::convertToCamelCase
* @covers ::getNamedArgumentBySpaceDelimiter
Expand All @@ -196,6 +201,7 @@ public function testOptions()

/**
* @group cli
*
* @covers ::convertToKebabCase
* @covers ::convertToCamelCase
* @covers ::getNamedArgumentBySpaceDelimiter
Expand Down Expand Up @@ -258,6 +264,7 @@ public function testCacheDirectory()

/**
* @group cli
*
* @covers ::convertToKebabCase
* @covers ::convertToCamelCase
* @covers ::getNamedArgumentBySpaceDelimiter
Expand Down Expand Up @@ -298,6 +305,7 @@ public function testBootstrap()

/**
* @group cli
*
* @covers ::convertToKebabCase
* @covers ::convertToCamelCase
* @covers ::getNamedArgumentBySpaceDelimiter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function testCompileNode()

/**
* @covers ::<public>
*
* @expectedException \Phug\CompilerException
*/
public function testException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function testCompile()

/**
* @covers ::<public>
*
* @expectedException \Phug\CompilerException
*/
public function testException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function testCompileNode()

/**
* @covers ::<public>
*
* @expectedException \Phug\CompilerException
*/
public function testException()
Expand Down
Loading

0 comments on commit f85ef38

Please sign in to comment.