Skip to content

Commit

Permalink
Sort ordered_class_elements alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
phpfui committed Apr 28, 2023
1 parent 25f0f7b commit 01eb2de
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion PhpCsFixer.php
Expand Up @@ -192,7 +192,7 @@
// There should not be space before or after object operators `->` and `?->`.
'object_operator_without_whitespace' => true,
// Orders the elements of classes/interfaces/traits.
'ordered_class_elements' => ['order'=>['use_trait','constant_public','constant_protected','constant_private','property_public','property_protected','property_private','construct','destruct','magic','phpunit','method_public','method_protected','method_private']],
'ordered_class_elements' => ['sort_algorithm' => 'alpha'],
// Ordering `use` statements.
'ordered_imports' => true,
// Orders the interfaces in an `implements` or `interface extends` clause.
Expand Down
10 changes: 5 additions & 5 deletions src/PHPFUI/PHPUnitSyntaxCoverage/ClassFinder.php
Expand Up @@ -35,16 +35,16 @@ public function enterNode(int|\PhpParser\Node|null $node)
return $node;
}

public function getNamespace() : string
{
return $this->currentNamespace;
}

/**
* @return array<string>
*/
public function getClasses() : array
{
return $this->classes;
}

public function getNamespace() : string
{
return $this->currentNamespace;
}
}
76 changes: 38 additions & 38 deletions src/PHPFUI/PHPUnitSyntaxCoverage/Extensions.php
Expand Up @@ -14,6 +14,8 @@

class Extensions extends \PHPUnit\Framework\TestCase
{
private ?\PHPFUI\PHPUnitSyntaxCoverage\ClassFinder $classFinder = null;

private static \PhpParser\Parser $parser;

/**
Expand All @@ -30,8 +32,6 @@ class Extensions extends \PHPUnit\Framework\TestCase

private ?\PhpParser\NodeTraverser $traverser = null;

private ?\PHPFUI\PHPUnitSyntaxCoverage\ClassFinder $classFinder = null;

public static function setUpBeforeClass() : void
{
$factory = new \PhpParser\ParserFactory();
Expand All @@ -50,6 +50,32 @@ protected function tearDown() : void
$this->classFinder = null;
}

/**
* Exclude any file with this $directory string in the path.
*
* Only a simple stripos is used to match anything in the file name.
*
* You can add multiple skips.
*/
public function addSkipDirectory(string $directory) : self
{
$this->skipDirectories[] = $directory;

return $this;
}

/**
* Exclude namespace from namespace testing
*
* You can add multiple namespaces to skip.
*/
public function addSkipNamespace(string $namespace) : self
{
$this->skipNamespaces[] = $namespace;

return $this;
}

/**
* Assert a string containing valid PHP will parse.
*
Expand Down Expand Up @@ -87,42 +113,6 @@ public function assertValidPHP(string $code, string $message = '') : void
}
}

/**
* Exclude any file with this $directory string in the path.
*
* Only a simple stripos is used to match anything in the file name.
*
* You can add multiple skips.
*/
public function addSkipDirectory(string $directory) : self
{
$this->skipDirectories[] = $directory;

return $this;
}

/**
* Skip namespace testing
*/
public function skipNamespaceTesting() : self
{
$this->skipNamespaceTest = true;

return $this;
}

/**
* Exclude namespace from namespace testing
*
* You can add multiple namespaces to skip.
*/
public function addSkipNamespace(string $namespace) : self
{
$this->skipNamespaces[] = $namespace;

return $this;
}

/**
* Validate all files in a directory. Recursive and only looks at .php files by default.
*
Expand Down Expand Up @@ -200,4 +190,14 @@ public function assertValidPHPFile(string $fileName, string $message = '') : voi
}
}
}

/**
* Skip namespace testing
*/
public function skipNamespaceTesting() : self
{
$this->skipNamespaceTest = true;

return $this;
}
}

0 comments on commit 01eb2de

Please sign in to comment.