Encountered this issue on old file.
use Forbidden\Classes\Secret_Class; // @codingStandardsIgnoreLine because I like to sweep problems under the rug
turns to
use Forbidden\Classes\Secret_Class;
// @codingStandardsIgnoreLine because I like to sweep problems under the rug
While this is a non-breaking change in php, the PHP_Codesniffer tag no longer points to the right line.
@nikolasmatt i think we should not move php_codesniffer comments (maybe other too, need investigate), but right now can fix it only for php_codesniffer.
I don't think it makes a difference that its a php_codesniffer comment or not, we should just keep inline comments as is
https://prettier.io/playground/#N4Igxg9gdgLgprEAuEMAWBLAzgOjAQwBtCAxAV1g2gAoBKAbgAIB6ZxrCAWzkck+9gAdKMOHMAVOOGMI6OACdeXATGnTxzUSKitG8LKp1t9h9NhwAzCmBhUoAYSKFqdRgF4AfI2DT2XOADycvIAKphQAOZ0TLoYUIRxcMIAvrQgADQgEAAOttBYyKD48vIQAO4ACsUIBSj4AG4QGAAmGSD4BsgWRFhwmQBG8vhgANZwMADK2cNxEcgw8mR9IM0QYF09y3G98jAVQxGc+BuEvZkAVlgAHgBCQ6PjE-jcADKJJ2dZZDDZ3wBMH2W03kO2QIH6+H6AE9CNA2tl5HEYAB1FroZAADgADJkERBesihtkwQi4Dt6nA2vI4ABHMgYan7fCHY5IbqnZa9TgYeaLTmzQhwACKZFklLZm0yMEhqOa6KQfylQwwCUi9mUrJAUGglMyZF6IUhtXZvWSySAA
@mgrip yes you are right :+1:
I believe that I am seeing this same issue. It doesn't break anything at all for me, but when I run prettier --debug-test on some files with inline comments it says that it broke when it didn't actually break. If I run without the debug-test flag it prettifies it just fine, and the results are syntactically identical, but inline comments have indeed been moved to the next line (I'm guessing that is why debug-test thinks it broke?).
Sample code:
<?php
class test {
/**
* Retrieves the hr sub-menu
*
* @return $menu Array of employee menu items
*/
protected function get_sub_menu($page = null) {
return [
['url' => '/hr/admin/pto','title' => 'Review Time-Off Requests','active' => $active ],
['url' => '/hr/admin/employees', 'title' => 'Employees', 'active' => $active ],
['url' => '/hr/admin/employees/inactive', 'title' => 'Inactive Employees', 'active' => $active ],
];
} //end method get_sub_menu
/**
* @return $array Array of actions user is allowed to perform on an hr list
*/
protected function get_actions($page) {
$actions = [];
return [
function( $model ){ return '<a href="hr/admin/employees/update/' . $model->id . '" class="modal_handle" >Edit</a>'; },
function( $model ){ return '<a href="hr/admin/employees/contracts/' . $model->id . '" class="modal_handle" >View Contracts</a>'; },
];
return $actions;
} //end function get_actions
/**
* Team leader is allowed to approve team members' time-off requests
*
*
* @return Array of employee ids the user is allowed to approve
*
*/
public function get_approvable_employees() {
return true;
} //end get_approvable_employees
} // end class test
Output:
<?php
class test
{
/**
* Retrieves the hr sub-menu
*
* @return $menu Array of employee menu items
*/
protected function get_sub_menu($page = null)
{
return [
[
'url' => '/hr/admin/pto',
'title' => 'Review Time-Off Requests',
'active' => $active
],
[
'url' => '/hr/admin/employees',
'title' => 'Employees',
'active' => $active
],
[
'url' => '/hr/admin/employees/inactive',
'title' => 'Inactive Employees',
'active' => $active
]
];
}
// end method get_sub_menu
/**
* @return $array Array of actions user is allowed to perform on an hr list
*/
protected function get_actions($page)
{
$actions = [];
return [
function ($model) {
return '<a href="hr/admin/employees/update/' .
$model->id .
'" class="modal_handle" >Edit</a>';
},
function ($model) {
return '<a href="hr/admin/employees/contracts/' .
$model->id .
'" class="modal_handle" >View Contracts</a>';
}
];
return $actions;
}
// end function get_actions
/**
* Team leader is allowed to approve team members' time-off requests
*
* @return Array of employee ids the user is allowed to approve
*
*/
public function get_approvable_employees()
{
return true;
}
// end get_approvable_employees
}
// end class test
We're most likely going to get rid of these inline comments, but since it is causing prettier to report breaks I figured I'd report it.
thanks @cmancone! I think part of the issue there as well is that --debug-check doesn't properly account for comments changing. https://github.com/prettier/plugin-php/issues/190 has some more info
related parser issue https://github.com/glayzzle/php-parser/issues/132
will be fixed with https://github.com/prettier/plugin-php/pull/217
Just ran into this with 0.2.1:
//input
$foo['options'] = array_slice($foo['options'], 0, \Forbidden\Classes\Secret_Class::$amount); // @codingStandardsIgnoreLine because I like to sweep problems under the rug
//output
$foo['options'] = array_slice(
$foo['options'],
0,
\Forbidden\Classes\Secret_Class::$amount
); // @codingStandardsIgnoreLine because I like to sweep problems under the rug
@roippi can you create new issue? thanks!
Most helpful comment
I don't think it makes a difference that its a
php_codesniffercomment or not, we should just keep inline comments as ishttps://prettier.io/playground/#N4Igxg9gdgLgprEAuEMAWBLAzgOjAQwBtCAxAV1g2gAoBKAbgAIB6ZxrCAWzkck+9gAdKMOHMAVOOGMI6OACdeXATGnTxzUSKitG8LKp1t9h9NhwAzCmBhUoAYSKFqdRgF4AfI2DT2XOADycvIAKphQAOZ0TLoYUIRxcMIAvrQgADQgEAAOttBYyKD48vIQAO4ACsUIBSj4AG4QGAAmGSD4BsgWRFhwmQBG8vhgANZwMADK2cNxEcgw8mR9IM0QYF09y3G98jAVQxGc+BuEvZkAVlgAHgBCQ6PjE-jcADKJJ2dZZDDZ3wBMH2W03kO2QIH6+H6AE9CNA2tl5HEYAB1FroZAADgADJkERBesihtkwQi4Dt6nA2vI4ABHMgYan7fCHY5IbqnZa9TgYeaLTmzQhwACKZFklLZm0yMEhqOa6KQfylQwwCUi9mUrJAUGglMyZF6IUhtXZvWSySAA