Closed finalblast closed 1 year ago
Thank you. The fix for #29 made this up. It's already fix in the next release
Thank you for the quick fix, Appreciate that. Since the latest fix, seem another issue happens:
Before
<?php
class Test
{
public function saveTest()
{
$campaign = $api->getCampaign($campaign_id);
$db_test = new Test();
$db_test->name = $campaign->{CampaignFields::NAME};
$db_test->status = $campaign->{CampaignFields::EFFECTIVE_STATUS};
$db_test->budget = $campaign->{CampaignFields::LIFETIME_BUDGET};
$db_test->save();
}
}
After
<?php
class Test
{
public function saveTest()
{
$campaign = $api->getCampaign($campaign_id);
$db_test = new Test();
$db_test->name = $campaign->{CampaignFields::NAME}
$db_test->status = $campaign->{CampaignFields::EFFECTIVE_STATUS}
$db_test->budget = $campaign->{CampaignFields::LIFETIME_BUDGET}
$db_test->save();
}
}
Please have a look @driade
There you're, fixed. Thanks.
@driade I think it makes another bigger issue.
Before
<?php
class Test
{
public function saveTest()
{
$value = [
'test' => 1,
'another_test' => 2
];
foreach (array_keys($value) as $array_key) {
$report->{$array_key} = $value[$array_key];
}
$report->save();
}
}
After
<?php
class Test
{
public function saveTest()
{
$value = [
'test' => 1,
'another_test' => 2
];
foreach (array_keys($value) as $array_key) {
$report->{$array_key}; = $value[$array_key];
}
$report->save();
}
}
Another case
<?php
class Test
{
public function saveTest()
{
$user = {};
$tests = $api->getTests();
foreach ($tests as $key => $test) {
$db_test[] = [
'test' => $test->{'Id'},
'another_test' => $user->another_test,
'user_id' => $user->user_id,
'blah' => $user->blah,
'name' => $test->{'Name'},
'status' => strtoupper($test->{'Status'}),
'budget' => $test->{'BudgetType'} === 'DailyBudgetStandard' ? $test->{'DailyBudget'} : 0,
'updated_at' => now()
];
}
}
}
Becomes
<?php
class Test
{
public function saveTest()
{
$user = {}
$tests = $api->getTests();
foreach ($tests as $key => $test) {
$db_test[] = [
'test' => $test->{'Id'};,
'another_test' => $user->another_test,
'user_id' => $user->user_id,
'blah' => $user->blah,
'name' => $test->{'Name'};,
'status' => strtoupper($test->{'Status'};),
'budget' => $test->{'BudgetType'}; === 'DailyBudgetStandard' ? $test->{'DailyBudget'}; : 0,
'updated_at' => now()
];
}
}
}
Thank you very much @finalblast . Patch uploaded. The more cases we've the more confident we're.
Thanks for quick fix @driade
There is also 1 more issue I wanna to ask:
<?php
class Test
{
public function array(array $rows)
{
if (count($rows) > 0) {
foreach ($rows as $row) {
// Save DB
}
}
}
}
Becomes
<?php
class Test
{
function [array $rows) {
if (count($rows) > 0) {
foreach ($rows as $row) {
// Save DB
}
}
}
}
Another case
<?php
class Test
{
public function array($rows)
{
if (count($rows) > 0) {
foreach ($rows as $row) {
// Save DB
}
}
}
}
Becomes
<?php
class Test
{
function [$rows] {
if (count($rows) > 0) {
foreach ($rows as $row) {
// Save DB
}
}
}
}
Thank you.
Hi, thanks. May you open a separate issue for this case?
El vie, 9 jun 2023, 10:34, Nam (Nick) N. HUYNH @.***> escribió:
Thanks for quick fix @driade https://github.com/driade
There is also 1 more issue I wanna to ask:
<?php class Test { public function array(array $rows) { if (count($rows) > 0) { foreach ($rows as $row) { // Save DB } } } }
Becomes
<?php class Test { function [array $rows) { if (count($rows) > 0) { foreach ($rows as $row) { // Save DB } } } }
Thank you.
— Reply to this email directly, view it on GitHub https://github.com/driade/phpfmt8/issues/34#issuecomment-1584187276, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLNWSGCRASQSNIOQJPH5CLXKLN3DANCNFSM6AAAAAAY2VGU2M . You are receiving this because you were mentioned.Message ID: @.***>
Hello again @finalblast .
"array" in a reserved word https://www.php.net/manual/en/reserved.keywords.php so you can´t use it a a function name
@driade There is a repository that is required to implement the interface that the function name was an array. You can look here: https://github.com/SpartnerNL/Laravel-Excel/blob/3.1/src/Concerns/ToArray.php
So in the code, we cannot format the file.
I think it is because of ShortArray config?
Yes, it's because of the ShortArray, which you can disable of course.
Anyway I now understand you needs, and I think I can handle it. Give me a second.
There you're, patch uploaded!
Thanks @driade , it is almost perfect but still 3 issues:
<?php
class Test
{
public function array($rows)
{
if (count($rows) > 0) {
foreach ($rows as &$row) {
// Save DB
}
}
}
}
Becomes
<?php
class Test
{
function array($rows) {
if (count($rows) > 0) {
foreach ($rows as &$row) {
// Save DB
}
}
}
}
Issues:
Thanks a lot, fixed
@driade Thank you. I think it is almost perfect, only 1 case left:
<?php
class Test
{
public function array($rows)
{
if (!isset($groups[$test['category']])) {
$children[$test['category']] = [];
$groups[$test['category']] = [
'id' => $test['category'],
'type' => 'group',
'label' => $test['category'],
'children' => &$children[$test['category']]
];
$options[] = $groups[$test['category']];
}
}
}
Becomes
<?php
class Test
{
public function array($rows)
{
if (!isset($groups[$test['category']])) {
$children[$test['category']] = [];
$groups[$test['category']] = [
'id' => $test['category'],
'type' => 'group',
'label' => $test['category'],
'children' => &$children[$test['category']]
];
$options[] = $groups[$test['category']];
}
}
}
You can notice an addition space in 'children' => &$children[$test['category']]
There you're, fixed, thanks!
Wonderful. Thank you very much, all good now.
Before
After
Configs: