PhpStorm over-indenting multi-line functions - phpstorm

I'm currently attempting to configure PhpStorm to produce fully-PSR-2-compliant code, however its formatter is tripping up on long lines which contain functions with multiple parameters.
When I run the formatter, it converts this:
return ($thisIsALongLine || functionCall($arg1, $arg2));
into this:
return ($thisIsALongLine || functionCall(
$arg1,
$arg2
));
However, what I want is this:
return ($thisIsALongLine || functionCall(
$arg1,
$arg2
));
Does anyone know which formatter option tells it to further indent multi-line function calls in this instance?
Note: Usually, I'd format the above as this:
return ($thisIsALongLine
|| functionCall($arg1, $arg2));
However, that just bypasses the extra indentation issue, which I'd still need to fix for other situations.
Edit: This is the state of Wrapping and Braces, as requested by #LazyOne below:
Edit 2: Examples of two different types of line which PhpStorm's formatter isn't handling correctly. (Disclaimer: This is old code from a legacy system.)
Firstly, this:
if ($validateBudget && $this->getFinancialPeriodService()->validateBudget($formModel->action, $formModel->estimatedBudget, $formModel->startDate, $formModel->endDate, $formModel->isFirstPeriod)) {
becomes this:
if ($validateBudget && $this->getFinancialPeriodService()
->validateBudget($formModel->action, $formModel->estimatedBudget,
$formModel->startDate, $formModel->endDate, $formModel->isFirstPeriod)) {
when I would expect this based on the settings above:
if ($validateBudget && $this->getFinancialPeriodService()
->validateBudget(
$formModel->action,
$formModel->estimatedBudget,
$formModel->startDate,
$formModel->endDate,
$formModel->isFirstPeriod
)
) {
Secondly, if you enable alignment on chained methods, then this:
if ($evaluation->getExpert() != NULL && ($evaluation->getExpert()->getStatusId() == Evaluation::STATUS_ASSIGNED || $evaluation->getEvaluationStage() == Evaluation::STAGE_PROPOSED && CoreDateUtils::dateIsPast($proposal->getCalendar()->getStage1StartDate()) == false || $evaluation->getEvaluationStage() == Evaluation::STAGE_IN_PROGRESS && CoreDateUtils::dateIsPast($proposal->getCalendar()->getStage2StartDate()) == false)) {
is reformatted to this:
if ($evaluation->getExpert() != null && ($evaluation->getExpert()
->getStatusId() == Evaluation::STATUS_ASSIGNED || $evaluation->getEvaluationStage() == Evaluation::STAGE_PROPOSED && CoreDateUtils::dateIsPast($proposal->getCalendar()
->getStage1StartDate()) == false || $evaluation->getEvaluationStage() == Evaluation::STAGE_IN_PROGRESS && CoreDateUtils::dateIsPast($proposal->getCalendar()
->getStage2StartDate()) == false)) {
when I would expect this:
if ($evaluation->getExpert() != null
&& ($evaluation->getExpert()->getStatusId() == Evaluation::STATUS_ASSIGNED
|| $evaluation->getEvaluationStage() == Evaluation::STAGE_PROPOSED
&& CoreDateUtils::dateIsPast($proposal->getCalendar()->getStage1StartDate()) == false
|| $evaluation->getEvaluationStage() == Evaluation::STAGE_IN_PROGRESS
&& CoreDateUtils::dateIsPast($proposal->getCalendar()->getStage2StartDate()) == false)
) {
To be honest, at this point I suspect a bug in the formatter, so will open a ticket with JetBrains, however I'll leave this open in case anyone does know why it over-/underformats things.

Related

Github action job fire when previous job skipped

While setting up my GitHub action to build and deploy my apps, I'm running into the following issue.
I want to deploy my web app under the following conditions below. However, whenever deploy-api and deploy-sync skip deploy-web is also skipped. I figured that my if condition would catch that case and still run deploy-web but it isn't. Feels like I'm missing something obvious but can't identify it.
deploy-web:
name: Deploy Web
runs-on: ubuntu-latest
needs: [build-and-publish-web, deploy-api, deploy-sync]
if: |
needs.build-and-publish-web.result == 'success' &&
(needs.deploy-api.result == 'success' || needs.deploy-api.result == 'skipped') &&
(needs.deploy-sync.result == 'success' || needs.deploy-sync.result == 'skipped')
It seems like you encounter this issue - Job-level "if" condition not evaluated correctly if job in "needs" property is skipped.
Please try with always expression:
deploy-web:
name: Deploy Web
runs-on: ubuntu-latest
needs: [build-and-publish-web, deploy-api, deploy-sync]
if: |
always() &&
needs.build-and-publish-web.result == 'success' &&
(needs.deploy-api.result == 'success' || needs.deploy-api.result == 'skipped') &&
(needs.deploy-sync.result == 'success' || needs.deploy-sync.result == 'skipped')
Not specific to the original question but if all you care about is making sure there are no failures, needs.*.result provides wildcard behavior that prevents you from having to manually check each step:
if: |
always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')

Unable to send data to FPDF

I have a php page called page2.php which is connected to database via conectionDB.php and uploadChannel1.php to upload images. I have html page channel1.html where my form is.
But I need to send the input to FPDF to print it or save it, but this error keeps showing
Fatal error: Uncaught exception 'Exception' with message 'FPDF error: Some data has already been output, can't send PDF file'
I used ob_start and ob_flush and ob_clean and others but still not working I know the problem is with my php code. Please guys help me in this one.
require 'connectionDB.php';
require 'channel1.html';
require 'uploadChannel1.php';
if(isset($_POST['stdName']) && isset($_POST['secondGrand'])&& isset($_POST['grandName']) && isset($_POST['fatherAName']) && isset($_POST['motherGrand']) && isset($_POST['motherFatherName']) && isset($_POST['motherName']) && isset($_POST['subjectNum']) && isset($_POST['TotalNum'])&& isset($_POST['Avg']) && isset($_POST['birthDate']) && isset($_POST['gender']) && isset($_POST['stdType'])&& isset($_POST['jobs']) && isset($_POST['city'])&& isset($_POST['phone'])&& isset($_POST['bookDate'])&& isset($_POST['bookNo']))
{
$student=sanitizeString($_POST['stdName']);
$grand2=sanitizeString($_POST['secondGrand']);
$grand1=sanitizeString($_POST['grandName']);
$father=sanitizeString($_POST['fatherAName']);
$motherGrand=sanitizeString($_POST['motherGrand']);
$motherFather=sanitizeString($_POST['motherFatherName']);
$mother=sanitizeString($_POST['motherName']);
$subNo= sanitizeString($_POST['subjectNum']);
$Total=sanitizeString($_POST['TotalNum']);
$avg=sanitizeString($_POST['Avg']);
$graduateDate=sanitizeString($_POST['graduateYear']);
$birth=sanitizeString($_POST['birthDate']);
$gender=sanitizeString($_POST['gender']);
$job=sanitizeString($_POST['jobs']);
$stdType=sanitizeString($_POST['stdType']);
$City=sanitizeString($_POST['city']);
$tel=sanitizeString($_POST['phone']);
$bookdate=sanitizeString($_POST['bookDate']);
$bookNum=sanitizeString($_POST['bookNo']);
if(!empty($student) &&!empty($grand2) &&!empty($grand1) &&!empty($father)&&!empty($motherGrand)&&!empty($motherFather)&&!empty($mother)&&!empty($subNo)&&!empty($Total)&&!empty($avg)&&!empty($graduateDate)&&!empty($birth)&&!empty($gender)&&!empty($stdType)&&!empty($City)&&!empty($tel) && !empty($bookdate) &&!empty($bookNum) &&!empty($job))
{
session_start();
$_SESSION['stdName] =$studen ;
}
.......

SSIS Derived column Transformation setting to BOOL with UPPER(LTRIM(RTRIM

I have a Flag which needs to be set to 1 or 0. so i used Derived column transformation to convert it to bool
as you can se the code it works only when i use an OR operator for both Y and N .
This code below works for IF Flag is Y and N condition
(DT_BOOL)(Flag == "Y" ? 1 : 0) || (DT_BOOL)(Flag == "N" ? 0 : 1)
** working only when FLAG = (Capital)Y OR N *****************
but if my Flag is small 'n' it does not work it still sets to TRUE
I want to make it UPPER and TRIM it at the same time . Which i am having hard time to figure out .
This is my code but it does not work
(DT_BOOL)(UPPER(RTRIM(LTRIM
(Flag == "Y" ? 1 : 0)
)))
||(DT_BOOL)(UPPER(RTRIM(LTRIM(Flag == "N" ? 0 :1)
))) ***** this code is not working *****************
Thanks for your time.
PLEASE look at Tranformation Pic
Try this...
(DT_BOOL)(UPPER(RTRIM(LTRIM(Flag))) == "N" ? 0 :1)

Nested ternaries, can't spot the error

I have this nested ternary expression in SSIS that I can't seem to get to work, my eyes are about to come out of my skull.
FINDSTRING(TRIM(f3),"BASICS",1) != 0 ? (UPPER(LEFT(TRIM(f3),1)) == "F" ? #[User::FallBasicsEntityId] : (UPPER(LEFT(TRIM(f3),1)) == "S" ? #[User::SpringBasicsEntityId] : #[user::BasicsEntityId])) : (UPPER(LEFT(TRIM(f3),1)) == "F" ? #[user::FallEntityId] : (UPPER(LEFT(TRIM(f3),1)) == "S" ? #[user::SpringEntityId] : #[user::DefaultEntityId]))
Here's an "indented" version:
FINDSTRING(TRIM(f3),"BASICS",1) != 0
? (
UPPER(LEFT(TRIM(f3),1)) == "F"
? #[User::FallBasicsEntityId]
: (
UPPER(LEFT(TRIM(f3),1)) == "S"
? #[User::SpringBasicsEntityId]
: #[user::BasicsEntityId]
)
)
: (
UPPER(LEFT(TRIM(f3),1)) == "F"
? #[user::FallEntityId]
: (
UPPER(LEFT(TRIM(f3),1)) == "S"
? #[user::SpringEntityId]
: #[user::DefaultEntityId]
)
)
What am I missing? It looks to me like the parentheses are balanced and properly placed.. or are they?
I'm about to ditch this and resort to a script component... it seems to me such an expression would be easier to maintain with C# code...
The parentheses are balanced; the problem is that user is not the same as User.

FUNCTION database.AddDays does not exist

I'm trying to use dbfunction from EF6 on database MySQL but I get the follow exception "FUNCTION database.DiffDays does not exist".
I used this code:
var aux = bd.Atos.Where(w => w.IdAtivo == 1 && w.IdUtilizador == idUtilizador && DbFunctions.DiffDays(DbFunctions.AddDays(w.Data, w.NumDias).Value, DateTime.Now).Value < numeroDias)
What I'm missing?