Skip to content

Commit

Permalink
Fix minor CS violations
Browse files Browse the repository at this point in the history
Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Oct 25, 2024
1 parent 6400852 commit 24e0f52
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 64 deletions.
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
>
<arg value="ps" />
<!-- Paths to check -->
<file>src</file>
<file>test</file>
Expand Down
2 changes: 0 additions & 2 deletions src/Generator/ClassGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use function sprintf;
use function str_contains;
use function str_replace;
use function strpos;
use function strrpos;
use function strtolower;
use function substr;
Expand Down Expand Up @@ -185,7 +184,6 @@ public static function fromReflection(ClassReflection $classReflection)
* @configkey properties
* @configkey methods
* @throws Exception\InvalidArgumentException
* @param array $array
* @return static
*/
public static function fromArray(array $array)
Expand Down
1 change: 0 additions & 1 deletion src/Generator/DocBlockGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public static function fromReflection(DocBlockReflection $reflectionDocBlock)
* @configkey longdescription string The long description for this doc block
* @configkey tags array
* @throws Exception\InvalidArgumentException
* @param array $array
* @return DocBlockGenerator
*/
public static function fromArray(array $array)
Expand Down
1 change: 0 additions & 1 deletion src/Generator/FileGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public function __construct($options = null)
* @deprecated this API is deprecated, and will be removed in the next major release. Please
* use the other constructors of this class instead.
*
* @param array $values
* @return FileGenerator
*/
public static function fromArray(array $values)
Expand Down
1 change: 0 additions & 1 deletion src/Generator/InterfaceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public static function fromReflection(ClassReflection $classReflection)
* @configkey constants
* @configkey methods
* @throws Exception\InvalidArgumentException
* @param array $array
* @return static
*/
public static function fromArray(array $array)
Expand Down
1 change: 0 additions & 1 deletion src/Generator/MethodGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ protected static function clearBodyIndention($body)
* @configkey static bool
* @configkey visibility string
* @throws Exception\InvalidArgumentException
* @param array $array
* @return MethodGenerator
*/
public static function fromArray(array $array)
Expand Down
1 change: 0 additions & 1 deletion src/Generator/ParameterGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public static function fromReflection(ParameterReflection $reflectionParameter)
* @configkey sourcecontent string
* @configkey omitdefaultvalue bool
* @throws Exception\InvalidArgumentException
* @param array $array
* @return ParameterGenerator
*/
public static function fromArray(array $array)
Expand Down
1 change: 0 additions & 1 deletion src/Generator/PropertyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public static function fromReflection(PropertyReflection $reflectionProperty)
* @configkey omitdefaultvalue bool
* @configkey readonly bool
* @configkey type null|TypeGenerator
* @param array $array
* @return static
* @throws Exception\InvalidArgumentException
*/
Expand Down
1 change: 0 additions & 1 deletion src/Generator/TraitGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public static function fromReflection(ClassReflection $classReflection)
* @configkey properties
* @configkey methods
* @throws Exception\InvalidArgumentException
* @param array $array
* @return static
*/
public static function fromArray(array $array)
Expand Down
1 change: 0 additions & 1 deletion src/Generator/ValueGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class ValueGenerator extends AbstractGenerator
/** @var self::OUTPUT_* */
protected string $outputMode = self::OUTPUT_MULTIPLE_LINE;

/** @var array */
protected array $allowedTypes = [];

/**
Expand Down
112 changes: 58 additions & 54 deletions test/Reflection/ClassReflectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use PHPUnit\Framework\TestCase;

use function array_shift;
use function get_class;
use function trim;
use function uniqid;

Expand Down Expand Up @@ -69,67 +68,72 @@ public function testInterfaceReturn()
public function testGetContentsReturnsContents()
{
$reflectionClass = new ClassReflection(TestAsset\TestSampleClass2::class);
$target = <<<EOS
{
protected \$_prop1 = null;
/**
* @Sample({"foo":"bar"})
*/
protected \$_prop2 = null;

public function getProp1()
{
return \$this->_prop1;
}
public function getProp2(\$param1, TestSampleClass \$param2)
{
return \$this->_prop2;
}
public function getIterator(): \Traversable
{
return new \EmptyIterator();
}
}
EOS;
$contents = $reflectionClass->getContents();
// phpcs:disable SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly
$target = <<<EOS
{
protected \$_prop1 = null;
/**
* @Sample({"foo":"bar"})
*/
protected \$_prop2 = null;
public function getProp1()
{
return \$this->_prop1;
}
public function getProp2(\$param1, TestSampleClass \$param2)
{
return \$this->_prop2;
}
public function getIterator(): \Traversable
{
return new \EmptyIterator();
}
}
EOS;
$contents = $reflectionClass->getContents();
self::assertEquals(trim($target), trim($contents));
// phpcs:enable
}

public function testGetContentsReturnsContentsWithImplementsOnSeparateLine()
{
$reflectionClass = new ClassReflection(TestAsset\TestSampleClass9::class);
$target = <<<EOS
{
protected \$_prop1 = null;
/**
* @Sample({"foo":"bar"})
*/
protected \$_prop2 = null;
public function getProp1()
{
return \$this->_prop1;
}
public function getProp2(\$param1, TestSampleClass \$param2)
{
return \$this->_prop2;
}
public function getIterator(): \Traversable
{
return new \EmptyIterator();
}
}
EOS;
$contents = $reflectionClass->getContents();
// phpcs:disable SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly
$target = <<<EOS
{
protected \$_prop1 = null;
/**
* @Sample({"foo":"bar"})
*/
protected \$_prop2 = null;
public function getProp1()
{
return \$this->_prop1;
}
public function getProp2(\$param1, TestSampleClass \$param2)
{
return \$this->_prop2;
}
public function getIterator(): \Traversable
{
return new \EmptyIterator();
}
}
EOS;
$contents = $reflectionClass->getContents();
self::assertEquals(trim($target), trim($contents));
// phpcs:enable
}

public function testStartLine()
Expand Down

0 comments on commit 24e0f52

Please sign in to comment.