Commit Graph

791 Commits

Author SHA1 Message Date
Ben Ramsey c0a2ef7d15 Use correct phpcs configuration when running from Travis CI 2020-01-18 12:13:56 -06:00
Ben Ramsey ffc400e009 Change UuidInterface::getInteger() to always return a string value 2020-01-18 12:13:56 -06:00
Ben Ramsey b7f9dc5010 Check for RFC 4122, version 1 UUIDs with OrderedTimeCodec 2020-01-18 12:13:56 -06:00
Barney Laurance bdc9170edc Run Psalm on src as well as Static Analysis Fixture (#282)
* Run Psalm on src as well as Static Analysis Fixture

Psalm baselining feature is used to prevent immediate build failures -
psalm will just cause failures for errors caused by future changes to
the code.

See https://psalm.dev/docs/running_psalm/dealing_with_code_issues/#using-a-baseline-file

* Fix MixedArgument issues in OrderedTimeCodec

Potentially unpack should be documented as returning string[] instead of
array to make this unecassary.

* Fix Psalm PossiblyNullPropertyAssignmentValue issues

* Add psalm-immutable annotation to Uuid class

* Fix Psalm MixedArgument issues

* Fix MissingImmutableAnnotation psalm issue

* Fix Psalm MixedAssignment issue

* Fix Psalm InvalidReturnStatement / InvalidReturnType issue

* Add ImpureMethodCall issues to baseline.

Fixing these in one place just moves them somewhere else.

* Exclude psalm-baseline.xml from exported git archives
2020-01-18 12:13:56 -06:00
Marco Pivetta 27e1c4e073 Added psalm checks to CI integration configuration
This ensures that the added type annotations are enforced as the library
changes over time.
2020-01-18 12:13:55 -06:00
Marco Pivetta d01922dd14 Marked minimal parts of UuidInterface and Uuid named constructors as pure/immutable
This change is the minimum requirement to make the static analysis suite pass checks
on immutability/purity invariants of a `Uuid` and `UuidInterface`: it doesn't ensure
that internals of `Uuid` are pure. That will need deprecation of `Uuid::setFactory()`,
as well as marking any types referenced in private state as `@psalm-immutable` too.

That's out of scope for the current patch, which provides a good 80/20 split on purity
invariants for most (even advanced) UUID downstream users.
2020-01-18 12:13:55 -06:00
Marco Pivetta c935fbb0d9 Added minimal static analysis test suite to ensure purity/immutability of UUID API
This covers most of the commonly used `Uuid` and `UuidInterface` API, and allows us
to pass around `UuidInterface` references as if they were pure.

Note that this only verifies the *contract* of a `UuidInterface`: it is still very
much possible to write mutable `UuidInterface` implementations (and `Uuid` itself
has such an edge-case, allowing for replacement of the static `UuidFactory` reference),
but if you really do mutate UUIDs at runtime, then your code is very much hurting your
project, and you should get rid of that detail.
2020-01-18 12:13:55 -06:00
Marco Pivetta 17b390cc9c Disabled CS rule enforcing native type declarations where @param or @return are used instead
We can't use this rule for now, since changing interface type declarations is a major
BC break that is not worth introducing for now.
2020-01-18 12:13:55 -06:00
Marco Pivetta ba419f9715 Added vimeo/psalm dependency
`vimeo/psalm` won't be (for now) used to
scan the internals of the library, but just
the public API to be exposed to third parties
2020-01-18 12:13:55 -06:00
Marco Pivetta 667d42b5ce UuidInterface#getInteger() should return a string as per pre-existing declaration 2020-01-18 12:13:55 -06:00
Ben Ramsey 12896f06db Use internal exceptions
Fixes #254
2020-01-18 12:13:55 -06:00
Ben Ramsey 0d7b8c2b7a Update coding style to include PSR-12, among other options
This also includes heavy use of slevomat/coding-standard to apply
various checks to the code, based on maintainer (me) preference.
2020-01-18 12:13:55 -06:00
Ben Ramsey e2a56d62e6 Add link to CHANGELOG for 4.0.0-dev comparison with master 2020-01-18 12:13:10 -06:00
Massimiliano Arione 5459113b81 add typehints and return types 2020-01-18 12:13:10 -06:00
Ben Ramsey 3a42c259a7 Update unreleased CHANGELOG 2020-01-18 12:13:10 -06:00
Ben Ramsey 0721630ba4 Refactor converters to uniformly accept and return string values 2020-01-18 12:13:09 -06:00
Ben Ramsey 81f0f9a9b4 Clean-up tests and use PHPStan max level for tests 2020-01-18 12:13:09 -06:00
Carlos Barrero 650cb9f545 Change getDateTime to DateTimeInterface 2020-01-18 12:13:09 -06:00
Ben Ramsey 5f2eaa6d2d Add __toString() to UuidInterface
Resolves #111
2020-01-18 12:13:09 -06:00
Ben Ramsey 8544df0f40 Remove the MtRandGenerator 2020-01-18 12:13:09 -06:00
Ben Ramsey 05f3f16158 Remove the OpenSslGenerator 2020-01-18 12:13:09 -06:00
André Filipe bdfbf64a10 Removed some else/elseif and added some early returns to make the code a little easier to read, nothing changes on the big picture 2020-01-18 12:13:09 -06:00
Alessandro Minoccheri b234bec5b9 change array declarations 2020-01-18 12:13:09 -06:00
Julian Ecknig 4de1348099 Add GmpConverter and GmpTimeConverter 2020-01-18 12:13:09 -06:00
Bradyn Poulsen 3cf759ad05 Migrate isValid() to Validator and ValidatorInterface
* Maintain backwards compatibility with the former Uuid::isValid() and
  Uuid::VALID_PATTERN
* Remove the assert statements in favor of str_replace and preg_match
* Make the validator a featureset of the factory
* Remove old suggestion about locations of constants
* Remove argument count assertions
* Remove VALID_PATTERN from Uuid
2020-01-18 12:13:08 -06:00
Ben Ramsey 6f3316a1f7 Set minimum PHP version to 7.2 2020-01-18 12:13:08 -06:00
Ben Ramsey 506135cc6e Remove SodiumRandomGenerator generator class; it is no longer necessary 2020-01-18 12:13:08 -06:00
SignpostMarv 0030399564 Increase PHPStan levels and update code to resolve issues found 2020-01-18 12:13:08 -06:00
Viktor Szépe a2ba41740c Remove resolved errors from phpstan config 2020-01-18 12:13:08 -06:00
Martin Hujer ca2629767d Require phpstan and correct issues found up to level 2
* issues found by phpstan L0
* issues found by phpstan L1
* issues found by phpstan L2 in src/
* issues found by phpstan L2 in tests/
2020-01-18 12:13:08 -06:00
Martin Hujer 1eccd070c2 Add XSD schema to phpunit.xml.dist config
- Add XSD schema, so it can be validated (and PHPStorm provides
  auto-completion)
- Drop backupGlobals option, because false is the default value
2020-01-18 12:13:08 -06:00
Martin Hujer c5935bf963 Drop paragonie/random_compat from dependencies
It is not necessary anymore, because the minimal required version was
already set to PHP 7
2020-01-18 12:13:08 -06:00
Teoh Han Hui b6ca0903b9 Fix typo for PHP version requirement 2020-01-18 12:13:08 -06:00
Ben Ramsey 5d7ee63f1c Update dev requirements and test suite for PHP 7+ only 2020-01-18 12:13:07 -06:00
Martin Hujer 049d5acf7a Use ::class constants where possible
It helps with refactorings and static analysis, because you can easily
tell if the class is missing or not.
2020-01-18 12:13:07 -06:00
Jildert Miedema 225eb3b4c1 Set minimum version to PHP 5.6 and use PHP 5.5 style ::class constants 2020-01-18 12:13:07 -06:00
Mathieu TUDISCO e535e89708 Fix typo 2020-01-17 10:16:13 -06:00
Ben Ramsey eb1645bc72 Add behavior test for TimestampFirstCombCodec 2020-01-13 10:49:53 -06:00
Ben Ramsey da6fcde177 Add tests to ensure consistent behavior from 3.x to 4.x 2020-01-08 16:47:00 -06:00
Ben Ramsey f6da4ae7c5 Bump copyright year to 2020 2020-01-02 12:51:30 -06:00
Ben Ramsey 7779489a47 Fix CHANGELOG links 3.9.2 2019-12-17 02:18:51 -06:00
Ben Ramsey 21a981c29c Update CHANGELOG for 3.9.2 release 2019-12-17 02:04:50 -06:00
Ben Ramsey b39ec78f6e Check whether sysfs is readable before attempting to read it
Fixes #260
2019-12-17 02:01:14 -06:00
Ben Ramsey ed4223e250 Add scripts to build Docker images for alternate CPU arch testing 2019-12-06 21:45:23 -08:00
Ben Ramsey 2c87e46b63 Require builds on PHP 7.4 to pass and allow installation on PHP 8 2019-12-06 21:43:54 -08:00
Ben Ramsey 2ed5a60a61 Fix "access array offset on value of type null" errors 2019-12-06 21:24:32 -08:00
Ben Ramsey e1761af875 Disable deprecation messages for now 2019-12-06 17:55:09 -08:00
Ben Ramsey 0619916146 Turn of PHPUnit converting deprecations to exceptions 2019-12-06 17:06:07 -08:00
Ben Ramsey 0cc0217880 Mount the same path inside the container so coverage report is accurate 2019-12-06 15:52:08 -08:00
Ben Ramsey 7d82d45152 Do not proxy php-coveralls through the test container (if applicable) 2019-12-06 15:19:14 -08:00