Skip to content

Commit

Permalink
Merge pull request #6 from wmde/maintenance-2023
Browse files Browse the repository at this point in the history
Maintenance 2023
  • Loading branch information
Abban authored Aug 4, 2023
2 parents 8f2e4b8 + 9ef35a8 commit 9c19879
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 253 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# See the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "composer" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
21 changes: 21 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Dependabot auto-approve
on: pull_request

permissions:
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
*~
!.*
.idea/

composer.phar
composer.lock

vendor/

.idea/
.phpunit.result.cache
.phpunit.cache/
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ language: php

# php version to use for travis' composer & coverage
php:
- 7.4
- 8.2

dist: focal

services:
- docker
Expand Down
42 changes: 24 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
# If the first argument is "composer"...
ifeq (composer,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "composer"
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif
current_user := $(shell id -u)
current_group := $(shell id -g)

.PHONY: ci test phpunit cs stan covers composer
BUILD_DIR := $(PWD)
COMPOSER_FLAGS :=
DOCKER_FLAGS := --interactive --tty
DOCKER_IMAGE := registry.gitlab.com/fun-tech/fundraising-frontend-docker

.PHONY: ci test phpunit cs stan composer

ci: test cs

test: covers phpunit
test: phpunit

cs: phpcs stan

install-php: install

install:
docker run --rm $(DOCKER_FLAGS) --volume $(BUILD_DIR):/app -w /app --volume /tmp:/tmp --volume ~/.composer:/composer --user $(current_user):$(current_group) $(DOCKER_IMAGE):composer composer install $(COMPOSER_FLAGS)

update-php: update

update:
docker run --rm $(DOCKER_FLAGS) --volume $(BUILD_DIR):/app -w /app --volume /tmp:/tmp --volume ~/.composer:/composer --user $(current_user):$(current_group) $(DOCKER_IMAGE):composer composer update $(COMPOSER_FLAGS)

phpunit:
docker-compose run --rm email-address ./vendor/bin/phpunit
docker-compose run --rm app ./vendor/bin/phpunit

phpcs:
docker-compose run --rm email-address ./vendor/bin/phpcs
docker-compose run --rm app ./vendor/bin/phpcs

stan:
docker-compose run --rm email-address ./vendor/bin/phpstan analyse --level=1 --no-progress src/ tests/

covers:
docker-compose run --rm email-address ./vendor/bin/covers-validator
docker-compose run --rm app ./vendor/bin/phpstan analyse --level=9 --no-progress src/ tests/

composer:
docker run --rm --interactive --tty --volume $(shell pwd):/app -w /app\
--volume ~/.composer:/composer --user $(shell id -u):$(shell id -g) composer composer $(filter-out $@,$(MAKECMDGOALS))
fix-cs:
docker-compose run --rm app ./vendor/bin/phpcbf
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Email Address

[![Build Status](https://travis-ci.org/wmde/email-address.svg?branch=master)](https://travis-ci.org/wmde/email-address)
[![Build Status](https://travis-ci.org/wmde/email-address.svg?branch=main)](https://travis-ci.org/wmde/email-address)
[![Latest Stable Version](https://poser.pugx.org/wmde/email-address/version.png)](https://packagist.org/packages/wmde/email-address)
[![Download count](https://poser.pugx.org/wmde/email-address/d/total.png)](https://packagist.org/packages/wmde/email-address)

Email Address value object written in PHP 7.
Email Address value object that can

- split username and domain
- normalize Internationalized Domain names (IDN).

```php
class EmailAddress {
Expand Down Expand Up @@ -36,25 +39,19 @@ file that just defines a dependency on Email Address 2.x:

## Development

For development you need to have Docker and Docker-compose installed. Local PHP and Composer are not needed.

sudo apt-get install docker docker-compose

### Running Composer
### Installing dependencies

To pull in the project dependencies via Composer, run:

make composer install
make install

You can run other Composer commands via `make run`, but at present this does not support argument flags.
If you need to execute such a command, you can do so in this format:
To update them, run

docker run --rm --interactive --tty --volume $PWD:/app -w /app\
--volume ~/.composer:/composer --user $(id -u):$(id -g) composer composer install -vvv
make update

### Running the CI checks

To run all CI checks, which includes PHPUnit tests, PHPCS style checks and coverage tag validation, run:
To run all CI checks, which includes PHPUnit tests, PHPCS style checks and static analysis with PHPStan, run:

make

Expand All @@ -66,5 +63,5 @@ To run the PHPUnit tests run

To run a subset of PHPUnit tests or otherwise pass flags to PHPUnit, run

docker-compose run --rm email-address ./vendor/bin/phpunit --filter SomeClassNameOrFilter
docker-compose run --rm app ./vendor/bin/phpunit --filter SomeClassNameOrFilter

18 changes: 11 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
"license": "GPL-2.0-or-later",
"description": "Email Address value object written in PHP 7",
"require": {
"php": ">=7.3"
"php": ">=8.1"
},
"require-dev": {
"phpunit/phpunit": "~8.4",
"ockcyp/covers-validator": "~1.1",
"squizlabs/php_codesniffer": "~3.0",
"slevomat/coding-standard": "~4.0",
"mediawiki/mediawiki-codesniffer": "~28.0",
"phpstan/phpstan": "~0.11.0"
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "~10.0",
"wmde/fundraising-phpcs": "~8.0"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/wmde/fundraising-phpcs",
"no-api": true
}
],
"autoload": {
"psr-4": {
"WMDE\\EmailAddress\\": "src/"
Expand Down
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
version: '2'

services:
email-address:
app:
volumes:
- ./:/usr/src/app
working_dir: /usr/src/app
image: wikimediade/fundraising-frontend:latest


image: registry.gitlab.com/fun-tech/fundraising-frontend-docker
171 changes: 5 additions & 166 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,173 +1,12 @@
<?xml version="1.0"?>
<!--
- https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
- https://github.com/squizlabs/PHP_CodeSniffer/tree/master/src/Standards
-->
<ruleset name="WikimediaDeutschlandStyle">

<ruleset>
<file>src/</file>
<file>tests/</file>

<arg name="extensions" value="php"/>
<arg value="s"/>
<arg value="p"/>

<rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki/Sniffs/WhiteSpace">
<exclude name="vendor/mediawiki/mediawiki-codesniffer/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php" />
</rule>

<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
<rule ref="Generic.Classes" />
<rule ref="Generic.CodeAnalysis">
<exclude name="Generic.CodeAnalysis.EmptyStatement" />
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter" />
</rule>
<rule ref="Generic.ControlStructures" />

<rule ref="Generic.Files.ByteOrderMark" />
<rule ref="Generic.Files.LineEndings" />
<rule ref="Generic.Files.LineLength">
<properties>
<!-- https://github.com/squizlabs/PHP_CodeSniffer/issues/1094 -->
<property name="lineLimit" value="170" />
<property name="absoluteLineLimit" value="170" />
</properties>
</rule>

<rule ref="Generic.Formatting.DisallowMultipleStatements" />

<rule ref="Generic.Functions.CallTimePassByReference" />
<rule ref="Generic.Functions.FunctionCallArgumentSpacing" />

<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />

<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="3" />
<property name="absoluteNestingLevel" value="3" />
</properties>
</rule>

<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="10" />
<property name="absoluteComplexity" value="10" />
</properties>
</rule>

<rule ref="Generic.NamingConventions" />
<!-- TODO: create variation of this sniff that allows underscores in test methods -->
<rule ref="Generic.NamingConventions.CamelCapsFunctionName.ScopeNotCamelCaps">
<!-- Exclude test methods like "testGivenInvalidInput_methodThrowsException". -->
<exclude-pattern>*Test\.php</exclude-pattern>
</rule>

<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag" />
<rule ref="Generic.PHP.DeprecatedFunctions" />
<rule ref="Generic.PHP.DisallowShortOpenTag" />
<rule ref="Generic.PHP.ForbiddenFunctions" />
<rule ref="Generic.PHP.LowerCaseConstant" />
<rule ref="Generic.PHP.LowerCaseKeyword" />
<rule ref="Generic.PHP.SAPIUsage" />

<rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />

<rule ref="PSR1" />
<!-- TODO: create variation of this sniff that allows underscores in test methods -->
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<!-- Exclude test methods like "testGivenInvalidInput_methodThrowsException". -->
<exclude-pattern>*Test\.php</exclude-pattern>
</rule>

<rule ref="PSR2.Classes.PropertyDeclaration" />
<rule ref="PSR2.ControlStructures.ElseIfDeclaration" />
<rule ref="PSR2.Namespaces" />

<rule ref="Squiz.Arrays.ArrayBracketSpacing" />
<rule ref="Squiz.CSS.SemicolonSpacing" />
<rule ref="Squiz.Classes.DuplicateProperty" />
<rule ref="Squiz.Classes.SelfMemberReference" />
<rule ref="Squiz.Classes.ValidClassName" />
<rule ref="Squiz.Functions.FunctionDuplicateArgument" />
<rule ref="Squiz.Functions.GlobalFunction" />
<rule ref="Squiz.Scope" />

<rule ref="Squiz.Strings.DoubleQuoteUsage" />
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<severity>0</severity>
</rule>

<rule ref="Squiz.WhiteSpace.CastSpacing" />
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" />
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing" />

<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true" />
</properties>
<exclude name="Squiz.WhiteSpace.OperatorSpacing.NoSpaceBefore" />
<exclude name="Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter" />
</rule>

<rule ref="Squiz.WhiteSpace.ScopeClosingBrace" />
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing" />
<rule ref="Squiz.WhiteSpace.SemicolonSpacing" />
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<severity>0</severity>
</rule>

<rule ref="Zend.Files.ClosingTag" />

<!-- MediaWiki.WhiteSpace.SpaceyParenthesis replica for up-to-date codesniffer version -->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1" />
<property name="requiredSpacesAfterOpen" value="1" />
<property name="requiredSpacesBeforeClose" value="1" />
</properties>
</rule>

<rule ref="PEAR.Functions.FunctionCallSignature">
<properties>
<property name="requiredSpacesAfterOpen" value="1" />
<property name="requiredSpacesBeforeClose" value="1" />
</properties>
<exclude name="PEAR.Functions.FunctionCallSignature.Indent" />
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" />
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" />
</rule>

<!-- Using 3rd party sniff while Squiz isn't there, yet. https://github.com/squizlabs/PHP_CodeSniffer/issues/911 -->
<rule ref="./vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/TypeHints/DeclareStrictTypesSniff.php" />
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2" />
<property name="spacesCountAroundEqualsSign" value="1" />
</properties>
</rule>

<rule ref="./vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/TypeHints/ReturnTypeHintSpacingSniff.php" />

<rule ref="./vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/TypeHints/TypeHintDeclarationSniff.php">
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversablePropertyTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableReturnTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingPropertyTypeHint" />
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
<properties>
<property name="usefulAnnotations" type="array" value="
@see,
@throws,
@dataProvider,
@slowThreshold,
@noinspection
"/>
<property name="enableVoidTypeHint" value="false" />
</properties>
</rule>
<arg name="encoding" value="UTF-8"/>
<arg value="p" />
<arg value="s" />

<rule ref="./vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Namespaces/UseDoesNotStartWithBackslashSniff.php" />
<rule ref="./vendor/wmde/fundraising-phpcs/WMDE/Fundraising"/>
</ruleset>
Loading

0 comments on commit 9c19879

Please sign in to comment.