Skip to content
This repository has been archived by the owner on Mar 29, 2021. It is now read-only.

Commit

Permalink
Add code of conduct and add psr12
Browse files Browse the repository at this point in the history
  • Loading branch information
hxtree committed Feb 13, 2021
1 parent 2bec8ee commit e953662
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 29 deletions.
8 changes: 4 additions & 4 deletions composer.json
Expand Up @@ -41,15 +41,15 @@
},
"scripts": {
"build": [
"php-cs-fixer fix --rules=@PSR2 --using-cache=no src/",
"php-cs-fixer fix --rules=@PSR2 --using-cache=no tests/"
"php-cs-fixer fix --rules=@PSR12 --using-cache=no src/",
"php-cs-fixer fix --rules=@PSR12 --using-cache=no tests/"
],
"test": [
"XDEBUG_MODE=coverage phpunit"
],
"fix-code": [
"php-cs-fixer fix --rules=@PSR2 --using-cache=no src/",
"php-cs-fixer fix --rules=@PSR2 --using-cache=no tests/"
"php-cs-fixer fix --rules=@PSR12 --using-cache=no src/",
"php-cs-fixer fix --rules=@PSR12 --using-cache=no tests/"
]
}
}
1 change: 1 addition & 0 deletions docs/index.rst
Expand Up @@ -66,6 +66,7 @@ Navigation
project/elements.rst
project/configuration.rst
project/security.rst
project/code-of-conduct.rst

Classes <api.rst>

Expand Down
86 changes: 86 additions & 0 deletions docs/project/code-of-conduct.rst
@@ -0,0 +1,86 @@
.. _code_of_conduct:

Contributor Covenant Code of Conduct
++++++++++++++++++++++++++++++++++++

Our Pledge
==========

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and
expression, level of experience, education, socio-economic status, nationality,
personal appearance, race, religion, or sexual identity and orientation.

Our Standards
=============

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members


Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others’ private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting


Our Responsibilities
====================

Maintainers are responsible for clarifying the standards of acceptable behavior
and are expected to take appropriate and fair corrective action in response to
any instances of unacceptable behavior.

Maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening,
offensive, or harmful.

Scope
=====

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

Enforcement
===========

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the Code of Conduct Committee at
<conduct@kernel.org>. All complaints will be reviewed and investigated
and will result in a response that is deemed necessary and appropriate
to the circumstances. The Code of Conduct Committee is obligated to
maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted
separately.

Attribution
===========

This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

Interpretation
==============

See the :ref:`code_of_conduct_interpretation` document for how the Linux
kernel community will be interpreting this document.
4 changes: 2 additions & 2 deletions src/ArgumentArray.php
Expand Up @@ -34,7 +34,7 @@ class ArgumentArray implements
* Returns count of containers
* @return int
*/
public function count() : int
public function count(): int
{
return count($this->container);
}
Expand Down Expand Up @@ -114,7 +114,7 @@ public function get(): array
*
* @param $array
*/
public function merge($array) : void
public function merge($array): void
{
$this->container = array_merge($array, $this->container);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Configuration.php
Expand Up @@ -29,9 +29,9 @@
*/
class Configuration implements ConfigurationInterface
{
const VERSION = 3;
const LOCAL_FILENAME = 'config.json';
const DIST_FILENAME = 'config.dist.json';
public const VERSION = 3;
public const LOCAL_FILENAME = 'config.json';
public const DIST_FILENAME = 'config.dist.json';

private $document;

Expand Down
2 changes: 1 addition & 1 deletion src/Contract/DocumentInterface.php
Expand Up @@ -26,4 +26,4 @@ public function __construct();
* @return bool
*/
public function loadSource(string $source): bool;
}
}
2 changes: 1 addition & 1 deletion src/Document.php
Expand Up @@ -23,7 +23,7 @@
*/
class Document extends DomDocument implements DocumentInterface
{
const DEFAULT_LANG = "en";
public const DEFAULT_LANG = "en";

/**
* Document constructor.
Expand Down
1 change: 0 additions & 1 deletion src/Element/AbstractElement.php
Expand Up @@ -24,7 +24,6 @@
*/
abstract class AbstractElement
{

// id used to reference object
public $element_id = 0;
// id used to load args
Expand Down
8 changes: 4 additions & 4 deletions src/Engine.php
Expand Up @@ -30,10 +30,10 @@
class Engine implements EngineInterface
{
// TODO: implement LivingMarkup const
const RETURN_CALL = 1;
public const RETURN_CALL = 1;

// marker attribute used by Engine to identify DOMElement during processing
const INDEX_ATTRIBUTE = '_ELEMENT_ID';
public const INDEX_ATTRIBUTE = '_ELEMENT_ID';

// Document Object Model (DOM)
public $dom;
Expand Down Expand Up @@ -339,7 +339,7 @@ private function instantiateElement(DOMElement $element, string $class_name): bo
*/
public function getElementArgs(DOMElement $element): ArgumentArray
{
$args = new ArgumentArray;
$args = new ArgumentArray();

// set attributes belonging to DOMElement as args
if ($element->hasAttributes()) {
Expand Down Expand Up @@ -407,7 +407,7 @@ public function setType($value = null, $type = 'string')
break;
case 'bool':
case 'boolean':
$value = (boolean)$value;
$value = (bool)$value;
break;
case 'null':
$value = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Entities.php
Expand Up @@ -21,7 +21,7 @@
*/
class Entities
{
const HTML5 = <<<'ENTITY'
public const HTML5 = <<<'ENTITY'
<!ENTITY aacute "&amp;#193">
<!ENTITY abreve "&amp;#258">
<!ENTITY ac "&amp;#8766">
Expand Down
60 changes: 60 additions & 0 deletions tests/src/Feature/SecurityTest.php
@@ -0,0 +1,60 @@
<?php
/*
* This file is part of the LivingMarkup package.
*
* (c) 2017-2021 Ouxsoft <contact@ouxsoft.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Ouxsoft\LivingMarkup\Tests\Feature;

use Ouxsoft\LivingMarkup\Factory\ProcessorFactory;
use Ouxsoft\LivingMarkup\Processor;
use PHPUnit\Framework\TestCase;

final class SecurityTest extends TestCase
{
/**
* @var Processor
*/
private $processor;

public function setUp(): void
{
$this->processor = ProcessorFactory::getInstance();
}

public function tearDown(): void
{
unset($this->processor);
}


public function testNoProcessFlag()
{
$this->processor->addElement([
'name' => 'Bitwise',
'xpath' => '//bitwise[process=true]',
'class_name' => 'Ouxsoft\LivingMarkup\Tests\Resource\Element\Bitwise'
]);

$this->processor->addRoutine([
'method' => 'onRender',
'description' => 'Execute while object is rendering',
'execute' => 'RETURN_CALL'
]);


$html = file_get_contents(TEST_DIR . 'Resource/inputs/index.html');

$test_results = $this->processor->parseString($html);

$this->assertStringMatchesFormatFile(
TEST_DIR . 'Resource/outputs/index.html',
$test_results
);
}

}
1 change: 0 additions & 1 deletion tests/src/Resource/Element/Bitwise.php
Expand Up @@ -18,7 +18,6 @@
*/
class Bitwise extends AbstractElement
{

/**
* Renders output of BitWise operator
*
Expand Down
1 change: 0 additions & 1 deletion tests/src/Unit/DocumentTest.php
Expand Up @@ -15,7 +15,6 @@

class DocumentTest extends TestCase
{

/**
* @covers \Ouxsoft\LivingMarkup\Document::loadSource
*/
Expand Down
1 change: 0 additions & 1 deletion tests/src/Unit/Element/AbstractElementTest.php
Expand Up @@ -15,7 +15,6 @@

class AbstractElementTest extends TestCase
{

/**
* @covers \Ouxsoft\LivingMarkup\Element\AbstractElement::getArgByName
*/
Expand Down
11 changes: 5 additions & 6 deletions tests/src/Unit/Element/ElementPoolTest.php
Expand Up @@ -18,13 +18,12 @@

class ElementPoolTest extends TestCase
{

/**
* @covers \Ouxsoft\LivingMarkup\Element\ElementPool::getIterator
*/
public function testGetIterator()
{
$pool = new ElementPool;
$pool = new ElementPool();
$this->assertTrue(($pool->getIterator() instanceof ArrayIterator));
}

Expand All @@ -33,7 +32,7 @@ public function testGetIterator()
*/
public function testGetPropertiesById()
{
$pool = new ElementPool;
$pool = new ElementPool();
$lhtml_element = new HelloWorld();
$pool->add($lhtml_element);
$this->assertIsArray($pool->getPropertiesById($lhtml_element->element_id));
Expand All @@ -44,7 +43,7 @@ public function testGetPropertiesById()
*/
public function testGetById()
{
$pool = new ElementPool;
$pool = new ElementPool();
$lhtml_element = new HelloWorld();
$pool->add($lhtml_element);
$this->assertTrue(($pool->getById($lhtml_element->element_id) instanceof AbstractElement));
Expand All @@ -57,7 +56,7 @@ public function testGetById()
*/
public function testAdd()
{
$pool = new ElementPool;
$pool = new ElementPool();
$lhtml_element = new HelloWorld();
$pool->add($lhtml_element);
$this->assertTrue(($pool->getById($lhtml_element->element_id) instanceof AbstractElement));
Expand All @@ -78,7 +77,7 @@ public function testCallRoutine()
*/
public function testCount()
{
$pool = new ElementPool;
$pool = new ElementPool();
$lhtml_element = new HelloWorld();
$pool->add($lhtml_element);
$this->assertCount(1, $pool);
Expand Down
1 change: 0 additions & 1 deletion tests/src/Unit/Exception/ExceptionTest.php
Expand Up @@ -15,7 +15,6 @@

class ExceptionTest extends TestCase
{

/**
* @covers \Ouxsoft\LivingMarkup\Exception\Exception::__construct
* @covers \Ouxsoft\LivingMarkup\Exception\Exception::getLog
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Unit/KernelTest.php
Expand Up @@ -25,7 +25,7 @@ class KernelTest extends TestCase
{
private $kernel;

public function setUp() : void
public function setUp(): void
{
$abstractFactory = new ConcreteFactory();

Expand All @@ -36,7 +36,7 @@ public function setUp() : void
$this->kernel = &$container['kernel'];
}

public function tearDown() : void
public function tearDown(): void
{
unset($this->kernel);
}
Expand Down

0 comments on commit e953662

Please sign in to comment.