From c046165333477a408b78aa9a485f980c4c012796 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 30 Jun 2022 21:01:53 +0200 Subject: [PATCH 01/12] build: delete unused files --- .editorconfig | 12 -- .php_cs.dist | 120 ------------- .travis.yml | 49 ------ CONDUCT.md | 73 -------- README-ES.md | 327 ------------------------------------ tests/ScriptsTest.php | 316 ---------------------------------- tests/StylesTest.php | 214 ----------------------- tests/UnifyFilesTest.php | 287 ------------------------------- tests/assets/css/custom.css | 3 - tests/assets/css/style.css | 4 - tests/assets/js/custom.js | 3 - tests/assets/js/script.js | 3 - 12 files changed, 1411 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .php_cs.dist delete mode 100644 .travis.yml delete mode 100644 CONDUCT.md delete mode 100644 README-ES.md delete mode 100644 tests/ScriptsTest.php delete mode 100644 tests/StylesTest.php delete mode 100644 tests/UnifyFilesTest.php delete mode 100644 tests/assets/css/custom.css delete mode 100644 tests/assets/css/style.css delete mode 100644 tests/assets/js/custom.js delete mode 100644 tests/assets/js/script.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index d672f69..0000000 --- a/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -root = true - -[*] -charset = utf-8 -indent_size = 4 -indent_style = space -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -trim_trailing_whitespace = false diff --git a/.php_cs.dist b/.php_cs.dist deleted file mode 100644 index 6735b7d..0000000 --- a/.php_cs.dist +++ /dev/null @@ -1,120 +0,0 @@ -setRiskyAllowed(true) - ->setRules(array( - '@PSR2' => true, - 'array_syntax' => ['syntax' => 'short'], - 'binary_operator_spaces' => ['align_equals' => false, 'align_double_arrow' => false], - 'blank_line_after_opening_tag' => true, - 'blank_line_after_namespace' => false, - 'blank_line_before_return' => true, - 'cast_spaces' => true, -// 'class_keyword_remove' => true, - 'combine_consecutive_unsets' => true, - 'concat_space' => ['spacing' => 'one'], - 'declare_equal_normalize' => true, - 'declare_strict_types' => false, - 'dir_constant' => true, - 'ereg_to_preg' => true, - 'function_typehint_space' => true, -// 'general_phpdoc_annotation_remove' => ['author', 'category', 'package', 'copyright', 'version'], - 'hash_to_slash_comment' => true, - 'heredoc_to_nowdoc' => true, - 'include' => true, - 'indentation_type' => true, -// 'is_null' => ['use_yoda_style' => false], - 'linebreak_after_opening_tag' => true, - 'lowercase_cast' => true, -// 'mb_str_functions' => true, - 'method_separation' => true, - 'modernize_types_casting' => true, - 'native_function_casing' => true, -// 'native_function_invocation' => true, - 'new_with_braces' => false, // - 'no_alias_functions' => true, - 'no_blank_lines_after_class_opening' => true, - 'no_blank_lines_after_phpdoc' => true, - 'no_blank_lines_before_namespace' => true, - 'no_empty_comment' => true, - 'no_empty_phpdoc' => true, - 'no_empty_statement' => true, - 'no_extra_consecutive_blank_lines' => ['break', 'continue', 'curly_brace_block', 'extra', 'parenthesis_brace_block', 'return', 'square_brace_block', 'throw', 'use', 'useTrait'], - 'no_leading_import_slash' => true, - 'no_leading_namespace_whitespace' => true, - 'no_mixed_echo_print' => ['use' => 'echo'], - 'no_multiline_whitespace_around_double_arrow' => true, - 'no_multiline_whitespace_before_semicolons' => true, - 'no_php4_constructor' => true, - 'no_short_bool_cast' => true, - 'no_short_echo_tag' => false, - 'no_singleline_whitespace_before_semicolons' => true, - 'no_spaces_around_offset' => true, - 'no_trailing_comma_in_list_call' => true, - 'no_trailing_comma_in_singleline_array' => true, - 'no_trailing_whitespace' => true, - 'no_trailing_whitespace_in_comment' => true, - 'no_unneeded_control_parentheses' => true, - 'no_unreachable_default_argument_value' => true, - 'no_unused_imports' => true, - 'no_useless_else' => true, - 'no_useless_return' => true, - 'no_whitespace_before_comma_in_array' => true, - 'no_whitespace_in_blank_line' => true, - 'normalize_index_brace' => true, - 'not_operator_with_space' => false, - 'not_operator_with_successor_space' => true, - 'object_operator_without_whitespace' => true, - 'ordered_class_elements' => true, - 'ordered_imports' => true, - 'php_unit_construct' => true, - 'php_unit_dedicate_assert' => true, - 'php_unit_fqcn_annotation' => true, - 'php_unit_strict' => true, -// 'phpdoc_add_missing_param_annotation' => true, - 'phpdoc_align' => true, - 'phpdoc_annotation_without_dot' => true, - 'phpdoc_indent' => true, - 'phpdoc_inline_tag' => true, - 'phpdoc_no_access' => true, - 'phpdoc_no_alias_tag' => ['property-read' => 'property', 'property-write' => 'property', 'type' => 'var'], - 'phpdoc_no_empty_return' => true, - 'phpdoc_no_package' => true, -// 'phpdoc_no_useless_inheritdoc' => true, - 'phpdoc_order' => true, - 'phpdoc_return_self_reference' => true, - 'phpdoc_scalar' => true, - 'phpdoc_separation' => false, - 'phpdoc_single_line_var_spacing' => true, -// 'phpdoc_summary' => true, - 'phpdoc_to_comment' => true, - 'phpdoc_trim' => true, - 'phpdoc_types' => true, - 'phpdoc_var_without_name' => true, - 'pow_to_exponentiation' => true, -// 'pre_increment' => true, - 'protected_to_private' => true, - 'psr0' => true, - 'psr4' => true, - 'random_api_migration' => true, - 'return_type_declaration' => ['space_before' => 'one'], - 'self_accessor' => true, - 'short_scalar_cast' => true, -// 'silenced_deprecation_error' => true, -// 'simplified_null_return' => true, - 'single_blank_line_before_namespace' => false, - 'single_quote' => true, - 'space_after_semicolon' => true, - 'standardize_not_equals' => true, -// 'strict_comparison' => true, - 'ternary_operator_spaces' => true, - 'strict_param' => true, - 'ternary_to_null_coalescing' => false, -// 'trailing_comma_in_multiline_array' => true, - 'trim_array_spaces' => true, - 'unary_operator_spaces' => true, - 'whitespace_after_comma_in_array' => true - )) - ->setFinder( - PhpCsFixer\Finder::create() - ->in(__DIR__) - )->setLineEnding("\n"); diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0e8345d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: php - -sudo: false - -cache: - directories: - - $HOME/.composer/cache - -dist: trusty - -branches: - only: - - master - -git: - depth: 5 - -php: - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - hhvm - - nightly - -matrix: - fast_finish: true - include: - - php: 7.1 - env: PHPCS=PSR2 - - allow_failures: - - php: nightly - -before_script: - - export PATH="./vendor/bin:$PATH" - - travis_retry composer self-update - - travis_retry composer install --no-interaction --prefer-source --dev - -script: - - phpunit - - | - if [[ "$PHPCS" ]] ; then - phpcs --standard=phpcs.xml $(find . -name '*.php') - phpmd src,tests text ./phpmd.xml - fi - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/CONDUCT.md b/CONDUCT.md deleted file mode 100644 index 30f74c5..0000000 --- a/CONDUCT.md +++ /dev/null @@ -1,73 +0,0 @@ -# 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, gender identity and expression, level of experience, -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 - -Project 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. - -Project 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 project team at [INSERT EMAIL ADDRESS]. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html - -[homepage]: https://www.contributor-covenant.org diff --git a/README-ES.md b/README-ES.md deleted file mode 100644 index 5015d10..0000000 --- a/README-ES.md +++ /dev/null @@ -1,327 +0,0 @@ -# PHP Asset library - -[![Latest Stable Version](https://poser.pugx.org/josantonius/Asset/v/stable)](https://packagist.org/packages/josantonius/Asset) [![Latest Unstable Version](https://poser.pugx.org/josantonius/Asset/v/unstable)](https://packagist.org/packages/josantonius/Asset) [![License](https://poser.pugx.org/josantonius/Asset/license)](LICENSE) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/d93b5c9ef2784bc7a4d1577f0835c41d)](https://www.codacy.com/app/Josantonius/PHP-Asset?utm_source=github.com&utm_medium=referral&utm_content=Josantonius/PHP-Asset&utm_campaign=Badge_Grade) [![Total Downloads](https://poser.pugx.org/josantonius/Asset/downloads)](https://packagist.org/packages/josantonius/Asset) [![Travis](https://travis-ci.org/Josantonius/PHP-Asset.svg)](https://travis-ci.org/Josantonius/PHP-Asset) [![PSR2](https://img.shields.io/badge/PSR-2-1abc9c.svg)](http://www.php-fig.org/psr/psr-2/) [![PSR4](https://img.shields.io/badge/PSR-4-9b59b6.svg)](http://www.php-fig.org/psr/psr-4/) [![CodeCov](https://codecov.io/gh/Josantonius/PHP-Asset/branch/master/graph/badge.svg)](https://codecov.io/gh/Josantonius/PHP-Asset) - -[English version](README.md) - -Biblioteca PHP para manejo de estilos y scripts; Añadir, minimizar, unificar e imprimir. - ---- - -- [Requisitos](#requisitos) -- [Instalación](#instalación) -- [Métodos disponibles](#métodos-disponibles) -- [Cómo empezar](#cómo-empezar) -- [Uso](#uso) -- [Tests](#tests) -- [Tareas pendientes](#-tareas-pendientes) -- [Contribuir](#contribuir) -- [Repositorio](#repositorio) -- [Licencia](#licencia) -- [Copyright](#copyright) - ---- - -## Requisitos - -Esta clase es soportada por versiones de **PHP 5.6** o superiores y es compatible con versiones de **HHVM 3.0** o superiores. - -## Instalación - -La mejor forma de instalar esta extensión es a través de [Composer](http://getcomposer.org/download/). - -Para instalar **PHP Asset library**, simplemente escribe: - - $ composer require Josantonius/Asset - -El comando anterior sólo instalará los archivos necesarios, si prefieres **descargar todo el código fuente** puedes utilizar: - - $ composer require Josantonius/Asset --prefer-source - -También puedes **clonar el repositorio** completo con Git: - - $ git clone https://github.com/Josantonius/PHP-Asset.git - -O **instalarlo manualmente**: - -[Descargar Asset.php](https://raw.githubusercontent.com/Josantonius/PHP-Asset/master/src/Asset.php): - - $ wget https://raw.githubusercontent.com/Josantonius/PHP-Asset/master/src/Asset.php - -[Descargar Json.php](https://raw.githubusercontent.com/Josantonius/PHP-Json/master/src/Json.php): - - $ wget https://raw.githubusercontent.com/Josantonius/PHP-Json/master/src/Json.php - -## Métodos disponibles - -Métodos disponibles en esta biblioteca: - -### - Agregar scripts o estilos: - -```php -Asset::add($type, $data); -``` - -| Atributo | Descripción | Tipo | Requerido | Predeterminado -| --- | --- | --- | --- | --- | -| $type | 'script' o 'style' | string | Sí | | - -| Atributo | clave | Descripción | Tipo | Requerido | Predeterminado -| --- | --- | --- | --- | --- | --- | -| $data | | Settings | array | Sí | | -| | name | ID único | string | Sí | | -| | url | URL del archivo | string | Sí | | -| | version | Versión | string | No | false | -| | footer | **Solo para scripts** - Fijar en footer | boolean | No | true | -| | attr | **Solo para scripts** - Atributo (defer/sync) | string | No | | - -**# Return** (boolean) - -### - Comprobar si se ha añadido un estilo o script en particular: - -```php -Asset::isAdded($type, $name); -``` - -| Atributo | Descripción | Tipo | Requerido | Predeterminado -| --- | --- | --- | --- | --- | -| $type | 'script' o 'style' | string | Sí | | -| $name | ID único | string | Sí | | - -**# Return** (boolean) - -### - Eliminar script o estilo: - -```php -Asset::remove($type, $name); -``` - -| Atributo | Descripción | Tipo | Requerido | Predeterminado -| --- | --- | --- | --- | --- | -| $type | 'script' o 'style' | string | Sí | | -| $name | ID único | string | Sí | | - -**# Return** (boolean true) - -### - Unificar el contenido de los archivos en un único archivo: - -```php -Asset::unify($uniqueID, $params, $minify); -``` - -| Atributo | Descripción | Tipo | Requerido | Predeterminado -| --- | --- | --- | --- | --- | -| $uniqueID | Identificador único para el archivo unificado | string | Sí | | -| $params | Urls de ruta | mixed | Sí | | -| $minify | Minimizar el contenido del archivo | boolean | No | false | - -**# Return** (boolean true) - -### - Salida de hojas de estilos: - -```php -Asset::outputStyles($output); -``` - -| Atributo | Descripción | Tipo | Requerido | Predeterminado -| --- | --- | --- | --- | --- | -| $output | Salida para estilos | string | No | '' | - -**# Return** (string|false) → Estilos o false - -### - Salida de hojas de scripts: - -```php -Asset::outputScripts($place, $output); -``` - -| Atributo | Descripción | Tipo | Requerido | Predeterminado -| --- | --- | --- | --- | --- | -| $place | 'header' o 'footer' | string | Sí | | -| $output | Salida para scripts | string | No | '' | - -**# Return** (string|false) → Scripts o false - -## Cómo empezar - -Para utilizar esta clase con **Composer**: - -```php -require __DIR__ . '/vendor/autoload.php'; - -use Josantonius\Asset\Asset; -``` - -Si la instalaste **manualmente**, utiliza: - -```php -require_once __DIR__ . '/Asset.php'; -require_once __DIR__ . '/Json.php'; - -use Josantonius\Asset\Asset; -``` - -## Uso - -Ejemplo de uso para esta biblioteca: - -### - Agregar estilos: - -```php -Asset::add('style', [ - 'name' => 'style-first', - 'url' => 'http://josantonius.com/css/style.css', -]); - -Asset::add('style', [ - 'name' => 'style-second', - 'url' => 'http://josantonius.com/css/custom.css', - 'version' => '1.1.1' -]); -``` - -### - Agregar scripts: - -```php -Asset::add('script', [ - 'name' => 'script-first', - 'url' => 'http://josantonius.com/js/script.js', -]); - -Asset::add('script', [ - 'name' => 'script-second', - 'url' => 'http://josantonius.com/js/custom.js', - 'attr' => 'defer', - 'version' => '1.1.3', - 'footer' => false -]); -``` - -### - Verificar si los recursos se han añadido correctamente: - -```php -Asset::isAdded('script', 'script-first'); // true -Asset::isAdded('style', 'style-first'); // true -``` - -### - Borrar recursos añadidos: - -```php -Asset::remove('style', 'style-first') // true -Asset::remove('script', 'script-first'); // true -``` - -### - Unificar: - -```php -Asset::unify('UniqueID', 'http://josantonius.com/min/'); -``` - -### - Unificar y minimizar: - -```php -Asset::unify('UniqueID', 'http://josantonius.com/min/', true); -``` - -### - Unificar indicando diferentes rutas de urls para estilos y scripts: - -```php -Asset::unify('UniqueID', [ - - 'styles' => 'http://josantonius.com/min/css/', - 'scripts' => 'http://josantonius.com/min/js/' -]); -``` - -### - Unificar y minimizar indicando diferentes rutas de urls para estilos y scripts: - -```php -Asset::unify('UniqueID', [ - - 'styles' => 'http://josantonius.com/min/css/', - 'scripts' => 'http://josantonius.com/min/js/' - -], true); -``` - -### - Imprimir estilos: - -```php -echo Asset::outputStyles(); -``` - -### - Imprimir los scripts del footer: - -```php -echo Asset::outputScripts('footer'); -``` - -### - Imprimir los scripts del header: - -```php -echo Asset::outputScripts('header'); -``` - -## Tests - -Para ejecutar las [pruebas](tests) necesitarás [Composer](http://getcomposer.org/download/) y seguir los siguientes pasos: - - $ git clone https://github.com/Josantonius/PHP-Algorithm.git - - $ cd PHP-Algorithm - - $ composer install - -Ejecutar pruebas unitarias con [PHPUnit](https://phpunit.de/): - - $ composer phpunit - -Ejecutar pruebas de estándares de código [PSR2](http://www.php-fig.org/psr/psr-2/) con [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer): - - $ composer phpcs - -Ejecutar pruebas con [PHP Mess Detector](https://phpmd.org/) para detectar inconsistencias en el estilo de codificación: - - $ composer phpmd - -Ejecutar todas las pruebas anteriores: - - $ composer tests - -## ☑ Tareas pendientes - -- [ ] Añadir nueva funcionalidad. -- [ ] Mejorar pruebas. -- [ ] Mejorar documentación. -- [ ] Refactorizar código para las reglas de estilo de código deshabilitadas. Ver [phpmd.xml](phpmd.xml) y [.php_cs.dist](.php_cs.dist). - -## Contribuir - -Si deseas colaborar, puedes echar un vistazo a la lista de -[issues](https://github.com/Josantonius/PHP-Algorithm/issues) o [tareas pendientes](#-tareas-pendientes). - -**Pull requests** - -* [Fork and clone](https://help.github.com/articles/fork-a-repo). -* Ejecuta el comando `composer install` para instalar dependencias. - Esto también instalará las [dependencias de desarrollo](https://getcomposer.org/doc/03-cli.md#install). -* Ejecuta el comando `composer fix` para estandarizar el código. -* Ejecuta las [pruebas](#tests). -* Crea una nueva rama (**branch**), **commit**, **push** y envíame un - [pull request](https://help.github.com/articles/using-pull-requests). - -## Repositorio - -La estructura de archivos de este repositorio se creó con [PHP-Skeleton](https://github.com/Josantonius/PHP-Skeleton). - -## Licencia - -Este proyecto está licenciado bajo **licencia MIT**. Consulta el archivo [LICENSE](LICENSE) para más información. - -## Copyright - -2016 - 2018 Josantonius, [josantonius.com](https://josantonius.com/) - -Si te ha resultado útil, házmelo saber :wink: - -Puedes contactarme en [Twitter](https://twitter.com/Josantonius) o a través de mi [correo electrónico](mailto:hello@josantonius.com). \ No newline at end of file diff --git a/tests/ScriptsTest.php b/tests/ScriptsTest.php deleted file mode 100644 index e625f2f..0000000 --- a/tests/ScriptsTest.php +++ /dev/null @@ -1,316 +0,0 @@ - - * @copyright 2016 - 2018 (c) Josantonius - PHP-Assets - * @license https://opensource.org/licenses/MIT - The MIT License (MIT) - * @link https://github.com/Josantonius/PHP-Asset - * @since 1.1.5 - */ -namespace Josantonius\Asset; - -use PHPUnit\Framework\TestCase; - -/** - * Tests class for Asset library. - * - * @since 1.1.5 - */ -final class ScriptsTest extends TestCase -{ - /** - * Asset instance. - * - * @since 1.1.6 - * - * @var object - */ - protected $Asset; - - /** - * Assets url. - * - * @var string - */ - protected $assetsUrl; - - /** - * Set up. - */ - public function setUp() - { - parent::setUp(); - - $this->Asset = new Asset; - - $url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; - - $this->assetsUrl = 'https://' . $url; - } - - /** - * Check if it is an instance of Asset. - * - * @since 1.1.6 - */ - public function testIsInstanceOf() - { - $this->assertInstanceOf('\Josantonius\Asset\Asset', $this->Asset); - } - - /** - * Add script. - */ - public function testAddScript() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::add('script', [ - 'name' => 'script-first', - 'url' => $this->assetsUrl . 'js/script.js', - ]) - ); - } - - /** - * Add script with 'defer' attribute. - */ - public function testAddScriptWithDeferAttribute() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::add('script', [ - 'name' => 'script-second', - 'url' => $this->assetsUrl . 'js/script.js', - 'attr' => 'defer', - ]) - ); - } - - /** - * Add script with 'async' attribute. - */ - public function testAddScriptWithAsyncAttribute() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::add('script', [ - 'name' => 'script-third', - 'url' => $this->assetsUrl . 'js/custom.js', - 'attr' => 'async', - ]) - ); - } - - /** - * Add script in footer. - */ - public function testAddScriptInFooter() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::add('script', [ - 'name' => 'script-fourth', - 'url' => $this->assetsUrl . 'js/script.js', - 'footer' => true, - ]) - ); - } - - /** - * Add script in header. - */ - public function testAddScriptInHeader() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::add('script', [ - 'name' => 'script-fifth', - 'url' => $this->assetsUrl . 'js/custom.js', - 'footer' => false, - ]) - ); - } - - /** - * Add script by adding all options. - */ - public function testAddScriptAddingAllParams() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::add('script', [ - 'name' => 'script-sixth', - 'url' => $this->assetsUrl . 'js/script.js', - 'attr' => 'defer', - 'version' => '1.1.3', - 'footer' => true - ]) - ); - } - - /** - * Add script without specifying a name. [FALSE|ERROR] - */ - public function testAddScriptWithoutName() - { - $asset = $this->Asset; - - $this->assertFalse( - $asset::add('script', [ - 'url' => $this->assetsUrl . 'js/unknown.js', - 'attr' => 'defer', - ]) - ); - } - - /** - * Add script without specifying a url. [FALSE|ERROR] - */ - public function testAddScriptWithoutUrl() - { - $asset = $this->Asset; - - $this->assertFalse( - $asset::add('script', [ - 'name' => 'unknown', - 'attr' => 'defer', - ]) - ); - } - - /** - * Check if the scripts have been added correctly. - */ - public function testIfScriptsAddedCorrectly() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::isAdded('script', 'script-first') - ); - - $this->assertTrue( - $asset::isAdded('script', 'script-second') - ); - - $this->assertTrue( - $asset::isAdded('script', 'script-third') - ); - - $this->assertTrue( - $asset::isAdded('script', 'script-fourth') - ); - - $this->assertTrue( - $asset::isAdded('script', 'script-fifth') - ); - - $this->assertTrue( - $asset::isAdded('script', 'script-sixth') - ); - } - - /** - * Delete added styles. - */ - public function testRemoveAddedScripts() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::remove('script', 'script-first') - ); - - $this->assertTrue( - $asset::remove('script', 'script-second') - ); - } - - /** - * Validation after deletion. - */ - public function testValidationAfterDeletion() - { - $asset = $this->Asset; - - $this->assertFalse( - $asset::isAdded('script', 'script-first') - ); - - $this->assertFalse( - $asset::isAdded('script', 'script-second') - ); - } - - /** - * Output footer scripts. - */ - public function testOutputFooterScripts() - { - $asset = $this->Asset; - - $scripts = $asset::outputScripts('footer'); - - $this->assertContains( - "", - $scripts - ); - - $this->assertContains( - "", - $scripts - ); - } - - /** - * Output header scripts. - */ - public function testOutputHeaderScripts() - { - $asset = $this->Asset; - - $scripts = $asset::outputScripts('header'); - - $this->assertContains( - "", - $scripts - ); - - $this->assertContains( - "", - $scripts - ); - } - - /** - * Output when there are not header scripts loaded. - */ - public function testOutputWhenNotFooterScriptsLoaded() - { - $asset = $this->Asset; - - $this->assertFalse( - $asset::outputScripts('footer') - ); - } - - /** - * Output when there are not header scripts loaded. - */ - public function testOutputWhenNotHeaderScriptsLoaded() - { - $asset = $this->Asset; - - $this->assertFalse( - $asset::outputScripts('header') - ); - } -} diff --git a/tests/StylesTest.php b/tests/StylesTest.php deleted file mode 100644 index 5c4c611..0000000 --- a/tests/StylesTest.php +++ /dev/null @@ -1,214 +0,0 @@ - - * @copyright 2016 - 2018 (c) Josantonius - PHP-Assets - * @license https://opensource.org/licenses/MIT - The MIT License (MIT) - * @link https://github.com/Josantonius/PHP-Asset - * @since 1.1.5 - */ -namespace Josantonius\Asset; - -use PHPUnit\Framework\TestCase; - -/** - * Tests class for Asset library. - * - * @since 1.1.5 - */ -final class StylesTest extends TestCase -{ - /** - * Asset instance. - * - * @since 1.1.6 - * - * @var object - */ - protected $Asset; - - /** - * Assets url. - * - * @var string - */ - protected $assetsUrl; - - /** - * Set up. - */ - public function setUp() - { - parent::setUp(); - - $this->Asset = new Asset; - - $url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; - - $this->assetsUrl = 'https://' . $url; - } - - /** - * Check if it is an instance of Asset. - * - * @since 1.1.6 - */ - public function testIsInstanceOf() - { - $this->assertInstanceOf('\Josantonius\Asset\Asset', $this->Asset); - } - - /** - * Add style. - */ - public function testAddStyle() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::add('style', [ - 'name' => 'style-first', - 'url' => $this->assetsUrl . 'css/style.css', - ]) - ); - } - - /** - * Add style with version. - */ - public function testAddStyleWithVersion() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::add('style', [ - 'name' => 'style-second', - 'url' => $this->assetsUrl . 'css/style.css', - 'version' => '1.0.0' - ]) - ); - } - - /** - * Add style by adding all options. - */ - public function testAddStyleAddingAllParams() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::add('style', [ - 'name' => 'style-third', - 'url' => $this->assetsUrl . 'css/custom.css', - 'version' => '1.1.3' - ]) - ); - } - - /** - * Add style without specifying a name. [FALSE|ERROR] - */ - public function testAddStyleWithoutName() - { - $asset = $this->Asset; - - $this->assertFalse( - $asset::add('style', [ - 'url' => $this->assetsUrl . 'css/unknown.css', - 'attr' => 'defer', - ]) - ); - } - - /** - * Add style without specifying a url. [FALSE|ERROR] - */ - public function testAddStyleWithoutUrl() - { - $asset = $this->Asset; - - $this->assertFalse( - $asset::add('style', [ - 'name' => 'unknown', - 'attr' => 'defer', - ]) - ); - } - - /** - * Check if the styles have been added correctly. - */ - public function testIfStylesAddedCorrectly() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::isAdded('style', 'style-first') - ); - - $this->assertTrue( - $asset::isAdded('style', 'style-second') - ); - - $this->assertTrue( - $asset::isAdded('style', 'style-third') - ); - } - - /** - * Delete added styles. - */ - public function testRemoveAddedStyles() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::remove('style', 'style-first') - ); - } - - /** - * Validation after deletion. - */ - public function testValidationAfterDeletion() - { - $asset = $this->Asset; - - $this->assertFalse( - $asset::isAdded('style', 'style-first') - ); - } - - /** - * Output styles. - */ - public function testOutputStyles() - { - $asset = $this->Asset; - - $styles = $asset::outputStyles(); - - $this->assertContains( - "", - $styles - ); - - $this->assertContains( - "", - $styles - ); - } - - /** - * Output when there are not header styles loaded. - */ - public function testOutputWhenNotStylesLoaded() - { - $asset = $this->Asset; - - $this->assertFalse( - $asset::outputStyles() - ); - } -} diff --git a/tests/UnifyFilesTest.php b/tests/UnifyFilesTest.php deleted file mode 100644 index d317cc1..0000000 --- a/tests/UnifyFilesTest.php +++ /dev/null @@ -1,287 +0,0 @@ - - * @copyright 2016 - 2018 (c) Josantonius - PHP-Assets - * @license http://opensource.org/licenses/MIT - The MIT License (MIT) - * @link http://github.com/Josantonius/PHP-Asset - * @since 1.1.5 - */ -namespace Josantonius\Asset; - -use PHPUnit\Framework\TestCase; - -/** - * Tests class for Asset library. - * - * @since 1.1.5 - */ -final class UnifyFilesTest extends TestCase -{ - /** - * Asset instance. - * - * @since 1.1.6 - * - * @var object - */ - protected $Asset; - - /** - * Assets url. - * - * @var string - */ - protected $assetsUrl; - - /** - * Assets path. - * - * @var string - */ - protected $assetsPath; - - /** - * Set up. - */ - public function setUp() - { - parent::setUp(); - - $this->Asset = new Asset; - - $url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; - - $this->assetsUrl = 'http://' . $url; - - $this->assetsPath = $_SERVER['DOCUMENT_ROOT']; - } - - /** - * Check if it is an instance of Asset. - * - * @since 1.1.6 - */ - public function testIsInstanceOf() - { - $this->assertInstanceOf('\Josantonius\Asset\Asset', $this->Asset); - } - - /** - * Unify files specifying the same url path for styles and scripts. - */ - public function testUnify() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::unify('UniqueID', $this->assetsUrl . 'min/') - ); - } - - /** - * Unify files specifying different url paths for styles and scripts. - */ - public function testUnifySpecifyingDifferentUrlPaths() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::unify('UniqueID', [ - 'styles' => $this->assetsUrl . 'min/', - 'scripts' => $this->assetsUrl . 'min/', - ]) - ); - } - - /** - * Unify files specifying the same url path for styles and scripts. - */ - public function testUnifyAndMinify() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::unify('UniqueID', $this->assetsUrl . 'min/', true) - ); - } - - /** - * Unify files specifying different url paths for styles and scripts. - */ - public function testUnifyAndMinifySpecifyingDifferentUrlPaths() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::unify('UniqueID', [ - 'styles' => $this->assetsUrl . 'min/', - 'scripts' => $this->assetsUrl . 'min/', - ], true) - ); - } - - /** - * Add styles and scripts. - */ - public function testAddStylesAndScripts() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::add('style', [ - 'name' => 'CustomStyle', - 'url' => $this->assetsUrl . 'css/custom.css', - 'version' => '1.1.3', - ]) - ); - - $this->assertTrue( - $asset::add('style', [ - 'name' => 'DefaultStyle', - 'url' => $this->assetsUrl . 'css/style.css', - ]) - ); - - $this->assertTrue( - $asset::add('script', [ - 'name' => 'DefaultScript', - 'url' => $this->assetsUrl . 'js/script.js', - 'version' => '1.1.3', - 'footer' => false, - ]) - ); - - $this->assertTrue( - $asset::add('script', [ - 'name' => 'CustomScript', - 'url' => $this->assetsUrl . 'js/custom.js', - 'version' => '1.1.3', - 'footer' => false, - ]) - ); - - $this->assertTrue( - $asset::add('script', [ - 'name' => 'Default', - 'url' => $this->assetsUrl . 'js/script.js', - 'version' => '1.1.3', - 'footer' => true, - ]) - ); - - $this->assertTrue( - $asset::add('script', [ - 'name' => 'Custom', - 'url' => $this->assetsUrl . 'js/custom.js', - 'version' => '1.1.3', - 'footer' => true, - ]) - ); - } - - /** - * Check if styles and scripts have been added correctly. - */ - public function testIfStylesAndScriptsAddedCorrectly() - { - $asset = $this->Asset; - - $this->assertTrue( - $asset::isAdded('style', 'CustomStyle') - ); - - $this->assertTrue( - $asset::isAdded('style', 'DefaultStyle') - ); - - $this->assertTrue( - $asset::isAdded('script', 'DefaultScript') - ); - - $this->assertTrue( - $asset::isAdded('script', 'CustomScript') - ); - - $this->assertTrue( - $asset::isAdded('script', 'Default') - ); - - $this->assertTrue( - $asset::isAdded('script', 'Custom') - ); - } - - /** - * If styles and scripts are registered. - */ - public function testOutputStylesAndScripts() - { - $asset = $this->Asset; - - $styleOne = 'custom.css'; - $styleTwo = 'style.css'; - - $style = sha1($styleOne . $styleTwo) . '.css'; - - $scriptOne = 'script.js'; - $scriptTwo = 'custom.js'; - - $script = sha1($scriptOne . $scriptTwo) . '.js'; - - $this->assertContains( - "", - $asset::outputStyles() - ); - - $this->assertContains( - "", - $asset::outputScripts('header') - ); - - $this->assertContains( - "", - $asset::outputScripts('footer') - ); - } - - /** - * Validate whether unified files have been created. - */ - public function testIfUnifiedFilesWasCreated() - { - $styleOne = 'custom.css'; - $styleTwo = 'style.css'; - - $style = sha1($styleOne . $styleTwo) . '.css'; - - $scriptOne = 'script.js'; - $scriptTwo = 'custom.js'; - - $script = sha1($scriptOne . $scriptTwo) . '.js'; - - $this->assertFileExists( - $this->assetsPath . 'min/' . $style - ); - - $this->assertContains( - "body, h1, h2, h3, h4, h5, h6 {font-family: 'Open Sans'", - file_get_contents($this->assetsPath . 'min/' . $style) - ); - - $this->assertFileExists( - $this->assetsPath . 'min/' . $script - ); - - $this->assertContains( - "$('p').click(function() {alert('The paragraph was clicked.');});", - file_get_contents($this->assetsPath . 'min/' . $script) - ); - - unlink($this->assetsPath . 'min/' . $style); - unlink($this->assetsPath . 'min/' . $script); - - rmdir($this->assetsPath . 'min/'); - } -} diff --git a/tests/assets/css/custom.css b/tests/assets/css/custom.css deleted file mode 100644 index 28cb48f..0000000 --- a/tests/assets/css/custom.css +++ /dev/null @@ -1,3 +0,0 @@ -body, h1, h2, h3, h4, h5, h6 { - font-family: 'Open Sans', sans-serif; -} \ No newline at end of file diff --git a/tests/assets/css/style.css b/tests/assets/css/style.css deleted file mode 100644 index 653ab98..0000000 --- a/tests/assets/css/style.css +++ /dev/null @@ -1,4 +0,0 @@ -body { - font-size: 1.6em; - line-height: 1.6; -} \ No newline at end of file diff --git a/tests/assets/js/custom.js b/tests/assets/js/custom.js deleted file mode 100644 index 70ca56e..0000000 --- a/tests/assets/js/custom.js +++ /dev/null @@ -1,3 +0,0 @@ -function myFunction() { - document.getElementById('myCheck').click(); -} \ No newline at end of file diff --git a/tests/assets/js/script.js b/tests/assets/js/script.js deleted file mode 100644 index 7042f3f..0000000 --- a/tests/assets/js/script.js +++ /dev/null @@ -1,3 +0,0 @@ -$('p').click(function() { - alert('The paragraph was clicked.'); -}); \ No newline at end of file From 9ce8bde2c40708afe9d3b3420a1cb5fa1f7abaa7 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 30 Jun 2022 21:05:09 +0200 Subject: [PATCH 02/12] build: add scripts and normalize Added scripts, normalized the archive and removed unused packages. Closes #1 --- composer.json | 55 +++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/composer.json b/composer.json index 219a99a..3487cac 100644 --- a/composer.json +++ b/composer.json @@ -1,48 +1,39 @@ { - "name": "josantonius/asset", - "type": "library", + "name": "josantonius/asset", "description": " * PHP library for handling styles and scripts: Add, minify, unify and print.", + "license": "MIT", + "type": "library", "keywords": [ "Asset", "JS", "CSS", - "minify", - "unify", "print", "scripts", "styles", - "HHVM", - "Load resources", "PHP" ], - "license": "MIT", "authors": [ { - "name": "Josantonius", - "email": "hello@josantonius.com", - "homepage": "https://josantonius.com", - "role": "Developer" + "name": "Josantonius", + "email": "hello@josantonius.dev", + "homepage": "https://josantonius.dev", + "role": "Developer" } ], "support": { "issues": "https://github.com/josantonius/php-asset/issues", - "forum": "http://stackoverflow.com/tags/josantonius/php-asset", - "source": "https://github.com/josantonius/php-asset" - }, - "config": { - "preferred-install": "dist" + "source": "https://github.com/josantonius/php-asset", + "discussions": "https://github.com/josantonius/php-asset/discussions" }, - "minimum-stability": "stable", "require": { - "php": "^5.6 || ^7.0", - "Josantonius/Json" : "^1.1.4" + "php": "^8.1" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0", - "squizlabs/php_codesniffer": "^3.0", - "friendsofphp/php-cs-fixer": "^2.3 || ^2.8", - "phpmd/phpmd": "^2.6" + "phpmd/phpmd": "^2.6", + "phpunit/phpunit": "^9.0", + "squizlabs/php_codesniffer": "^3.7" }, + "minimum-stability": "stable", "autoload": { "psr-4": { "Josantonius\\Asset\\": "src/" @@ -50,22 +41,26 @@ }, "autoload-dev": { "psr-4": { - "Josantonius\\Asset\\": "tests/" + "Josantonius\\Asset\\Tests\\": "tests/" } }, + "config": { + "preferred-install": "dist" + }, "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "1.0-dev" } }, "scripts": { - "phpunit": "vendor/bin/phpunit --colors=always;", - "phpcs": "vendor/bin/phpcs --standard=phpcs.xml $(find . -name '*.php');", - "phpmd": "vendor/bin/phpmd src,tests text ./phpmd.xml", + "coverage": "vendor/bin/phpunit --coverage-clover=coverage.xml", "fix": [ - "vendor/bin/php-cs-fixer fix -v", "vendor/bin/phpcbf src tests" ], + "htmlCoverage": "vendor/bin/phpunit --coverage-html coverage", + "phpcs": "vendor/bin/phpcs --standard=phpcs.xml $(find . -name '*.php');", + "phpmd": "vendor/bin/phpmd src,tests text ./phpmd.xml", + "phpunit": "vendor/bin/phpunit --colors=always;", "tests": [ "clear", "@phpmd", @@ -73,4 +68,4 @@ "@phpunit" ] } -} +} \ No newline at end of file From 3b5d20c68cc91011019b842cfcd46edc494b0704 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 30 Jun 2022 21:05:38 +0200 Subject: [PATCH 03/12] build: update changes in .git* files Update latest changes in .gitattributes and .gitignore files. Closes #1 --- .gitattributes | 8 ++------ .gitignore | 13 ++++++------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.gitattributes b/.gitattributes index 58ff123..2713ee2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,13 +1,9 @@ +/.github export-ignore /tests export-ignore CHANGELOG.md export-ignore -README.md export-ignore -README-ES.md export-ignore phpcs.xml export-ignore phpunit.xml export-ignore phpmd.xml export-ignore -.travis.yml export-ignore -.editorconfig export-ignore .gitattributes export-ignore .gitignore export-ignore -.php_cs.dist export-ignore -CONDUCT.md export-ignore \ No newline at end of file +.php-cs-fixer.dist.php export-ignore \ No newline at end of file diff --git a/.gitignore b/.gitignore index 40ac263..b740c4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,12 @@ -.git*/ vendor/ -docs/*.pyc -docs/_build -build/artifacts/ +coverage/ +.vscode/ composer.phar composer.lock composer-test.lock phpcbf-fixed.diff -.idea -.DS_STORE .php_cs.cache -src/files.jsond \ No newline at end of file +php-asset.code-workspace +.repository.md +.phpunit.result.cache +coverage.xml \ No newline at end of file From 02309f48ac07d90b3bafc4b07f61fee4dc37832a Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 30 Jun 2022 21:06:15 +0200 Subject: [PATCH 04/12] build: change rules Rules were modified. Closes #1 --- phpcs.xml | 202 +++++++++++++++++++++++++++++++++++++++++++++++++++--- phpmd.xml | 78 ++++++++++++++------- 2 files changed, 244 insertions(+), 36 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 1be40e3..28ddb47 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,17 +1,199 @@ - + + + Coding standard. + - - PHP Coding Standards + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + + + error + Method name "%s" must not be prefixed with an underscore to indicate visibility + + + + + - - - - + + + + 0 + + + 0 + + + 0 + + + + + + + + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + - node_modules + + + - vendor - + node_modules + vendor + \ No newline at end of file diff --git a/phpmd.xml b/phpmd.xml index 9480040..8d1a39d 100644 --- a/phpmd.xml +++ b/phpmd.xml @@ -1,21 +1,46 @@ - - + + + Coding standard. + + + + + + + + + + + + - - - + + - - + + + + + + + + + + + + + @@ -24,22 +49,23 @@ - + + + + + + + + + + + - - - + + + - - - - - - - - - - - + + \ No newline at end of file From 646de86beb4c06dd798fb26af3a714a3c66bb295 Mon Sep 17 00:00:00 2001 From: Josantonius Date: Thu, 30 Jun 2022 21:07:19 +0200 Subject: [PATCH 05/12] docs: improve documentation Add and modify new document files. Closes #1 --- .github/CODE_OF_CONDUCT.md | 131 ++++++++ .github/CONTRIBUTING.md | 314 ++++++++++++++++++ .github/FUNDING.yml | 2 + .github/lang/es-ES/CODE_OF_CONDUCT.md | 139 ++++++++ .github/lang/es-ES/CONTRIBUTING.md | 319 ++++++++++++++++++ .github/lang/es-ES/LICENSE | 23 ++ .github/lang/es-ES/README.md | 435 +++++++++++++++++++++++++ LICENSE | 2 +- README.md | 450 ++++++++++++++++---------- 9 files changed, 1642 insertions(+), 173 deletions(-) create mode 100644 .github/CODE_OF_CONDUCT.md create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/FUNDING.yml create mode 100644 .github/lang/es-ES/CODE_OF_CONDUCT.md create mode 100644 .github/lang/es-ES/CONTRIBUTING.md create mode 100644 .github/lang/es-ES/LICENSE create mode 100644 .github/lang/es-ES/README.md diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..5d1569c --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,131 @@ +# Contributor Covenant Code of Conduct + +- [Our Pledge](#our-pledge) +- [Our Standards](#our-standards) +- [Enforcement Responsibilities](#enforcement-responsibilities) +- [Scope](#scope) +- [Enforcement](#enforcement) +- [Enforcement Guidelines](#enforcement-guidelines) + - [1. Correction](#1-correction) + - [2. Warning](#2-warning) + - [3. Temporary Ban](#3-temporary-ban) + - [4. Permanent Ban](#4-permanent-ban) +- [Attribution](#attribution) + +--- + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +- Demonstrating empathy and kindness toward other people. +- Being respectful of differing opinions, viewpoints, and experiences. +- Giving and gracefully accepting constructive feedback. +- Accepting responsibility and apologizing to those affected by our mistakes. +- Focusing on what is best for the overall community. + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery. +- Sexual attention or advances of any kind. +- Trolling, insulting or derogatory comments. +- Personal or political attacks. +- Public or private harassment. +- Publishing others' private information without their explicit permission. +- Any conduct considered inappropriate in a professional environment. + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders 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, and will communicate reasons for +moderation decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail +address, posting via an official social media account, or acting as an +appointed representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[hello@josantonius.dev](mailto:hello@josantonius.dev). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the +[Contributor Covenant](https://www.contributor-covenant.org/), +version 2.1, available at +. diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..8bb03a0 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,314 @@ +# Contributing + +We would love for you to contribute to this project and help make it even better! +As a contributor, here are the guidelines we would like you to follow: + +--- + +- [Code of Conduct](#code-of-conduct) +- [Got a Question, Problem or Idea?](#got-a-question-problem-or-idea) +- [Add or Improve a Feature?](#add-or-improve-a-feature) +- [Found a Bug?](#found-a-bug) +- [Submitting an Issue](#submitting-an-issue) +- [Submitting a Pull Request](#submitting-a-pull-request) + - [After Your Pull Request is Merged](#after-your-pull-request-is-merged) +- [Coding Rules](#coding-rules) +- [Commit Message Conventions](#commit-message-conventions) + - [Commit Message Header](#commit-message-header) + - [Type](#type) + - [Scope](#scope) + - [Summary](#summary) + - [Commit Message Body](#commit-message-body) + - [Commit Message Footer](#commit-message-footer) + +--- + +## Code of Conduct + +Help us keep this project open and inclusive. +Please read and follow our [Code of Conduct](CODE_OF_CONDUCT.md). + +## Got a Question, Problem or Idea? + +Start a [new discussion](https://github.com/josantonius/php-asset/discussions/new) and select the +appropriate category for it: + +- `General`: Anything that is relevant to the project. +- `Ideas`: Ideas to change/improve the project or propose new features. +- `Polls`: Polls with multi options for the community to vote for and discuss. +- `Q&A`: Questions for the community to answer, in a question/answer format. +- `Show and tell`: Creations, experiments, or tests relevant to the project. + +## Add or Improve a Feature? + +- For a **Major Feature**, +first [open a new discussion](https://github.com/josantonius/php-asset/discussions/new) in the +`Ideas` category and outline your proposal so that it can be discussed. This will also allow us to +better coordinate our efforts, prevent duplication of work, and help you to craft the change so that +it is successfully accepted into the project. + +- **Small Features** can be crafted and directly +[submitted as a Pull Request](#submitting-a-pull-request). + +## Found a Bug? + +If you find a bug in the source code, you can help us by +[submitting an issue](#submitting-an-issue) to our +[repository](https://github.com/josantonius/php-asset). Even better, you can +[submit a Pull Request](#submitting-a-pull-request) with a fix. + +## Submitting an Issue + +Issues are very valuable for any project. + +Great bug reports tend to have: + +- A quick summary and/or background. +- Steps to reproduce. +- Be specific. +- Give sample code if you can. +- What you expected would happen. +- What actually happens. +- Notes; why you think this might be happening, tests that didn't work... + +You can file new issues by filling out our +[new issue form](https://github.com/josantonius/php-asset/issues/new). + +## Submitting a Pull Request + +Pull requests are a great way to put your ideas into this project or simply fix something. + +Before you submit your Pull Request (PR) consider the following guidelines: + +1. Search [GitHub](https://github.com/josantonius/php-asset/pulls) for an open or closed PR that +relates to your submission. You don't want to duplicate effort. + +1. [Fork](https://github.com/josantonius/php-asset/fork) the repository to your own GitHub account. + +1. Clone the repository to your machine. + +1. Go to the cloned repository. + + ```shell + cd php-asset + ``` + +1. Create a branch from the `main branch` with a succinct but descriptive name. + + ```shell + git checkout -b descriptive-name main + ``` + +1. Make your changes in the new git branch, including appropriate test cases. + +1. Follow our [Coding Rules](#coding-rules). + +1. Run the full repository test suite. + + ```shell + composer tests + ``` + +1. Commit your changes using a descriptive commit message that follows our + [commit message conventions](#commit-message-conventions). + + ```shell + git commit -a + ``` + + **The optional commit `-a` command line option will automatically "add" and "rm" edited files.** + +1. Push your branch to GitHub: + + ```shell + git push origin descriptive-name + ``` + +1. In GitHub, send a [pull request](https://github.com/josantonius/php-asset/compare/main..) +to `php-asset:main`. + +- If we suggest changes then: + - Make the required updates. + - Re-run the test suites to ensure tests are still passing. + - Rebase your branch and force push to your GitHub repository (this will update your Pull Request): + + ```shell + git rebase main -i + git push -f + ``` + +That's it! Thank you for your contribution! + +### After Your Pull Request is Merged + +After your pull request is merged, you can safely delete your branch and pull the changes from the +`main` (upstream) repository: + +- Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows: + + ```shell + git push origin --delete descriptive-name + ``` + +- Check out the `main` branch: + + ```shell + git checkout main -f + ``` + +- Delete the local branch: + + ```shell + git branch -D descriptive-name + ``` + +- Update your ´main´ branch with the latest upstream version: + + ```shell + git pull --ff upstream main + ``` + +## Coding Rules + +To ensure consistency throughout the source code, keep these rules in mind as you are working: + +- All features or bug fixes **must be tested** by one or more specs (unit-tests). + + You can use the following command to check the tests: + + ```shell + composer phpunit + ``` + +- All new feature **must be documented** in the `README.md` file. + +- We use `PHP CodeSniffer` and `PHP Mess Detector` to define our code standards. + + You can use the following commands to check the status of your code: + + ```shell + composer phpcs + ``` + + ```shell + composer phpmd + ``` + + You can use the following command to automatically format errors found with `PHP CodeSniffer`: + + ```shell + composer fix + ``` + +## Commit Message Conventions + +We have very precise rules over how our Git commit messages must be formatted. +This format leads to **easier to read commit history**. + +Each commit message consists of a **header**, a **body**, and a **footer**. + +```none +
+ + + +