Skip to content

Commit

Permalink
applying updated ruleset
Browse files Browse the repository at this point in the history
  • Loading branch information
SignpostMarv committed Jan 20, 2020
1 parent c5250f2 commit 8a1650d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 45 deletions.
4 changes: 2 additions & 2 deletions Tests/ConverterTest.php
Expand Up @@ -475,7 +475,7 @@ public function dataProviderMarkupFactoryPlusMarkupStringToMarkupArray() : Gener
*
* @dataProvider dataProviderMarkupFactoryPlusMarkupArrayToMarkupString
*/
public function testMarkupArrayToMarkupString(
public function test_markup_array_to_markup_string(
string $class,
array $ctorargs,
string $expected,
Expand Down Expand Up @@ -506,7 +506,7 @@ public function testMarkupArrayToMarkupString(
*
* @dataProvider dataProviderMarkupFactoryPlusMarkupStringToMarkupArray
*/
public function testMarkupStringToMarkupArray(
public function test_markup_string_to_markup_array(
string $class,
array $ctorargs,
array $expected,
Expand Down
48 changes: 24 additions & 24 deletions Tests/DocumentTest.php
Expand Up @@ -45,7 +45,7 @@ public function dataProviderDocumentToString() : array
Document::class,
[],
null,
function (Document $doc) : void {
static function (Document $doc) : void {
$doc->SetTitle('Test');
$doc->asyncJs('./foo.js');
$doc->deferJs('./bar.js', './baz.js');
Expand Down Expand Up @@ -88,7 +88,7 @@ function (Document $doc) : void {
Document::class,
[],
null,
function (Document $doc) : void {
static function (Document $doc) : void {
$doc->SetMarkupConverter(new Markup());
$doc->SetTitle('Test');
$doc->SetTitleAttribute('Toast');
Expand Down Expand Up @@ -128,7 +128,7 @@ function (Document $doc) : void {
Document::class,
[],
null,
function (Document $doc, TestCase $test) : void {
static function (Document $doc, TestCase $test) : void {
$doc->SetMarkupConverter(new Markup());
$doc->SetTitle('Test');
$doc->Preload('script', './foo.js');
Expand Down Expand Up @@ -157,7 +157,7 @@ function (Document $doc, TestCase $test) : void {
Document::class,
[],
null,
function (Document $doc, TestCase $test) : void {
static function (Document $doc, TestCase $test) : void {
$doc->SetMarkupConverter(new Markup());
$doc->SetTitle('Test');
$doc->Preload('script', './foo.js');
Expand Down Expand Up @@ -188,7 +188,7 @@ function (Document $doc, TestCase $test) : void {
Document::class,
[],
null,
function (Document $doc, TestCase $test) : void {
static function (Document $doc, TestCase $test) : void {
$doc->SetMarkupConverter(new Markup());
$doc->SetTitle('Test');
$doc->Preload('script', './foo.js');
Expand All @@ -213,7 +213,7 @@ function (Document $doc, TestCase $test) : void {
Document::class,
[],
null,
function (Document $doc) : void {
static function (Document $doc) : void {
$doc->SetTitle('Test');
$doc->ApplyValueForDataAttribute('foo', 'bar');
$doc->SetTabIndex(-1);
Expand All @@ -235,7 +235,7 @@ function (Document $doc) : void {
Document::class,
[],
null,
function (Document $doc) : void {
static function (Document $doc) : void {
$doc->SetTitle('Test');
$doc->SetDraggable(true);
},
Expand All @@ -254,7 +254,7 @@ function (Document $doc) : void {
Document::class,
[],
null,
function (Document $doc) : void {
static function (Document $doc) : void {
$doc->SetTitle('Test');
$doc->SetDraggable(false);
},
Expand All @@ -273,7 +273,7 @@ function (Document $doc) : void {
Document::class,
[],
null,
function (Document $doc) : void {
static function (Document $doc) : void {
$doc->SetTitle('Test');
$doc->SetDraggable(null);
},
Expand All @@ -292,7 +292,7 @@ function (Document $doc) : void {
Document::class,
[],
null,
function (Document $doc) : void {
static function (Document $doc) : void {
$doc->SetTitle('Test');
$doc->SetSpellcheck(true);
},
Expand All @@ -311,7 +311,7 @@ function (Document $doc) : void {
Document::class,
[],
null,
function (Document $doc) : void {
static function (Document $doc) : void {
$doc->SetTitle('Test');
$doc->SetSpellcheck(false);
},
Expand All @@ -330,7 +330,7 @@ function (Document $doc) : void {
Document::class,
[],
null,
function (Document $doc) : void {
static function (Document $doc) : void {
$doc->SetTitle('Test');
$doc->SetSpellcheck(null);
},
Expand Down Expand Up @@ -543,19 +543,19 @@ public function dataProviderTestDefaults() : Generator
/**
* @dataProvider dataProviderDocumentInstance
*/
public function testIsAbstractHtmlElement(string $class) : void
public function test_is_abstract_html_element(string $class) : void
{
static::assertTrue(is_a($class, AbstractHtmlElement::class, true));
}

/**
* @dataProvider dataProviderDocumentInstance
*
* @depends testIsAbstractHtmlElement
* @depends test_is_abstract_html_element
*
* @param class-string<AbstractHtmlElement> $class
*/
public function testValidElementName(string $class) : void
public function test_valid_element_name(string $class) : void
{
static::assertRegExp(Markup::REGEX_ELEMENT_NAME, (string) ((new $class())->MarkupElementName()));
}
Expand All @@ -566,9 +566,9 @@ public function testValidElementName(string $class) : void
*
* @dataProvider dataProviderDocumentToString
*
* @depends testIsAbstractHtmlElement
* @depends test_is_abstract_html_element
*/
public function testDocumentToString(
public function test_document_to_string(
string $class,
array $ctorargs,
? array $content,
Expand Down Expand Up @@ -603,9 +603,9 @@ public function testDocumentToString(
*
* @dataProvider dataProviderBadDocumentToString
*
* @depends testIsAbstractHtmlElement
* @depends test_is_abstract_html_element
*/
public function testBadDocumentToString(
public function test_bad_document_to_string(
string $class,
array $ctorargs,
string $expectedExceptionClass,
Expand Down Expand Up @@ -636,9 +636,9 @@ public function testBadDocumentToString(
*
* @dataProvider dataProviderStringArrayMethods
*
* @depends testIsAbstractHtmlElement
* @depends test_is_abstract_html_element
*/
public function testStringArrayMethods(
public function test_string_array_methods(
string $class,
array $ctorargs,
string $methodSuffix,
Expand Down Expand Up @@ -688,9 +688,9 @@ public function testStringArrayMethods(
*
* @dataProvider dataProviderTestDefaults
*
* @depends testIsAbstractHtmlElement
* @depends test_is_abstract_html_element
*/
public function testTranslateDefault(string $class, string $methodSuffix, $expected) : void
public function test_translate_default(string $class, string $methodSuffix, $expected) : void
{
$doc = $this->AbstractHtmlElementFromCtorArgs($class);

Expand All @@ -708,7 +708,7 @@ public function testTranslateDefault(string $class, string $methodSuffix, $expec
*
* @dataProvider dataProviderDocumentInstance
*/
public function testDocumentDefaults(
public function test_document_defaults(
string $class,
array $ctorargs
) : void {
Expand Down
21 changes: 11 additions & 10 deletions Tests/ValidatorTest.php
Expand Up @@ -9,6 +9,7 @@
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use SignpostMarv\DaftMarkup\MarkupValidator;
use stdClass;
use Throwable;

class ValidatorTest extends TestCase
Expand Down Expand Up @@ -42,7 +43,7 @@ public function dataProvider_ValidateMarkup_failure() : array
*
* @dataProvider dataProvider_ValidateMarkup_failure
*/
public function test_ValidateMarkup_failure(
public function test_Validate_markup_failure(
array $content,
string $expected_exception,
string $expected_message
Expand Down Expand Up @@ -82,7 +83,7 @@ public function dataProvider_MaybeThrowWhenValidatingMarkup_failure() : array
*
* @dataProvider dataProvider_MaybeThrowWhenValidatingMarkup_failure
*/
public function test_MaybeThrowWhenValidatingMarkup_failure(
public function test_Maybe_throw_when_validating_markup_failure(
array $content,
string $expected_exception,
string $expected_message
Expand All @@ -105,7 +106,7 @@ public function dataProvider_ValidateMarkupAttributeName_failure() : array
'Attribute keys must be strings!',
],
[
new \stdClass(),
new stdClass(),
InvalidArgumentException::class,
'Attribute keys must be strings!',
],
Expand Down Expand Up @@ -138,7 +139,7 @@ public function dataProvider_ValidateMarkupAttributeName_failure() : array
*
* @dataProvider dataProvider_ValidateMarkupAttributeName_failure
*/
public function test_ValidateMarkupAttributeName_failure(
public function test_Validate_markup_attribute_name_failure(
$attr,
string $expected_exception,
string $expected_message
Expand All @@ -163,7 +164,7 @@ public function dataProvider_ValidateMarkupAttributeArrayValue_failure() : array
],
[
'class',
[new \stdClass()],
[new stdClass()],
InvalidArgumentException::class,
'Attribute class contained a non-scalar array value!',
],
Expand All @@ -181,7 +182,7 @@ public function dataProvider_ValidateMarkupAttributeArrayValue_failure() : array
*
* @dataProvider dataProvider_ValidateMarkupAttributeArrayValue_failure
*/
public function test_ValidateMarkupAttributeArrayValue_failure(
public function test_Validate_markup_attribute_array_value_failure(
string $attr,
array $value,
string $expected_exception,
Expand All @@ -207,7 +208,7 @@ public function dataProvider_ValidateMarkupAttributeValue_failure() : array
],
[
'id',
new \stdClass(),
new stdClass(),
InvalidArgumentException::class,
'Attribute id contained a non-scalar value!',
],
Expand All @@ -220,7 +221,7 @@ public function dataProvider_ValidateMarkupAttributeValue_failure() : array
*
* @dataProvider dataProvider_ValidateMarkupAttributeValue_failure
*/
public function test_ValidateMarkupAttributeValue_failure(
public function test_Validate_markup_attribute_value_failure(
string $attr,
$value,
string $expected_exception,
Expand Down Expand Up @@ -269,7 +270,7 @@ public function dataProvider_ValidateContent_failure() : array
'Element content must be specified as an array!',
],
[
new \stdClass(),
new stdClass(),
InvalidArgumentException::class,
'Element content must be specified as an array!',
],
Expand All @@ -287,7 +288,7 @@ public function dataProvider_ValidateContent_failure() : array
*
* @dataProvider dataProvider_ValidateContent_failure
*/
public function test_ValidateContent_failure(
public function test_Validate_content_failure(
$markup_content,
string $expected_exception,
string $expected_message
Expand Down
4 changes: 2 additions & 2 deletions src/AbstractHtmlElement.php
Expand Up @@ -118,13 +118,13 @@ protected function GroupedAttributes() : array
* @var list<T2>
*/
$groupedAttributes = array_map(
function (array $group) : array {
static function (array $group) : array {
return array_filter(
$group,
/**
* @param mixed $value
*/
function ($value) : bool {
static function ($value) : bool {
return ! is_null($value);
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/Html/AbstractHtmlDocument.php
Expand Up @@ -268,7 +268,7 @@ protected function HeadContentMarkupArray() : array
array_map([$this, 'PreloadsToMarkupArrayMapper'], array_keys($this->preloads)),
array_map([$this, 'StylesheetsToMarkupArrayMapper'], $this->stylesheets),
array_map(
function (array $meta) : array {
static function (array $meta) : array {
return ['!element' => 'meta', '!attributes' => $meta];
},
$this->metas
Expand Down
2 changes: 1 addition & 1 deletion src/Html/DocumentUtilities.php
Expand Up @@ -20,7 +20,7 @@ public static function ExcludeUrls(array $existing, string ...$urls) : array
/**
* @var list<string>
*/
$out = array_filter($existing, function (string $url) use ($urls) : bool {
$out = array_filter($existing, static function (string $url) use ($urls) : bool {
return ! in_array($url, $urls, self::BOOL_IN_ARRAY_STRICT);
});

Expand Down
4 changes: 2 additions & 2 deletions src/Markup.php
Expand Up @@ -307,7 +307,7 @@ protected function NodeListToContent(
*/
$filtered_nodes = array_filter(
iterator_to_array($nodes),
function (DOMNode $maybe) : bool {
static function (DOMNode $maybe) : bool {
return ($maybe instanceof DOMElement) || ($maybe instanceof DOMText);
}
);
Expand Down Expand Up @@ -336,7 +336,7 @@ function (
},
$filtered_nodes
),
function (array $out, array $childOut) : array {
static function (array $out, array $childOut) : array {
if ( ! isset($childOut['!element'])) {
$out = array_merge($out, $childOut);
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/MarkupUtilities.php
Expand Up @@ -93,7 +93,7 @@ public static function FilteredArrayFromDOMNamedNodeMap(
) : array {
return array_values(array_filter(
static::FilterDOMNamedNodeMapToAttrs($attributes),
function (DOMAttr $attr) use ($node, $keepElements, $generalAttrWhitelist) : bool {
static function (DOMAttr $attr) use ($node, $keepElements, $generalAttrWhitelist) : bool {
return static::FilterDOMAttr($node, $attr, $keepElements, $generalAttrWhitelist);
}
));
Expand Down Expand Up @@ -121,7 +121,7 @@ public static function ObtainAttributesFromDOMNamedNodeMap(
$keepElements,
$generalAttrWhitelist
),
function (array $out, DOMAttr $attr) : array {
static function (array $out, DOMAttr $attr) : array {
$out[$attr->name] = $attr->value;

if (
Expand All @@ -147,7 +147,7 @@ function (array $out, DOMAttr $attr) : array {
*/
protected static function FilterDOMNamedNodeMapToAttrs(DOMNamedNodeMap $attributes) : array
{
return array_filter(iterator_to_array($attributes), function (DOMNode $attr) : bool {
return array_filter(iterator_to_array($attributes), static function (DOMNode $attr) : bool {
return $attr instanceof DOMAttr;
});
}
Expand Down

0 comments on commit 8a1650d

Please sign in to comment.