-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from Ocramius/feature/pure-enumerable
Added purity markers for enumerables, improved type definitions
- Loading branch information
Showing
7 changed files
with
342 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/.github export-ignore | ||
/bench export-ignore | ||
/tests export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.travis.yml export-ignore | ||
phpbench.json export-ignore | ||
phpunit.xml.dist export-ignore | ||
psalm.xml export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,76 @@ | ||
sudo: false | ||
language: php | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
- $HOME/.local | ||
- $HOME/ocular.phar | ||
- $HOME/phpDocumentor.phar | ||
|
||
env: | ||
global: | ||
- CODE_COVERAGE="0" | ||
- PHPDOC="0" | ||
|
||
matrix: | ||
fast_finish: true | ||
include: | ||
- php: 7.1 | ||
env: | ||
- CODE_COVERAGE="1" | ||
- php: 7.2 | ||
env: | ||
- CODE_COVERAGE="1" | ||
- PHPDOC="1" | ||
- php: 7.3 | ||
env: | ||
- CODE_COVERAGE="1" | ||
- php: 7.4 | ||
env: | ||
- CODE_COVERAGE="1" | ||
- php: nightly | ||
allow_failures: | ||
- php: nightly | ||
|
||
install: | ||
- if [ "${CODE_COVERAGE}" == "0" ]; then | ||
phpenv config-rm xdebug.ini || return 0; | ||
fi | ||
- if [ "${CODE_COVERAGE}" == "1" ]; then | ||
wget -q -N -t 3 --retry-connrefused 'https://scrutinizer-ci.com/ocular.phar' || return 0; | ||
fi | ||
- if [ "${PHPDOC}" == "1" ]; then | ||
wget -q -N -t 3 --retry-connrefused 'https://github.com/phpDocumentor/phpDocumentor2/releases/download/v2.9.0/phpDocumentor.phar' || return 0; | ||
composer require --no-update --dev "evert/phpdoc-md:~0.2.0" || return 0; | ||
fi | ||
- composer install -n | ||
|
||
script: | ||
- if [ "$CODE_COVERAGE" == "1" ]; then | ||
php -d 'zend.assertions=1' vendor/bin/phpunit --verbose --coverage-text --coverage-clover=coverage.clover; | ||
else | ||
php -d 'zend.assertions=1' vendor/bin/phpunit --verbose; | ||
fi | ||
|
||
# run benchmarks to make sure they are working fine | ||
- php vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 | ||
|
||
after_script: | ||
- if [ "${CODE_COVERAGE}" == "1" ]; then | ||
php ocular.phar code-coverage:upload --format=php-clover coverage.clover; | ||
fi | ||
- if [ "${PHPDOC}" == "1" ]; then | ||
git clone "https://${CI_USER_TOKEN}@github.com/marc-mabe/php-enum.wiki.git" && | ||
php phpDocumentor.phar -d src -t docs/ --template="xml" && | ||
php vendor/bin/phpdocmd --lt '%c' --index 'Home.md' docs/structure.xml php-enum.wiki/ && | ||
cp php-enum.wiki/Home.md php-enum.wiki/_Sidebar.md && | ||
cd php-enum.wiki/ && | ||
git add . && | ||
git commit -m "auto generated PHP doc" && | ||
git push origin master:master; | ||
fi | ||
|
||
notifications: | ||
email: false | ||
sudo: false | ||
language: php | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
- $HOME/.local | ||
- $HOME/ocular.phar | ||
- $HOME/phpDocumentor.phar | ||
|
||
env: | ||
global: | ||
- CODE_COVERAGE="0" | ||
- PHPDOC="0" | ||
|
||
matrix: | ||
fast_finish: true | ||
include: | ||
- php: 7.1 | ||
env: | ||
- CODE_COVERAGE="1" | ||
- php: 7.2 | ||
env: | ||
- CODE_COVERAGE="1" | ||
- PHPDOC="1" | ||
- php: 7.3 | ||
env: | ||
- CODE_COVERAGE="1" | ||
- php: 7.4 | ||
env: | ||
- CODE_COVERAGE="1" | ||
- php: nightly | ||
allow_failures: | ||
- php: nightly | ||
|
||
install: | ||
- if [ "${CODE_COVERAGE}" == "0" ]; then | ||
phpenv config-rm xdebug.ini || return 0; | ||
fi | ||
- if [ "${CODE_COVERAGE}" == "1" ]; then | ||
wget -q -N -t 3 --retry-connrefused 'https://scrutinizer-ci.com/ocular.phar' || return 0; | ||
fi | ||
- if [ "${PHPDOC}" == "1" ]; then | ||
wget -q -N -t 3 --retry-connrefused 'https://github.com/phpDocumentor/phpDocumentor2/releases/download/v2.9.0/phpDocumentor.phar' || return 0; | ||
composer require --no-update --dev "evert/phpdoc-md:~0.2.0" || return 0; | ||
fi | ||
- composer install -n | ||
|
||
script: | ||
- if [ "$CODE_COVERAGE" == "1" ]; then | ||
php -d 'zend.assertions=1' vendor/bin/phpunit --verbose --coverage-text --coverage-clover=coverage.clover; | ||
else | ||
php -d 'zend.assertions=1' vendor/bin/phpunit --verbose; | ||
fi | ||
|
||
# run benchmarks to make sure they are working fine | ||
- php vendor/bin/phpbench run --no-interaction --revs=1 --retry-threshold=100 | ||
- vendor/bin/psalm | ||
|
||
after_script: | ||
- if [ "${CODE_COVERAGE}" == "1" ]; then | ||
php ocular.phar code-coverage:upload --format=php-clover coverage.clover; | ||
fi | ||
- if [ "${PHPDOC}" == "1" ]; then | ||
git clone "https://${CI_USER_TOKEN}@github.com/marc-mabe/php-enum.wiki.git" && | ||
php phpDocumentor.phar -d src -t docs/ --template="xml" && | ||
php vendor/bin/phpdocmd --lt '%c' --index 'Home.md' docs/structure.xml php-enum.wiki/ && | ||
cp php-enum.wiki/Home.md php-enum.wiki/_Sidebar.md && | ||
cd php-enum.wiki/ && | ||
git add . && | ||
git commit -m "auto generated PHP doc" && | ||
git push origin master:master; | ||
fi | ||
|
||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0"?> | ||
<psalm | ||
totallyTyped="true" | ||
errorLevel="1" | ||
resolveFromConfigFile="true" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="https://getpsalm.org/schema/config" | ||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | ||
> | ||
<projectFiles> | ||
<directory name="tests/MabeEnumStaticAnalysis" /> | ||
<ignoreFiles> | ||
<directory name="vendor" /> | ||
</ignoreFiles> | ||
</projectFiles> | ||
</psalm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MabeEnumStaticAnalysis; | ||
|
||
use MabeEnum\Enum; | ||
|
||
/** @psalm-immutable enums are immutable */ | ||
final class DummyEnum extends Enum | ||
{ | ||
public const A = 'A_VALUE'; | ||
public const B = 'B_VALUE'; | ||
|
||
/** @psalm-pure */ | ||
public static function a(): self | ||
{ | ||
return self::get(self::A); | ||
} | ||
|
||
/** @psalm-pure */ | ||
public static function b(): self | ||
{ | ||
return self::get(self::B); | ||
} | ||
} |
Oops, something went wrong.