FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=16836&edit=1

ID: 16836
Updated by: gsherwood@squiz.net
Reported By: xxx at marynicolehicks dot com
-Summary: Notice Raised
+Summary: Notice raised when using semicolon to open case
Status: Verified
Type: Bug
Package: PHP_CodeSniffer
Operating System: Windows Vista 32
Package Version: 1.2.1
PHP Version: 5.2.5
Assigned To: squiz
Roadmap Versions:
New Comment:

-Summary: Notice Raised
+Summary: Notice raised when using semicolon to open case



Previous Comments:
------------------------------------------------------------------------

[2009-11-30 06:07:01] squiz

This is caused by using a semi-colon to end the CASE statement instead
of a colon. PHP_CodeSniffer would have never checked this code correctly
although the error may not have been thrown because this is newish code
to support more SWITCH structures.

Please change the semi-colon to a colon to workaround this issue until
it is fixed.

------------------------------------------------------------------------

[2009-11-26 10:22:46] squiz

-Status: Feedback
+Status: Verified
Thanks a lot. Looks like the basic code causing the error is:

switch ($errorType) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case '404';
break;
}

------------------------------------------------------------------------

[2009-11-26 10:14:57] marynicolehicks

As a little side comment, I have not changed the NOTICE causing piece
of code for many months and it seemed to work with version 1.2.0 fine
but started causing the problem with 1.2.1

------------------------------------------------------------------------

[2009-11-26 09:57:38] marynicolehicks

Yes this code here should cause it. I have taken out as much code as I
can while still producing the same notice. Annoyingly I could not find
where to attach files to comments, so I hope this still causes the
problem after posting it. There was an opening PHP tag at the start but
this comment box did not allow it. This is up there with some of my
worst code, and now I have found it I could tidy up the code, but I
still hope it helps fixing that notice.


class ErrorController
{
public function errorAction()
{
$view = $this->view;

$errorMessage = '';

switch ($errorType) {
// 404 error -- controller/action not found
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
case '404';
// check for a redirect
if ($this->CheckForRedirect()){
return;
}

// set the http response code to 404
$this->getResponse()->setHttpResponseCode(404);

// add the header and info message
$fullUrl = $this->_helper->fullurl();
$view->messages[] = '<b>404:</b> The page you requested
('.wordwrap(htmlentities( $fullUrl),75,'<br>',TRUE).') could not be
found.';
if (!empty($errorMessage)){
$this->showAdminMessage($view,$errorMessage);
}
break;

// application error; display error page, but don't change
// status code
default:
// add the header and info message
$view->messages[] = '<b>500:</b> The page you requested will be
under maintenance until tomorrow.';
if (isset($errorMessage)){
My_Log::LogError( $errorMessage, My_Log::ERR );
$this->showAdminMessage($view,$errorMessage);
}
break;
}
return $this->_forward('error','home');
}
}

------------------------------------------------------------------------

[2009-11-26 05:45:30] squiz

-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: squiz
Errors like this indicate that there is a bit of code PHPCS was unable
to tokenise correctly. I never mute errors like this because they mask a
bigger problem. To fix them, I need the code you were checking or some
sample code that produces the same issue. Are you able to supply some?

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://pear.php.net/bugs/bug.php?id=16836

Search Discussions

  • Gsherwood at Jan 14, 2010 at 5:55 am
    Edit report at http://pear.php.net/bugs/bug.php?id=16836&edit=1

    ID: 16836
    Updated by: gsherwood@squiz.net
    Reported By: xxx at marynicolehicks dot com
    Summary: Notice raised when using semicolon to open case
    -Status: Verified
    +Status: Closed
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: Windows Vista 32
    Package Version: 1.2.1
    PHP Version: 5.2.5
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Verified
    +Status: Closed
    This bug has been fixed in SVN.

    If this was a documentation problem, the fix will appear on
    pear.php.net by the end of next Sunday (CET).

    If this was a problem with the pear.php.net website, the change should
    be live shortly.

    Otherwise, the fix will appear in the package's next release.

    Thank you for the report and for helping us make PEAR better.




    Previous Comments:
    ------------------------------------------------------------------------

    [2010-01-14 05:52:11] squiz

    -Summary: Notice Raised
    +Summary: Notice raised when using semicolon to open case


    ------------------------------------------------------------------------

    [2009-11-30 06:07:01] squiz

    This is caused by using a semi-colon to end the CASE statement instead
    of a colon. PHP_CodeSniffer would have never checked this code correctly
    although the error may not have been thrown because this is newish code
    to support more SWITCH structures.

    Please change the semi-colon to a colon to workaround this issue until
    it is fixed.

    ------------------------------------------------------------------------

    [2009-11-26 10:22:46] squiz

    -Status: Feedback
    +Status: Verified
    Thanks a lot. Looks like the basic code causing the error is:

    switch ($errorType) {
    case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
    case '404';
    break;
    }

    ------------------------------------------------------------------------

    [2009-11-26 10:14:57] marynicolehicks

    As a little side comment, I have not changed the NOTICE causing piece
    of code for many months and it seemed to work with version 1.2.0 fine
    but started causing the problem with 1.2.1

    ------------------------------------------------------------------------

    [2009-11-26 09:57:38] marynicolehicks

    Yes this code here should cause it. I have taken out as much code as I
    can while still producing the same notice. Annoyingly I could not find
    where to attach files to comments, so I hope this still causes the
    problem after posting it. There was an opening PHP tag at the start but
    this comment box did not allow it. This is up there with some of my
    worst code, and now I have found it I could tidy up the code, but I
    still hope it helps fixing that notice.


    class ErrorController
    {
    public function errorAction()
    {
    $view = $this->view;

    $errorMessage = '';

    switch ($errorType) {
    // 404 error -- controller/action not found
    case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
    case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
    case '404';
    // check for a redirect
    if ($this->CheckForRedirect()){
    return;
    }

    // set the http response code to 404
    $this->getResponse()->setHttpResponseCode(404);

    // add the header and info message
    $fullUrl = $this->_helper->fullurl();
    $view->messages[] = '<b>404:</b> The page you requested
    ('.wordwrap(htmlentities( $fullUrl),75,'<br>',TRUE).') could not be
    found.';
    if (!empty($errorMessage)){
    $this->showAdminMessage($view,$errorMessage);
    }
    break;

    // application error; display error page, but don't change
    // status code
    default:
    // add the header and info message
    $view->messages[] = '<b>500:</b> The page you requested will be
    under maintenance until tomorrow.';
    if (isset($errorMessage)){
    My_Log::LogError( $errorMessage, My_Log::ERR );
    $this->showAdminMessage($view,$errorMessage);
    }
    break;
    }
    return $this->_forward('error','home');
    }
    }

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    http://pear.php.net/bugs/bug.php?id=16836

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJan 14, '10 at 5:53a
activeJan 14, '10 at 5:55a
posts2
users1
websitepear.php.net

1 user in discussion

Gsherwood: 2 posts

People

Translate

site design / logo © 2022 Grokbase