Skip to content

Commit

Permalink
Add PHP8 attributes to documentation
Browse files Browse the repository at this point in the history
- Update dependencies
- Test bundle in PHP8
- Adjust configuration
  • Loading branch information
iquito committed Dec 18, 2020
1 parent 74ee3ba commit 35b2e0e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 27 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ env:
global:
- CC_TEST_REPORTER_ID=4fcc7cd3d969a1c9138bc05862c70ea7776670f18e15c8508e3827332578dac8
- GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi)
- XDEBUG_MODE=coverage
language: php
php:
- '7.4'
- '8.0'

before_script:
- composer self-update
Expand All @@ -16,10 +18,10 @@ before_script:

script:
- composer phpunit_clover
- composer phpstan
- composer psalm
- if [ "${TRAVIS_PHP_VERSION:0:1}" == "8" ]; then composer phpstan; fi
- if [ "${TRAVIS_PHP_VERSION:0:1}" == "8" ]; then composer psalm; fi
- composer phpcs
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build -t clover --exit-code $TRAVIS_TEST_RESULT; fi
- if [ "$TRAVIS_PULL_REQUEST" == "false" -a "${TRAVIS_PHP_VERSION:0:1}" == "8" ]; then ./cc-test-reporter after-build -t clover --exit-code $TRAVIS_TEST_RESULT; fi

notifications:
email: false
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ class NewsletterChangeAction
}
```

With PHP8 you can use attributes instead of annotations:

```php
<?php

use Squirrel\Strings\Annotation\StringFilter;

class NewsletterChangeAction
{
#[StringFilter("StreamlineInputNoNewlines","RemoveHTMLTags")]
public string $firstName = '';

#[StringFilter("RemoveNonAlphanumeric")]
public string $confirmToken = '';
}
```

You can run one or more string filters and use any of the default list of filters or any of [your own filters which you added](#adding-new-filters). The filters are run as an early PRE_SUBMIT form event.

Beware: It only works if you map your class properties (`$firstName` and `$lastName` in this example) to the form without custom property paths, so the names used in the form have to be identical to the property names in the class. As long as you do not specify `property_path` in your form you are safe.
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@
},
"scripts": {
"phpstan": "vendor/bin/phpstan analyse",
"phpstan_full": "vendor/bin/phpstan clear-result-cache && vendor/bin/phpstan analyse",
"phpstan_base": "vendor/bin/phpstan analyse --generate-baseline",
"phpstan_clear": "vendor/bin/phpstan clear-result-cache",
"psalm": "vendor/bin/psalm --show-info=false",
"psalm_full": "vendor/bin/psalm --show-info=false",
"psalm_full": "vendor/bin/psalm --clear-cache && vendor/bin/psalm --show-info=false",
"psalm_base": "vendor/bin/psalm --set-baseline=psalm-baseline.xml",
"phpunit": "vendor/bin/phpunit --colors=always",
"phpunit_clover": "vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml",
"coverage": "vendor/bin/phpunit --coverage-html tests/_reports",
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html tests/_reports",
"phpcs": "vendor/bin/phpcs --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --colors src tests",
"phpcsfix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --cache=.phpcs-cache src tests",
"binupdate": "@composer bin all update --ansi",
Expand Down
30 changes: 11 additions & 19 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Unit Tests">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Unit Tests">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion vendor-bin/phpcs/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"squizlabs/php_codesniffer": "^3.5",
"slevomat/coding-standard": "^5.0"
"slevomat/coding-standard": "^6.0"
}
}
2 changes: 1 addition & 1 deletion vendor-bin/psalm/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"vimeo/psalm": "^3.7"
"vimeo/psalm": "^4.0"
}
}

0 comments on commit 35b2e0e

Please sign in to comment.