Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP: Unsupported if: else: endif: endforeach; #5170

Closed
tecnoweb opened this issue May 15, 2023 · 6 comments
Closed

PHP: Unsupported if: else: endif: endforeach; #5170

tecnoweb opened this issue May 15, 2023 · 6 comments

Comments

@tecnoweb
Copy link

Describe the bug

If I try to parse if($variale == true): return true; else: return false; endif;
the editor not recognize the part of stack code
the same issue is applied on
foreach($variable as $key):

endforeach;
the editor not recognize the part of stack code

Expected Behavior

not parse this part of code

Current Behavior

I don't have error but not parse this part of code

Reproduction Steps

foreach($variable as $key):

endforeach;

if($variale == true): return true; else: return false; endif;

Possible Solution

No response

Additional Information/Context

No response

Ace Version / Browser / OS / Keyboard layout

latest/Safari/Mac/IT

@InspiredGuy
Copy link
Contributor

hey @tecnoweb, thanks for the report. can you reproduce the issue in the kitchen sink with PHP mode on? when I paste the code from the issue there, it gets syntax highlighting (see screenshot, made with Dracula theme enabled). Also, which theme are you using? Try using a different theme to see if syntax highlighting becomes visible.
image

@tecnoweb
Copy link
Author

I try show you,
Not detect end of variable
foreach($variable as $key):
if($variale == true):
return true;
else:
return false;
endif;
endforeach;

Detect variable **{**
foreach($variable as $key) {
if($variale == true){
    return true; 
} else {
    return false; 
   }

}
Screenshot 2023-05-16 alle 14 00 25 Screenshot 2023-05-16 alle 14 00 20 Screenshot 2023-05-16 alle 14 00 14 Screenshot 2023-05-16 alle 14 00 39

@InspiredGuy
Copy link
Contributor

InspiredGuy commented May 16, 2023

Thank you for the details and screenshots. This is how I understood the issue, please correct me if I'm wrong: ace PHP mode does not recognise alternative syntax with colons as nested code and does not show the folding controls, and does not highlight closing tag (e.g. endforeach;) as a closing brace. I can reproduce it in the kitchen sink.

@InspiredGuy
Copy link
Contributor

This might be fixed by using pythonic folding mode for PHP (since it also handles nested code structures without braces), or mixing CStyle folding mode with pythonic one using mixed folding mode, or implementing PHP folding mode which would handle both cases - I am not sure which would help, these are listed in order of approximate effort required. Folding mode would be used in the PHP mode. Contributions are welcome!

@tecnoweb
Copy link
Author

tecnoweb commented Aug 18, 2023

I have try to add some modification but unable to do it can you help me ?

i have try make this .. but not work..

`"use strict";

var oop = require("../lib/oop");
var lang = require("../lib/lang");
var BaseFoldMode = require("../mode/folding/fold_mode").FoldMode;

function PHPAlternativeFoldMode() {
this.foldingStartMarker = /<?php\s*(?::|if|else|elseif|endif|for|endfor|while|endwhile|foreach|endforeach|switch|case|break|default|endswitch)\b/;
this.foldingStopMarker = /^\s*(?:end[a-zA-Z0-9_]+|endif|endforeach|endfor|endwhile|endswitch)\b/;
}

oop.inherits(PHPAlternativeFoldMode, BaseFoldMode);

exports.PHPAlternativeFoldMode = PHPAlternativeFoldMode;
`

@InspiredGuy
Copy link
Contributor

#5491 with a fix was merged, should be available in the next release

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

No branches or pull requests

2 participants