Skip to content

Commit 0a35a5b

Browse files
committed
Amend documentation & configuration
1 parent e2cc191 commit 0a35a5b

13 files changed

+46
-3368
lines changed

.gitattributes

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
/tests export-ignore
22
/examples export-ignore
33
/docker export-ignore
4+
/vendor-bin export-ignore
5+
/.editorconfig export-ignore
46
/.gitattributes export-ignore
57
/.gitignore export-ignore
6-
/phpunit.xml.dist export-ignore
7-
/phpcs.xml.dist export-ignore
8-
/captainhook.json export-ignore
98
/.travis.yml export-ignore
10-
/ruleset.xml export-ignore
11-
/.editorconfig export-ignore
9+
/captainhook.json export-ignore
1210
/phpstan.neon export-ignore
13-
/phpstan_base.neon export-ignore
1411
/phpstan-baseline.neon export-ignore
12+
/phpunit.xml.dist export-ignore
1513
/psalm.xml export-ignore
1614
/psalm-baseline.xml export-ignore
17-
/vendor-bin export-ignore
15+
/ruleset.xml export-ignore

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
/composer.lock
33
/vendor
44
/vendor-bin/**/vendor
5-
/.phpunit*
5+
/vendor-bin/**/composer.lock
6+
/.phpunit.result.cache
7+
/.phpcs-cache
68
/tests/_output
79
/tests/_reports
810
/build

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ php:
88

99
before_script:
1010
- composer self-update
11-
- composer install --prefer-source --no-interaction --dev
11+
- composer install --prefer-source --no-interaction
12+
- composer bin all install
1213
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
1314
- chmod +x ./cc-test-reporter
1415
- ./cc-test-reporter before-build

README.md

+27-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PHP Syntax for Twig
22
===================
33

4-
[![Build Status](https://img.shields.io/travis/com/squirrelphp/twig-php-syntax.svg)](https://travis-ci.com/squirrelphp/twig-php-syntax) ![PHPStan](https://img.shields.io/badge/style-level%207-success.svg?style=flat-round&label=phpstan) [![Packagist Version](https://img.shields.io/packagist/v/squirrelphp/twig-php-syntax.svg?style=flat-round)](https://packagist.org/packages/squirrelphp/twig-php-syntax) [![PHP Version](https://img.shields.io/packagist/php-v/squirrelphp/twig-php-syntax.svg)](https://packagist.org/packages/squirrelphp/twig-php-syntax) [![Software License](https://img.shields.io/badge/license-MIT-success.svg?style=flat-round)](LICENSE)
4+
[![Build Status](https://img.shields.io/travis/com/squirrelphp/twig-php-syntax.svg)](https://travis-ci.com/squirrelphp/twig-php-syntax) [![Test Coverage](https://api.codeclimate.com/v1/badges/56ed1e15544f2bb7609e/test_coverage)](https://codeclimate.com/github/squirrelphp/twig-php-syntax/test_coverage) ![PHPStan](https://img.shields.io/badge/style-level%208-success.svg?style=flat-round&label=phpstan) [![Packagist Version](https://img.shields.io/packagist/v/squirrelphp/twig-php-syntax.svg?style=flat-round)](https://packagist.org/packages/squirrelphp/twig-php-syntax) [![PHP Version](https://img.shields.io/packagist/php-v/squirrelphp/twig-php-syntax.svg)](https://packagist.org/packages/squirrelphp/twig-php-syntax) [![Software License](https://img.shields.io/badge/license-MIT-success.svg?style=flat-round)](LICENSE)
55

66
Enables syntax known from PHP in Twig, so PHP developers can more easily create and edit twig templates. This is especially useful for small projects, where the PHP developers end up writing twig templates and it is not worth it to have a slightly different syntax in your templates.
77

@@ -27,16 +27,29 @@ Features
2727

2828
### === / !== strict comparison operators
2929

30-
Twig has the `same as` operator, or `==` which actually is not the same as `==` in PHP (it is a bit stricter). After being used to `===` and `!==` in PHP it is handy to just them for clarity.
30+
Twig has the `same as` test, which mimicks `===` in PHP, but has a syntax that can be hard to get used to. Using the strict comparison operators from PHP (`===` and `!==`) reduces friction, is familiar and less verbose.
3131

3232
```twig
3333
{% if 1 === 1 %}
34+
This will be shown
3435
{% endif %}
3536
37+
{% if 1 is same as(1) %}
38+
Same as above but with standard twig syntax
39+
{% endif %}
40+
41+
42+
{% if 1 === '1' %}
43+
This will not be shown, as 1 and '1' have different types (string vs. integer)
44+
{% endif %}
45+
46+
3647
{% if somevariable === "test" %}
48+
somevariable is of type string and equals "test"
3749
{% endif %}
3850
3951
{% if somevariable !== "test" %}
52+
somevariable either is not a string or does not equal "test"
4053
{% endif %}
4154
```
4255

@@ -71,7 +84,7 @@ You can use `break` with a number to break out of multiple loops, just like in P
7184
{% foreach list as sublist %}
7285
{% foreach sublist as entry %}
7386
{% if loop.index > 10 %}
74-
{% break 2 %} {# breaks out of both loops #}
87+
{% break 2 %} {# breaks out of both foreach loops #}
7588
{% endif %}
7689
{% endforeach %}
7790
{% endforeach %}
@@ -93,4 +106,14 @@ Adds a strict true/false test, so expressions become a bit more readable:
93106

94107
### && and ||
95108

96-
If you want to make expressions even more like PHP, you can use `&&` instead of `and` and `||` instead of `or`. This might be the least useful part of this library, as `and` and `or` are already short and clear, yet it is another easily remedied difference between twig and PHP.
109+
If you want to make expressions even more like PHP, you can use `&&` instead of `and` and `||` instead of `or`. This might be the least useful part of this library, as `and` and `or` are already short and clear, yet it is another easily remedied difference between twig and PHP, and `&&` and `||` can be easier to spot in comparison to `and` and `or`.
110+
111+
```twig
112+
{% if someflag === true && otherflag === false %}
113+
instead of if someflag === true and otherflag === false
114+
{% endif %}
115+
116+
{% if someflag === true || otherflag === true %}
117+
instead of if someflag === true or otherflag === false
118+
{% endif %}
119+
```

composer.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"require-dev": {
2424
"bamarni/composer-bin-plugin": "^1.3",
25-
"captainhook/plugin-composer": "^4.0"
25+
"captainhook/plugin-composer": "^5.0"
2626
},
2727
"config": {
2828
"sort-packages": false,
@@ -41,18 +41,17 @@
4141
}
4242
},
4343
"scripts": {
44-
"post-install-cmd": ["@composer bin all install --ansi"],
45-
"post-update-cmd": ["@composer bin all update --ansi"],
4644
"phpstan": "vendor/bin/phpstan analyse",
47-
"phpstan_base": "vendor/bin/phpstan analyse --configuration phpstan_base.neon --error-format baselineNeon > phpstan-baseline.neon",
45+
"phpstan_base": "vendor/bin/phpstan analyse --generate-baseline",
46+
"phpstan_clear": "vendor/bin/phpstan clear-result-cache",
4847
"psalm": "vendor/bin/psalm --show-info=false --diff",
4948
"psalm_full": "vendor/bin/psalm --show-info=false",
5049
"psalm_base": "vendor/bin/psalm --set-baseline=psalm-baseline.xml",
5150
"phpunit": "vendor/bin/phpunit --colors=always",
5251
"phpunit_clover": "vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml",
53-
"phpcs": "vendor/bin/phpcs --standard=ruleset.xml --extensions=php --cache src tests",
54-
"phpcsfix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --cache src tests",
5552
"codecoverage": "vendor/bin/phpunit --coverage-html tests/_reports",
53+
"phpcs": "vendor/bin/phpcs --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --colors src tests",
54+
"phpcsfix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --cache=.phpcs-cache src tests",
5655
"binupdate": "@composer bin all update --ansi",
5756
"bininstall": "@composer bin all install --ansi"
5857
}

phpstan-baseline.neon

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
parameters:
2+
ignoreErrors: []
3+

phpstan_base.neon

-5
This file was deleted.

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<phpunit
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.3/phpunit.xsd"
5+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.1/phpunit.xsd"
66
backupGlobals="false"
77
colors="true"
88
bootstrap="vendor/autoload.php"

ruleset.xml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<exclude name="Generic.Files.LineLength"/>
88
</rule>
99

10-
1110
<config name="installed_paths" value="../../slevomat/coding-standard"/>
1211

1312
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>

vendor-bin/phpcs/composer.lock

-157
This file was deleted.

vendor-bin/phpstan/composer.lock

-61
This file was deleted.

0 commit comments

Comments
 (0)