Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Incorrect line number reported for Kohana.Operators.TernaryOperator.TernaryParenthesized #16

Description

@samwilson

The following code is not being sniffed correctly:

<?php

function test($test)
{
    $bar = 'foobar';
    $foo = $test ? $bar : (1);
}

This is the error:

$ ./vendor/bin/phpcs.bat --standard=vendor/kohana/coding-standards/Kohana -s test.php

Notice: Undefined offset: -1 in C:\work\public_html\kohana_test\vendor\squizlabs\php_codesniffer\CodeSniffer\File.php on line 2665

FILE: C:\work\public_html\kohana_test\test.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
 3 | ERROR | Comparisons and operations must be in parentheses in the false
   |       | value portion of ternary operations
   |       | (Kohana.Operators.TernaryOperator.TernaryParenthesized)
--------------------------------------------------------------------------------

Time: 0 seconds, Memory: 1.25Mb

The coding standard error also seems to be wrong, but perhaps that's just related to the line number thing?

(I'll dig into this deeper when I've got time... just putting this here now as a reminder, and in case someone smarter than me can tell me where I'm going wrong.)

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions