The main scope of this extension is to help phpstan to detect the type of object after the Assert\Assertion validation.

Overview

PHPStan beberlei/assert extension

Build Latest Stable Version License

Description

The main scope of this extension is to help phpstan to detect the type of object after the Assert\Assertion validation.

 declare(strict_types = 1);
use Assert\Assertion;

function demo(?int $a) {
	// ...

	Assertion::integer($a);
	// phpstan is now aware that $a can no longer be `null` at this point

	return ($a === 10);
}

This extension specifies types of values passed to:

  • Assertion::integer
  • Assertion::integerish
  • Assertion::string
  • Assertion::float
  • Assertion::numeric
  • Assertion::boolean
  • Assertion::scalar
  • Assertion::objectOrClass
  • Assertion::isResource
  • Assertion::isCallable
  • Assertion::isArray
  • Assertion::isInstanceOf
  • Assertion::notIsInstanceOf
  • Assertion::subclassOf
  • Assertion::true
  • Assertion::false
  • Assertion::null
  • Assertion::notNull
  • Assertion::same
  • Assertion::notSame
  • Assertion::isJsonString
  • nullOr* and all* variants of the above methods

Assert::that, Assert::thatNullOr and Assert::thatAll chaining methods are also supported.

Assert\that, Assert\thatNullOr and Assert\thatAll functions are supported too.

Installation

To use this extension, require it in Composer:

composer require --dev phpstan/phpstan-beberlei-assert

If you also install phpstan/extension-installer then you're all set!

Manual installation

If you don't want to use phpstan/extension-installer, include extension.neon in your project's PHPStan config:

includes:
    - vendor/phpstan/phpstan-beberlei-assert/extension.neon
Comments
  • Assertion::isInstanceOf is not working as expected

    Assertion::isInstanceOf is not working as expected

    Given controller:

    # src/Controller/EventController.php
    <?php
    declare(strict_types=1);
    
    namespace App\Controller;
    
    use App\Entity\User;
    use Assert\Assertion;
    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
    use Symfony\Component\Routing\Annotation\Route;
    use Symfony\Component\Security\Core\User\UserInterface;
    
    class EventController
    {
        /**
         * @param UserInterface|User $user
         *
         * @return array
         * @Route("/events", name="event_list")
         * @Template(template="event/list.html.twig")
         *
         */
        public function __invoke(UserInterface $user): array
        {
            Assertion::isInstanceOf($user, User::class);
            $team = $user->getTeams();
            ...
    

    Given User class:

    <?php
    declare(strict_types=1);
    
    namespace App\Entity;
    
    ...
    use FOS\UserBundle\Model\User as BaseUser; # this one implements \Symfony\Component\Security\Core\User\UserInterface
    ...
    
    class User extends BaseUser
    {
        /**
         * @return Collection|Team[]
         */
        public function getTeams()
        {
            ...
        }
    

    Given phpstan.neon

    parameters:
        level: 3
        paths:
            - %currentWorkingDirectory%/src
        includes:
            - vendor/phpstan/phpstan-beberlei-assert/extension.neon
        excludes_analyse:
            - %currentWorkingDirectory%/src/Migrations/Version*.php
        parameters:
            symfony:
                container_xml_path: %rootDir%/../../../var/cache/dev/srcDevDebugProjectContainer.xml
    

    Given phpstan-output:

     ------ ----------------------------------------------------------------- 
      Line   Controller/EventController.php                                   
     ------ ----------------------------------------------------------------- 
      25     Call to an undefined method                                      
             Symfony\Component\Security\Core\User\UserInterface::getTeams().  
     ------ ----------------------------------------------------------------- 
    

    Expected phpstan-output:

     [OK] No errors  
    

    Am I missing something?

    PS: I have the same issue with https://github.com/phpstan/phpstan-webmozart-assert. I will open an issue there if this one gets confirmed and if it's not a misconfiguration or misuse on my side.

    opened by robertfausk 7
  • Invalid Assertion::eq evaluation

    Invalid Assertion::eq evaluation

        private function first()
        {
            $var = getenv('env');
            Assertion::eq($var, 'value');
            $this->second($var);
        }
    
        private function second(string $needsString)
        {
    
        }
    

    Returns

    Parameter #1 $needsString of method ::second() expects string, string|false given.

    Even though we know the possible set of types for $var is string when passed into second(). Or am I wrong?

    opened by simPod 3
  • Add support for integerish assertion

    Add support for integerish assertion

    I'd be great if the integerish assertion would also work, as its value is guaranteed to be either a string|float|int (almost like the scalar assertion minus the boolean type). I can work on a PR if needed.

    opened by acasademont 2
  • Update phpunit/phpunit requirement from ^7.5.20 to ^9.5.0

    Update phpunit/phpunit requirement from ^7.5.20 to ^9.5.0

    Updates the requirements on phpunit/phpunit to permit the latest version.

    Changelog

    Sourced from phpunit/phpunit's changelog.

    9.5.0 - 2020-12-04

    Changed

    • #4490: Emit Error instead of Warning when test case class cannot be instantiated
    • #4491: Emit Error instead of Warning when data provider does not work correctly
    • #4492: Emit Error instead of Warning when test double configuration is invalid
    • #4493: Emit error when (configured) test directory does not exist

    Fixed

    • #4535: getMockFromWsdl() does not handle methods that do not have parameters correctly
    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies php 
    opened by dependabot[bot] 2
  • Assert::that()->numeric() being marked as

    Assert::that()->numeric() being marked as "always evaluate to true"

    For the following code:

    class Bar
    {
        public function doBar(string $s)
        {
            Assert::that($s)->numeric();
        }
    }
    

    We're always getting the error:

    # Call to method Assert\AssertionChain::numeric() will always evaluate to true.
    

    I don't believe this is quite right, since we might have non-numeric strings, correct? Or are we doing something wrong?

    opened by lcobucci 2
  • Enhancement: Run ergebnis/composer-normalize in check target

    Enhancement: Run ergebnis/composer-normalize in check target

    This PR

    • [x] runs ergebnis/composer-normalize with the --dry-run option in the check target
    • [x] runs composer normalize
    • [x] keeps packages sorted in composer.json
    opened by localheinz 2
  • Should isJsonString() implicitly make type string?

    Should isJsonString() implicitly make type string?

    When using isJsonString. should the value type be changed to string? Can send PR if so.

    Eg.

    fcn(?string $value) : string {
        Assertion::isJsonString($value);
        return $value;
    }
    
    opened by simPod 2
  • Migrate to new `Type::getArrays()`

    Migrate to new `Type::getArrays()`

    • fixed what was mentioned in https://github.com/phpstan/phpstan-beberlei-assert/commit/8df4766e5a2c59bce668fe42d1cd575d68fb6f92#commitcomment-82796461
    opened by herndlm 1
  • Fix allSubclassOf test case

    Fix allSubclassOf test case

    Apparently this has been fixed in https://github.com/phpstan/phpstan-src/commit/73f14dbf82cf054f9ef7f57ffe3a2794e0e659e9 / https://github.com/phpstan/phpstan-src/pull/1039

    opened by herndlm 1
  • Bump metcalfc/changelog-generator from 1.0.0 to 3.0.0

    Bump metcalfc/changelog-generator from 1.0.0 to 3.0.0

    Bumps metcalfc/changelog-generator from 1.0.0 to 3.0.0.

    Release notes

    Sourced from metcalfc/changelog-generator's releases.

    Release v3.0.0

    This release changes the default order of commits in the changelog to match the command line default (chronological order). If you want to keep the old reverse chronological order there is a new action input you can set reverse:

          - name: Reverse the generated changelog
            id: changelog-rev
            uses: metcalfc/[email protected]
            with:
              myToken: ${{ secrets.GITHUB_TOKEN }}
              head-ref: 'v0.0.2'
              base-ref: 'v0.0.1'
              reverse: 'true'
    
    • 32988f6 - Bump eslint from 8.0.1 to 8.1.0
    • 2005b9a - Merge pull request #94 from metcalfc/dependabot/npm_and_yarn/eslint-8.1.0
    • 650acdc - Bump eslint from 8.1.0 to 8.2.0
    • 153d5bd - Merge pull request #95 from metcalfc/dependabot/npm_and_yarn/eslint-8.2.0
    • edf68eb - Bump @​vercel/ncc from 0.31.1 to 0.32.0
    • cc17b6d - Update tests for new reverse option.
    • 7daf4da - Change the order of logs to match git log.
    • 0fcd088 - Force the changelog action to use the current.
    • 0fe53bf - Revert "Bump @​vercel/ncc from 0.31.1 to 0.32.0"
    • a76f2c1 - Cleanup from ncc revert.
    • 6a73d83 - Bumping to 3.0.0 because adding reverse input as a breaking change.

    Release v2.0.0

    • e16f916 - Adding support for gitpod.
    • 7eb6ada - Convert to ES6.
    • c3f61b2 - Merge pull request #88 from metcalfc/es6
    • 291e473 - Bump eslint from 8.0.0 to 8.0.1
    • ff0e06b - Merge pull request #89 from metcalfc/dependabot/npm_and_yarn/eslint-8.0.1
    • 20f9702 - format code with yaml
    • 2d09b90 - Merge pull request #90 from wibbuffey/patch-1
    • a991ef7 - Update release.yml
    • 44ef091 - Ignore backticks when echoing the changelog.
    • 36466c9 - Remove backticks from markdown.
    • 225f098 - No markdown characters that mean anything in the shell.
    • 4a06273 - Include a test for the example in the README.
    • 3aa3286 - Adding an example for mutating the changelog.
    • b63471a - Note: Output format change.

    Release v1.0.1 - Downstream security fix included

    • ae42cbb - Merge pull request #56 from metcalfc/dependabot/npm_and_yarn/eslint-7.22.0
    • ca6b283 - Fixing yaml formating.
    • e5306b3 - 1.0.0
    • 717ba1a - Fixing yaml formating.
    • 6d1070a - 1.0.0
    • 6d002aa - Versions less then 1.0.0 aren't supported.
    • 173e8ae - Adding a helper makefile.

    ... (truncated)

    Commits
    • 6a73d83 Bumping to 3.0.0 because adding reverse input as a breaking change.
    • a76f2c1 Cleanup from ncc revert.
    • 0fe53bf Revert "Bump @​vercel/ncc from 0.31.1 to 0.32.0"
    • 0fcd088 Force the changelog action to use the current.
    • 7daf4da Change the order of logs to match git log.
    • cc17b6d Update tests for new reverse option.
    • edf68eb Bump @​vercel/ncc from 0.31.1 to 0.32.0
    • 153d5bd Merge pull request #95 from metcalfc/dependabot/npm_and_yarn/eslint-8.2.0
    • 650acdc Bump eslint from 8.1.0 to 8.2.0
    • 2005b9a Merge pull request #94 from metcalfc/dependabot/npm_and_yarn/eslint-8.1.0
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 1
  • Bump metcalfc/changelog-generator from 1.0.0 to 2.0.0

    Bump metcalfc/changelog-generator from 1.0.0 to 2.0.0

    Bumps metcalfc/changelog-generator from 1.0.0 to 2.0.0.

    Release notes

    Sourced from metcalfc/changelog-generator's releases.

    Release v2.0.0

    • e16f916 - Adding support for gitpod.
    • 7eb6ada - Convert to ES6.
    • c3f61b2 - Merge pull request #88 from metcalfc/es6
    • 291e473 - Bump eslint from 8.0.0 to 8.0.1
    • ff0e06b - Merge pull request #89 from metcalfc/dependabot/npm_and_yarn/eslint-8.0.1
    • 20f9702 - format code with yaml
    • 2d09b90 - Merge pull request #90 from wibbuffey/patch-1
    • a991ef7 - Update release.yml
    • 44ef091 - Ignore backticks when echoing the changelog.
    • 36466c9 - Remove backticks from markdown.
    • 225f098 - No markdown characters that mean anything in the shell.
    • 4a06273 - Include a test for the example in the README.
    • 3aa3286 - Adding an example for mutating the changelog.
    • b63471a - Note: Output format change.

    Release v1.0.1 - Downstream security fix included

    • ae42cbb - Merge pull request #56 from metcalfc/dependabot/npm_and_yarn/eslint-7.22.0
    • ca6b283 - Fixing yaml formating.
    • e5306b3 - 1.0.0
    • 717ba1a - Fixing yaml formating.
    • 6d1070a - 1.0.0
    • 6d002aa - Versions less then 1.0.0 aren't supported.
    • 173e8ae - Adding a helper makefile.
    • 0ce4e7a - Bump eslint from 7.22.0 to 7.23.0
    • ae91160 - Bump replace from 1.2.0 to 1.2.1
    • bf430f0 - [Security] Bump y18n from 4.0.0 to 4.0.1
    • e737180 - Merge pull request #57 from metcalfc/dependabot/npm_and_yarn/eslint-7.23.0
    • 523e0a7 - Merge pull request #58 from metcalfc/dependabot/npm_and_yarn/replace-1.2.1
    • 14b159a - Merge pull request #59 from metcalfc/dependabot/npm_and_yarn/y18n-4.0.1
    • a920419 - Bump eslint from 7.23.0 to 7.24.0
    • ac81346 - Bump @​actions/core from 1.2.6 to 1.2.7
    • 7524621 - Merge pull request #61 from metcalfc/dependabot/npm_and_yarn/eslint-7.24.0
    • 68d6336 - Merge pull request #62 from metcalfc/dependabot/npm_and_yarn/actions/core-1.2.7
    • 8444c6d - Bump eslint from 7.24.0 to 7.25.0
    • 1ef22b7 - Merge pull request #63 from metcalfc/dependabot/npm_and_yarn/eslint-7.25.0
    • 376b1f2 - Upgrade to GitHub-native Dependabot
    • b1018a1 - Merge pull request #64 from metcalfc/dependabot/add-v2-config-file
    • 2574596 - fix typos, grammar, odds-ends.
    • 361ebd7 - Bump prettier from 2.2.1 to 2.3.0
    • 3786790 - Bump @​actions/github from 4.0.0 to 5.0.0
    • 72c4c86 - Bump @​actions/core from 1.2.7 to 1.3.0
    • f0d71e2 - Bump eslint from 7.25.0 to 7.27.0
    • 1b91dad - Merge pull request #69 from metcalfc/dependabot/npm_and_yarn/actions/core-1.3.0
    • 4c74af2 - Merge pull request #67 from metcalfc/dependabot/npm_and_yarn/prettier-2.3.0
    • a21127a - Merge pull request #70 from metcalfc/dependabot/npm_and_yarn/eslint-7.27.0
    • 6fab1d9 - Merge pull request #68 from metcalfc/dependabot/npm_and_yarn/actions/github-5.0.0
    • ba54dec - Bump prettier from 2.3.0 to 2.3.1
    • b20fa05 - Merge pull request #71 from metcalfc/dependabot/npm_and_yarn/prettier-2.3.1
    • ee9eb96 - Bump eslint from 7.27.0 to 7.28.0

    ... (truncated)

    Commits
    • b63471a Note: Output format change.
    • 3aa3286 Adding an example for mutating the changelog.
    • 4a06273 Include a test for the example in the README.
    • 225f098 No markdown characters that mean anything in the shell.
    • 36466c9 Remove backticks from markdown.
    • 44ef091 Ignore backticks when echoing the changelog.
    • a991ef7 Update release.yml
    • 2d09b90 Merge pull request #90 from wibbuffey/patch-1
    • 20f9702 format code with yaml
    • ff0e06b Merge pull request #89 from metcalfc/dependabot/npm_and_yarn/eslint-8.0.1
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 1
  • Update build-cs (major)

    Update build-cs (major)

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | dealerdirect/phpcodesniffer-composer-installer (source) | require-dev | major | ^0.7.0 -> ^1.0.0 | | slevomat/coding-standard | require-dev | major | ^7.0 -> ^8.0 |


    Release Notes

    Dealerdirect/phpcodesniffer-composer-installer

    v1.0.0

    Compare Source

    What's Changed

    New Contributors

    Full Changelog: https://github.com/PHPCSStandards/composer-installer/compare/v0.7.2...v1.0.0

    slevomat/coding-standard

    v8.7.1

    Compare Source

    🐛 Fixes

    • SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing: Fixed false positive when parameter has attribute but no type hint

    v8.7.0

    Compare Source

    🔧 Improvements

    • Support for phpstan/phpdoc-parser 1.15
    • Support for phpstan/phpdoc-parser 1.14
    • SlevomatCodingStandard.Attributes.AttributesOrder: New option orderAlphabetically
    • SlevomatCodingStandard.Attributes.AttributesOrder: Attributes could be ordered by mask (thanks to @​alexndlm)

    🐛 Fixes

    • SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing: Fixed fixer

    v8.6.4

    Compare Source

    🔧 Improvements

    • Improved annotations parsing
    • SlevomatCodingStandard.Classes.ClassConstantVisibility: Added support for traits with constants
    • SlevomatCodingStandard.Classes.ConstantSpacing: Added support for traits with constants

    🐛 Fixes

    • SlevomatCodingStandard.Attributes.DisallowAttributesJoining: Fix for attribute with trailing comma (thanks to @​javer)

    v8.6.3

    Compare Source

    🐛 Fixes

    • Slevomat.Namespaces.ReferenceUsedNamesOnly: Fixed fixer when there's conflict with Slevomat.Namespaces.UnusedUses
    • SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation: Fixed false positives for int<0, max> and int<min, 100>
    • SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing: Fixed false positive for comment after attribute

    v8.6.2

    Compare Source

    🐛 Fixes

    • SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation: Fixed false positive with self::CONSTANT

    v8.6.1

    Compare Source

    🔧 Improvements

    • Support of phpstan/phpdoc-parser 1.12.0

    🐛 Fixes

    • SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation: Fixed false positives for global constants
    • SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration: Fixed false positives for constants

    v8.6.0

    Compare Source

    🆕 New sniffs

    • Added SlevomatCodingStandard.Attributes.AttributesOrder
    • Added SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing
    • Added SlevomatCodingStandard.Attributes.DisallowMultipleAttributesPerLine
    • Added SlevomatCodingStandard.Attributes.DisallowAttributesJoining (thanks to @​michnovka)
    • Added SlevomatCodingStandard.Attributes.RequireAttributeAfterDocComment

    🔧 Improvements

    • Support of phpstan/phpdoc-parser 1.11.0
    • Support for @phpstan-self-out/@phpstan-this-out
    • Support for @param-out annotation`
    • Support for @template with default value
    • Add dev Composer keyword (thanks to @​GaryJones)

    🐛 Fixes

    • Improved detection of references in double quotes strings

    v8.5.2

    Compare Source

    🐛 Fixes

    • SlevomatCodingStandard.TypeHints.PropertyTypeHint: Fixed false positives when enableUnionTypeHint is disabled and enableIntersectionTypeHint is enabled
    • SlevomatCodingStandard.TypeHints.ParameterTypeHint: Fixed false positives when enableUnionTypeHint is disabled and enableIntersectionTypeHint is enabled
    • SlevomatCodingStandard.TypeHints.ReturnTypeHint: Fixed false positives when enableUnionTypeHint is disabled and enableIntersectionTypeHint is enabled

    v8.5.1

    Compare Source

    🐛 Fixes

    • SlevomatCodingStandard.PHP.RequireExplicitAssertion: Fixed broken fixer when enableAdvancedStringTypes is enabled

    v8.5.0

    Compare Source

    🔧 Improvements

    • PHP 8.2: Support for standalone null, true and false type hints
    • SlevomatCodingStandard.PHP.RequireExplicitAssertion: Improved support for native simple types
    • SlevomatCodingStandard.PHP.RequireExplicitAssertion: New option enableIntegerRanges
    • SlevomatCodingStandard.PHP.RequireExplicitAssertion: New option enableAdvancedStringTypes
    • Support of phpstan/phpdoc-parser 1.8.0

    🐛 Fixes

    • SlevomatCodingStandard.Classes.PropertyDeclaration: Fixed false positive
    • SlevomatCodingStandard.PHP.RequireExplicitAssertion: Fixed false positive
    • SlevomatCodingStandard.ControlStructures.DisallowYodaComparison/RequireYodaComparison: Fixed support for condition in arrow function
    • SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition: Fixed false positives for old array definition style
    • SlevomatCodingStandard.Variables.UselessVariable: Fixed false positives

    v8.4.0

    Compare Source

    🔧 Improvements

    • Support of phpstan/phpdoc-parser 1.7.0

    🐛 Fixes

    • Fixed detection of some PHP 8.1 types
    • SlevomatCodingStandard.PHP.RequireNowdoc: Accepts escaped sequences (thanks to @​dg)
    • SlevomatCodingStandard.Functions.RequireSingleLineCall: Skip calls with multi-line double-quoted string (thanks to @​schlndh)
    • SlevomatCodingStandard.PHP.UselessParentheses: Fixed false positive with xor
    • SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator: Try to ignore string offsets

    v8.3.0

    Compare Source

    🆕 New sniffs

    • Added SlevomatCodingStandard.Complexity.Cognitive (thanks to @​bkdotcom)
    • Added SlevomatCodingStandard.Files.FileLength (thanks to @​bkdotcom)
    • Added SlevomatCodingStandard.Classes.ClassLength (thanks to @​bkdotcom)

    🐛 Fixes

    • SlevomatCodingStandard.PHP.RequireExplicitAssertion: Do not throw away static type (thanks to @​simPod)

    v8.2.0

    Compare Source

    🆕 New sniffs

    • Added SlevomatCodingStandard.Classes.BackedEnumTypeSpacing

    🔧 Improvements

    • SlevomatCodingStandard.TypeHints.ParameterTypeHint: MissingTraversableTypeHintSpecification is not reported when promoted property has @var annotation

    v8.1.0

    Compare Source

    🔧 Improvements

    • SlevomatCodingStandard.Classes.PropertyDeclaration: New option checkPromoted to enable check of promoted properties
    • SlevomatCodingStandard.Classes.PropertyDeclaration: New option enableMultipleSpacesBetweenModifiersCheck to enable check of spaces between property modifiers
    • SlevomatCodingStandard.Classes.PropertyDeclaration: Improved error messages
    • SlevomatCodingStandard.Classes.ForbiddenPublicProperty: New option checkPromoted to enable check of promoted properties

    🐛 Fixes

    • SlevomatCodingStandard.TypeHints.PropertyTypeHint: Fix inconsistent enableIntersectionTypeHint (thanks to @​schlndh)

    v8.0.1

    Compare Source

    🐛 Fixes

    • Group use statements are ignored - we don't support them
    • SlevomatCodingStandard.PHP.UselessParentheses: Fixed false positive
    • SlevomatCodingStandard.TypeHints.ParameterTypeHint: Fixed internal error (thanks to @​schlndh)

    v8.0.0

    Compare Source

    🔧 Improvements

    • Support for intersection types
    • Support for readonly properties
    • Support for enums
    • Support for never type hint
    • Support for more unofficial type hints
    • SlevomatCodingStandard.Classes.PropertyDeclaration: Checks also order of modifiers
    • SlevomatCodingStandard.Classes.ClassStructure: Support for enum cases and readonly properties

    🐛 Fixes

    • SlevomatCodingStandard.Classes.PropertyDeclaration: Fixed missing support for only static property
    • SlevomatCodingStandard.TypeHints.PropertyTypeHint: Fixed missing support for only static property
    • SlevomatCodingStandard.Commenting.EmptyComment: Fixed internal error
    • SlevomatCodingStandard.Classes.ForbiddenPublicProperty: Fixed internal error
    • SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation: Fixed false positives for @psalm-import-type in @psalm-var
    • SlevomatCodingStandard.PHP.RequireExplicitAssertion: Ignore unsupported unofficial type hints

    ⚠️BC breaks

    • SlevomatCodingStandard.TypeHints.PropertyTypeHintSpacing renamed to SlevomatCodingStandard.Classes.PropertyDeclaration
    • SlevomatCodingStandard.Classes.ClassStructure: Removed option enableFinalMethods
    • Removed error SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity

    Configuration

    📅 Schedule: Branch creation - "before 3am on Monday" (UTC), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 1
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    Awaiting Schedule

    These updates are awaiting their schedule. Click on a checkbox to get an update now.

    • [ ] Update dependency consistence-community/coding-standard to v3.11.2

    Open

    These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

    Detected dependencies

    composer
    build-cs/composer.json
    • consistence-community/coding-standard ^3.10
    • dealerdirect/phpcodesniffer-composer-installer ^0.7.0
    • slevomat/coding-standard ^7.0
    composer.json
    • php ^7.2 || ^8.0
    • phpstan/phpstan ^1.9.0
    • beberlei/assert ^3.3.0
    • nikic/php-parser ^4.13.0
    • php-parallel-lint/php-parallel-lint ^1.2
    • phpstan/phpstan-phpunit ^1.0
    • phpstan/phpstan-strict-rules ^1.0
    • phpunit/phpunit ^9.5
    github-actions
    .github/workflows/build.yml
    • actions/checkout v3
    • shivammathur/setup-php v2
    • actions/checkout v3
    • shivammathur/setup-php v2
    • actions/checkout v3
    • shivammathur/setup-php v2
    • actions/checkout v3
    • shivammathur/setup-php v2
    .github/workflows/create-tag.yml
    • actions/checkout v3
    • WyriHaximus/github-action-get-previous-tag v1
    • WyriHaximus/github-action-next-semvers v1
    • rickstaa/action-create-tag v1
    • rickstaa/action-create-tag v1
    .github/workflows/lock-closed-issues.yml
    • dessant/lock-threads v4
    .github/workflows/release-toot.yml
    • cbrgm/mastodon-github-action v1
    .github/workflows/release-tweet.yml
    • Eomm/why-don-t-you-tweet v1
    .github/workflows/release.yml
    • actions/checkout v3
    • metcalfc/changelog-generator v4.0.1
    • actions/create-release v1

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
  • Assertion::inArray w/ constant array support

    Assertion::inArray w/ constant array support

    Should specify type to a union of the array values.

    $format = $_GET['foo'];
    
    Assertion::inArray($format, [ // or Assertion::choice
        ExportFormat::FORMAT_CSV,
        ExportFormat::FORMAT_EXCEL,
    ]);
    
    \PhpStan\dumpType($format); // ExportFormat::FORMAT_CSV|ExportFormat::FORMAT_EXCEL
    
    opened by b1rdex 0
  • Chainable types do not work

    Chainable types do not work

    the following code:

    <?php
    
    declare(strict_types=1);
    
    use Assert\Assert;
    
    class Result
    {
        private ?float $percent;
    
        private function __construct()
        {
        }
    
        /** @param array<string, mixed> $payload */
        public static function fromQueryResults(array $payload): self
        {
            Assert::that($payload['percent'])
                ->nullOr()
                ->string()
                ->numeric();
    
            $floatOrNull = static fn (?string $value): ?float => null === $value ? null : (float) $value;
    
            $instance = new self();
            $instance->percent = $floatOrNull($payload['percent']);
    
            return $instance;
        }
    }
    

    Produces the error: Parameter #1 $value of closure expects string|null, float|int|string|null given.

    The type of $payload['percent'] should be infered to string|null, not float|int|string|null

    opened by bendavies 0
  • Assert::that conditions are not working as expected

    Assert::that conditions are not working as expected

    Given this case https://phpstan.org/r/ea5dfda5-33b6-49e7-8e5f-1db4214533e4 I'd expect that method withAssertwill work just like withIf. PhpStan will however throw following error

    Offset 'host' does not exist on false|array('scheme' => string, ?'host' => string, ?'port' => int, ?'user' => string, ?'pass' => string, ?'query' => string, ?'fragment' => string). |
    

    I know that phpstan/phpstan-beberlei-assert is not integrated in the web-tester, but the same will happen locally when it is.

    opened by meridius 0
Releases(1.0.1)
Owner
PHPStan
PHP Static Analysis Tool - discover bugs in your code without running it!
PHPStan
A PocketMine-MP plugin that replaces a block to another block when breaks, then back to the original block after a certain time

BlockReplacer A PocketMine-MP plugin that replaces a block to another block when breaks, then back to the original block after a certain time How to I

AIPTU 11 Sep 2, 2022
WeExpire is an opensource tool for creating emergency notes that can be read by your trusted contacts only after your death or if you are seriously injured

WeExpire is an opensource tool for creating emergency notes that can be read by your trusted contacts only after your death or if you are

Francesco 36 Nov 24, 2022
PHPStan extension to support #[Readonly] constructor properties

icanhazstring/phpstan-readonly-property Support #[Readonly] promoted constructor properties for PHPStan. This library is used to have a full transitio

Andreas Frömer 4 Apr 5, 2022
Magento specific extension for phpstan

bitexpert/phpstan-magento This package provides some additional features for PHPStan to make it work for Magento 2 projects. Installation The preferre

bitExpert AG 92 Dec 7, 2022
PHPStan extension for webmozart/assert

PHPStan webmozart/assert extension PHPStan webmozart/assert Description The main scope of this extension is to help phpstan to detect the type of obje

PHPStan 139 Dec 22, 2022
An extension for PHPStan for adding analysis for PHP Language Extensions.

PHPStan PHP Language Extensions (currently in BETA) This is an extension for PHPStan for adding analysis for PHP Language Extensions. Language feature

Dave Liddament 9 Nov 30, 2022
PHPStan extension for sealed classes and interfaces.

Sealed classes with PHPStan This extension adds support for sealed classes and interfaces to PHPStan. Installation To use this extension, require it v

Jiří Pudil 14 Nov 28, 2022
Extension for PHPStan to allow analysis of Drupal code.

phpstan-drupal Extension for PHPStan to allow analysis of Drupal code. Sponsors Would you like to sponsor? Usage When you are using phpstan/extension-

Matt Glaman 154 Jan 2, 2023
The Simple Result Type simply returns the processing result as an object.

The Simple Result Type The Simple Result Type simply returns the processing result as an object. Enjoy! Example This is a basic usage example. use Tak

null 1 Mar 23, 2022
Type and shape system for arrays. Help write clearer code when implementing configs for your PocketMine-MP plugin or composer project.

ConfigStruct Type and shape system for arrays. Help write clearer code when implementing configs for your PocketMine-MP plugin or composer project. It

EndermanbugZJFC 9 Aug 22, 2022
An article about alternative solution for convert object into a JSON Object for your api.

Do we really need a serializer for our JSON API? The last years I did build a lot of JSON APIs but personally was never happy about the magic of using

Alexander Schranz 1 Feb 1, 2022
Your alter ego object. Takes the best of object and array worlds.

Supporting Opensource formapro\values is an MIT-licensed open source project with its ongoing development made possible entirely by the support of com

FormaPro 31 Jun 25, 2021
[READ-ONLY] CakePHP Utility classes such as Inflector, Text, Hash, Security and Xml. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Utility Classes This library provides a range of utility classes that are used throughout the CakePHP framework What's in the toolbox? Hash A

CakePHP 112 Feb 15, 2022
Wcdek - Main plugin.

=== WCdek > Integration of WooCommerce and CDEK === Contributors: WCdek, Digiom Tags: cdek, сдэк, delivery, woocommerce, woo, доставка, woo commerce R

WCDEK 0 Jun 12, 2022
The main website source code based on php , html/css/js and an independent db system using xml/json.

jsm33t.com Well umm, a neat website LIVE SITE » View Demo · Report Bug · Request a feature About The Project Desc.. Built Using Php UI Frameworks Boot

Jasmeet Singh 5 Nov 23, 2022
QuidPHP/Main is a PHP library that provides a set of base objects and collections that can be extended to build something more specific.

QuidPHP/Main is a PHP library that provides a set of base objects and collections that can be extended to build something more specific. It is part of the QuidPHP package and can also be used standalone.

QuidPHP 4 Jul 2, 2022
FFCMS 3 version core MVC architecture. Build-on use with ffcms main architecture builder.

FFCMS 3 version core MVC architecture. Build-on use with ffcms main architecture builder.

FFCMS 0 Feb 25, 2022
Main ABRouter product repository that contains docker-compose file and orchestrates the project containers.

ABRouter-Compose ?? ABRouter is the open-source tool to perform and track A/B tests which is also known as the experiments. Additionally, feature flag

ABRouter 29 Dec 22, 2022