<?xml version="1.0"?>
<psalm
    useDocblockTypes="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="database/seeds" />
        <directory name="database/migrations" />
        <directory name="app" />
        <directory name="routes" />
        <ignoreFiles>
            <directory name="vendor" />
            <file name="app/Helpers/helpers.php" />
        </ignoreFiles>
    </projectFiles>

    <plugins>
        <pluginClass class="Psalm\LaravelPlugin\Plugin" />
    </plugins>

    <issueHandlers>
        <LessSpecificReturnType errorLevel="info" />

        <!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->

        <DeprecatedMethod errorLevel="info" />

        <MissingClosureReturnType errorLevel="info" />
        <MissingReturnType errorLevel="info" />
        <MissingPropertyType errorLevel="error" />
        <InvalidDocblock errorLevel="error" />

        <PropertyNotSetInConstructor errorLevel="info" />
        <MissingConstructor errorLevel="info" />
        <MissingParamType errorLevel="info" />
        <MissingClosureParamType errorLevel="info" />

        <DocblockTypeContradiction errorLevel="info" />
        <RedundantConditionGivenDocblockType errorLevel="info" />

        <!-- level 4 issues - points to possible deficiencies in logic, higher false-positives -->

        <MismatchingDocblockReturnType errorLevel="info" />
        <MismatchingDocblockParamType errorLevel="info" />

        <MoreSpecificReturnType errorLevel="info" />
        <LessSpecificReturnStatement errorLevel="info" />
        <ArgumentTypeCoercion errorLevel="info" />
        <RedundantCondition errorLevel="info" />

        <PossiblyFalseArgument errorLevel="info" />
        <PossiblyFalsePropertyAssignmentValue errorLevel="info" />
        <PossiblyFalseReference errorLevel="info" />
        <PossiblyInvalidArgument errorLevel="info" />
        <PossiblyInvalidArrayAccess errorLevel="info" />
        <PossiblyInvalidArrayAssignment errorLevel="info" />
        <PossiblyInvalidMethodCall errorLevel="info" />
        <PossiblyInvalidPropertyAssignment errorLevel="info" />
        <PossiblyInvalidPropertyAssignmentValue errorLevel="info" />
        <PossiblyInvalidPropertyFetch errorLevel="info" />
        <PossiblyNullArgument errorLevel="info" />
        <PossiblyNullArrayAccess errorLevel="info" />
        <PossiblyNullArrayAssignment errorLevel="info" />
        <PossiblyNullArrayOffset errorLevel="info" />
        <PossiblyNullFunctionCall errorLevel="info" />
        <PossiblyNullIterator errorLevel="info" />
        <PossiblyNullOperand errorLevel="info" />
        <PossiblyNullPropertyAssignment errorLevel="info" />
        <PossiblyNullPropertyAssignmentValue errorLevel="info" />
        <PossiblyNullPropertyFetch errorLevel="info" />
        <PossiblyNullReference errorLevel="info" />

        <!-- level 5 issues - should be avoided at mosts costs... -->

        <ForbiddenCode errorLevel="info" />
        <ImplicitToStringCast errorLevel="info" />
        <InvalidScalarArgument errorLevel="info" />
        <InvalidToString errorLevel="info" />
        <MethodSignatureMismatch errorLevel="info" />
        <NoInterfaceProperties errorLevel="info" />
        <TooManyArguments errorLevel="info" />
        <TypeDoesNotContainType errorLevel="info" />
        <InvalidOperand errorLevel="info" />
        <LessSpecificImplementedReturnType errorLevel="info" />
        <MoreSpecificImplementedParamType errorLevel="info" />
        <InternalMethod errorLevel="suppress" />

        <!-- level 6 issues - bad stuff here -->

        <InvalidNullableReturnType errorLevel="info" />
        <NullableReturnStatement errorLevel="info" />
        <ImplementedReturnTypeMismatch errorLevel="info" />
        <UnresolvableInclude errorLevel="info" />
        <InvalidReturnStatement errorLevel="info" />
        <InvalidReturnType errorLevel="info" />

        <InvalidArgument errorLevel="info" />

        <PossiblyUndefinedMethod errorLevel="info" />
        <ReservedWord errorLevel="info" />
        <UndefinedInterfaceMethod errorLevel="info" />

        <!-- Personal fixes -->
        <UndefinedMagicPropertyFetch errorLevel="suppress" />
        <InvalidPropertyAssignmentValue errorLevel="suppress" />

        <UndefinedPropertyAssignment>
            <errorLevel type="suppress">
                <file name="database/migrations/2017_07_26_220021_change_contacts_table.php" />
            </errorLevel>
        </UndefinedPropertyAssignment>

        <UndefinedMagicPropertyAssignment>
            <errorLevel type="suppress">
                <file name="database/migrations/2017_08_06_153253_move_kids_to_contacts.php" />
            </errorLevel>
        </UndefinedMagicPropertyAssignment>

        <UndefinedPropertyFetch>
            <errorLevel type="suppress">
                <file name="app/Services/VCalendar/ImportTask.php" />
            </errorLevel>
        </UndefinedPropertyFetch>

        <UndefinedMagicMethod>
            <errorLevel type="suppress">
                <file name="app/Traits/Searchable.php" />
                <file name="app/Http/Controllers/SettingsController.php" />
                <file name="app/Http/Controllers/Api/ApiContactController.php" />
                <file name="app/Http/Controllers/Contacts/RelationshipsController.php" />
            </errorLevel>
        </UndefinedMagicMethod>

        <InvalidReturnType>
            <errorLevel type="suppress">
                <file name="app/Http/Controllers/Auth/RegisterController.php" />
            </errorLevel>
        </InvalidReturnType>

        <PossibleRawObjectIteration>
            <errorLevel type="suppress">
                <file name="app/Helpers/AuditLogHelper.php" />
            </errorLevel>
        </PossibleRawObjectIteration>
        <RawObjectIteration>
            <errorLevel type="suppress">
                <file name="app/Http/Controllers/Contacts/ContactAuditLogController.php" />
            </errorLevel>
        </RawObjectIteration>

        <TooManyTemplateParams errorLevel="info" />
        <NonInvariantDocblockPropertyType errorLevel="info" />

        <InvalidScope>
            <errorLevel type="suppress">
                <file name="routes/console.php" />
            </errorLevel>
        </InvalidScope>

        <ParamNameMismatch>
            <errorLevel type="suppress">
                <file name="app/Http/Controllers/DAV/Backend/CardDAV/AddressBookRoot.php" />
            </errorLevel>
        </ParamNameMismatch>

    </issueHandlers>
</psalm>
