Code Monkey home page Code Monkey logo

php-mode's People

Contributors

achitu avatar brkalmar avatar calbrecht avatar cmack avatar cweiske avatar ejmr avatar exu avatar fabacino avatar flack avatar fxbois avatar haxney avatar jcs090218 avatar jdufresne avatar joewreschnig avatar jorissteyn avatar jrbeeman avatar kalifg avatar mallt avatar marcinant avatar monnier avatar piotrkwiecinski avatar rev22 avatar ryuslash avatar scfc avatar sergeyklay avatar sten0 avatar syohex avatar takeokunn avatar tetsujin avatar zonuexe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-mode's Issues

php-mode breaks keybindings

With php-mode enabled I can’t use M-j (Meta is Alt) with my custom command, because M-j in php-mode breaks the line.

Fix Namespace Highlighting in Function Calls

Take the following code:

$foo = MyNamespace\some_function();

The mode highlights MyNamespace with font-lock-warning-face. This is not correct; it is not a warning to use a function from a namespace. This bug happens with version 1.7 of php-mode.

Error when editing a php file

I got this error when trying to edit a php file

"File mode specification error: (void-variable php-pear-coding-style-hook)"

This is what I have on my .emacs file

(add-to-list 'load-path "~/Documents/elisp")
(require 'php-mode)

Emacs version: 24.2.1

What did I do wrong? Thanks for the help.

PHP 5.5 Keywords

I'm already working on this, just wanted to make a note so I wouldn't forget.

comma separated use (namespaces)

php-mode works fine if you do a separate use for each class:

use ReflectionMethod;
use ReflectionObject;
...

However if you do it all in one use with commas, like this...

use ReflectionMethod, ReflectionObject, ... ;

It thinks all the subsequent classes are syntax errors and highlights them red, even though the syntax is perfectly valid.

is there a way to make attributes and methods colorful ?

hi, if you define attributes and methods within a class, ...

... attributes will be in orange-like color and methods will be in blue-like color.

class Foo
{
    public $bar;
    public function baz()
    {
        // just a test
    }
}

but when you invoke them on an object, it will be all white color.

$foo = new Foo();
$foo->bar;
$foo->baz();

so is there a way to solve it?

Feature request: Indentation in php-html mixed mode

Php-mode doesn't work with current mmm-mode https://github.com/purcell/mmm-mode
(font-lock is broken, indentation behave in random way )

I've been trying to use this with multi-web-mode https://github.com/fgallina/multi-web-mode

It's also broken. Indentation doesn't work at all. It generates random "a" in front of each empty line etc.

And mmm-mode and multi-web-mode goes crazy when facing syntax like this one (from WordPress theme):

>

Could it be possible to implement internal indentation rules for html in php-mode?
Css and js code usually goes to separate files and doesn't mix with php. But html is a different story.

Emacs Selects C++ Mode by Mistake

When I open certain PHP files (for example from the Laravel project) Emacs will enable C++ mode instead of the mode for PHP. If I manually attempt M-x php-mode then I get a pause followed by the error:

Lisp nesting exceeds max-lisp-eval-depth

This is with Emacs version 24.2.1 and php-mode 1.7. So far I have noticed no trend or consistent feature which causes this mistake; it may be a problem within my own dot-emacs file and not php-mode itself.

Ident breaks for files starting with a shebang

Yeah, I do scripting in PHP sometimes, and want to run them as executables like any other file.

The common way to do this is:

#!/usr/bin/env php
<?php
if(1 == 1) {
<tab>

Results in no indent.

Fix compiler warning re. font-lock

Compiling php-mode causes a warning about font-lock-syntactic-keywords being obsolete. Commit 78cb2fc fixes this issue but in turn breaks syntax highlighting in many situations. So we need to find a different solution that addresses the issue of the warning without breaking syntax highlighting.

php-mode is slow

When having a big file, my file here is 213, not very long lines.

With php-mode, it's slow to just move around in the file. Lagging when holding the arrow-key for instance.

213 lines is a quite small file in many projects...

I tried to byte-compile php-mode, did help a bit. I think. But not much. Say for example, html-mode is much much faster in the same file.

Does not seem to matter if there's acctualy php in the file, I can take the scratchbuffer, make some copies so the buffer get some size. Enable php-mode and bam, it's slow.

Chained method calls aren't indented

Chained method calls are not aligned to the first object operator in php-mode 1.6.6 and Emacs 24.2.

Indenting a region such as

    $object = new SomeClass();
    $object->method()
           ->another();

produces the same result as previous version of php-mode

    $object = new SomeClass();
    $object->method()
    ->another();

c-set-offset at the top-level?

On lines 528 and 529, there are calls to c-set-offset at the top-level. It seems like these calls should be within the definition of php-mode. I'm not very familiar with cc-mode and its derivatives, so this could be working as intended.

Fix Warnings About flet

Compiling php-mode produces warnings about flet on Emacs 24.3 because flet is obsolete as of that version. I need to replace the calls to flet with cl-flet to satisfy the compiler. But many people will continue to use versions older than 24.3 so I need to account for that.

Indent about Chained Method Calls

hey, there is another indentation problem.

it should be indented align with "->", but actually, it will not, just 4 chars indentation. codes:

        $di->getShared('dispatcher')                          
            ->setDefaultNamespace("Tycoon\Web\Controllers\\");

        $test->count()                                        
            ->test();                                         

Enhance delete-indentation

The delete-indentation function allows you to move the current line to the end of the previous line. It fixes up the white space so that for instance

$test 
    = 42;

becomes

$test = 42;

but

funcCall(
    $test);

will become

funcCall($test);

It actually relies on another function named fixup-whitespace to determine how to do this. This function was written with Lisp in mind; there are some symbols that we wouldn't want to leave spaces before that it doesn't know about. The two main ones that I've run into are -> and ::.

In php+-mode we fixed this by redefining fixup-whitespace like so:

(defun fixup-whitespace ()
  "Fixup white space between objects around point.
Leave one space or none, according to the context.  This version
overrides the one built into Emacs, and respects PHP accessor
operators."
  (interactive "*")
  (save-excursion
    (save-match-data
      (delete-horizontal-space)
      (if (or (looking-at "^\\|\\s)")
              (save-excursion (forward-char -1)
                              (looking-at "$\\|\\s(\\|\\s'"))
              (and (eq major-mode 'php-mode)
                   (or (looking-at "->\\|::")
                       (save-excursion (forward-char -2)
                                       (looking-at "->\\|::")))))
          nil
        (insert ?\s)))))

I'd be happy to commit that but I don't know if that's the best way to handle it. Any thoughts?

Syntax highlighting missing

Most of syntax highlighting for keywords used to write functions / classes is missing (same for variables) after the last php-mode update (1.9 of 2013-01-24). Tested with Emacs 24.2.50 and Emacs 24.3.50.

Fix Highlighting for Multiple Interfaces

The code

<?php

class Foo implements Bar, Baz {}

fails to correctly highlight Bar and Baz. Only one of the two has correct highlighting, while the other is treated like an error.

Wrong highlighting with numeric entity in HTML

If I have a line like this:

<?php echo "XXX"; ?><span>&#187;</span><?php echo 'XXX'; ?>

php-mode treats the # as a PHP comment and highlights the rest of the line in red. So it seems that it doesn't know that it's not in a PHP block

Bug Report Command

It would be useful for programmers working on php-mode to have a command for users that displays useful information they could paste into bug reports. Things like the current php-mode version, the Git commit hash of the version they're using (if available), the pass-and-fail status of all the unit tests, and so on. This would help us with debugging.

comment annotations not highlighted on first line of /* comment

A buffer containing the following:

/* @brief This is a function.
 * @param $foo Means something.
 */

results in "@param" being light blue, but "@brief" being red like the rest of the comment.

This is happening against the latest master under Aquamacs 2.4 (emacs 23.3.50.1).

I'm not much of an elisper - after spending an hour trying to figure out what the problem is, I decided to throw in the towel and just file a bug report.

Indention (and syntax highlighting) error when having // in string

For example this code:

.<?php
.
.$a = 'github';
.
.if($a === 'github') {
    .header('Location: http://github.com');
           .}
        .
        .

(Added a dot at every tab-end)

This is becouse the string seems to stop being a string(according to syntax-highlighting) if it contains //.

And when that happens, the last ) of the function I called is commented out, and the indention thinks that the function isn't ended... which breaks the indention...

Integration With Eldoc Mode

I want to see support for eldoc-mode within php-mode. But deciding how to approach that implementation is not trivial. Other people have already provided implementations on the Emacs Wiki and through various GitHub projects. Each implementation has its pros and cons.

One method relies on accessing the PHP documentation from the web in order to find the function signatures. I want to avoid any approach that requires the user to be online. As uncommon as I'm sure it is, I frequently work offline, even with languages like PHP. So any implementation that requires an Internet connection is a bust to me.

That approach can be turned around into using local documentation. But I do not know how common that is. I have no data to back this up, but I suspect very few PHP programmers keep a local copy of the official documentation on their computers.

Another idea is to use an auxilary PHP program. It would be a program that accepts a function, class name, et cetera, and uses PHP's reflection mechanisms to return a string of information to standard output, which php-mode could then prepare for eldoc-mode and pass along for display in the minibuffer. I feel like this is a more feasible approach than using local documentation because I do think most PHP programmers keep a copy of PHP on their own computers.

None of these approaches would support showing Eldoc information for user-defined functions. That would be the 'Killer Feature' to implement. In theory it could be done by running the user's PHP code and then using the reflection methods on that. But in practice that would be unsafe and ineffecient.

I am going to work on this in my spare time as a feature for the next version. But I would greatly appreciate any thoughts, ideas, and insights from other developers who have helped make php-mode what it is.

compatibility with emacs 24

php-mode not compatible with emacs 24

when i try to compile code, i have this errors:

Compiling file /home/@user@/.emacs.d/php-mode/php-mode.el at Thu Jul 19 12:28:26 2012
Entering directory /home/@user@/.emacs.d/php-mode/' php-mode.el:67:1:Warning: /home/@user@/.emacs.d/php-mode/php-mode.el: semantic-format-tag-summarize' obsoletes overload summerize-nonterminal' php-mode.el:67:1:Warning: /home/@user@/.emacs.d/php-mode/php-mode.el: semantic-format-tag-name' obsoletes overload name-nonterminal' php-mode.el:67:1:Warning: /home/@user@/.emacs.d/php-mode/php-mode.el: semantic-format-tag-abbreviate' obsoletes overload
abbreviate-nonterminal' php-mode.el:67:1:Warning: /home/@user@/.emacs.d/php-mode/php-mode.el: semantic-format-tag-prototype' obsoletes overload prototype-nonterminal' php-mode.el:67:1:Warning: /home/@user@/.emacs.d/php-mode/php-mode.el: semantic-format-tag-concise-prototype' obsoletes overload
concise-prototype-nonterminal' php-mode.el:67:1:Warning: /home/@user@/.emacs.d/php-mode/php-mode.el: semantic-format-tag-uml-abbreviate' obsoletes overload
uml-abbreviate-nonterminal' php-mode.el:67:1:Warning: /home/@user@/.emacs.d/php-mode/php-mode.el: semantic-format-tag-uml-prototype' obsoletes overload
uml-prototype-nonterminal' php-mode.el:67:1:Warning: /home/@user@/.emacs.d/php-mode/php-mode.el: semantic-format-tag-uml-concise-prototype' obsoletes overload
`uml-concise-prototype-nonterminal'
php-mode.el:67:1:Error: Forgot to expand macro eieio-object-p
php-mode.el:67:1:Error: Forgot to expand macro eieio-object-p
php-mode.el:67:1:Error: Forgot to expand macro eieio-object-p
php-mode.el:67:1:Error: Forgot to expand macro eieio-object-p
php-mode.el:67:1:Error: Forgot to expand macro eieio-object-p
php-mode.el:67:1:Error: Forgot to expand macro eieio-object-p
php-mode.el:67:1:Error: Forgot to expand macro eieio-object-p
php-mode.el:67:1:Error: Forgot to expand macro eieio-object-p
php-mode.el:67:1:Error: Forgot to expand macro eieio-object-p
php-mode.el:67:1:Error: Forgot to expand macro eieio-object-p
php-mode.el:67:1:Error: Forgot to expand macro eieio-object-p
php-mode.el:67:1:Error: Invalid function: eieio-object-p

Emacs < 24.3 and cl-lib

Byte compiling error:

In toplevel form:
php-mode.el:73:11:Error: Cannot open load file: cl-lib

run-time error:

File error: Cannot open load file, cl-lib

Wark-around:
I have downloaded cl-lib from ELPA. Copied it on ~/.emacs.d/cl-lib.el and added:

(add-to-list 'load-path "~/.emacs.d")

on my ~/.emacs file. This resolves run-time error but not batch byte compiling.

Is there a cleaner method?

Best regards,
Emanuele

Don't set `show-trailing-whitespace` in Drupal style

Right now, php-enable-drupal-coding-style sets show-trailing-whitespace to t. Minor-mode (and minor-mode-like) details such as this should be left to the user. Having delete-trailing-whitespace in the before-save-hook has the same problem.

The indentation setup is properly handled in the major mode, however.

Use `cc-mode` infrastructure throughout

Much of the existing functionality can be implemented in terms of c-lang-defconst calls at the top-level. These seem to have the advantage of handling both indentation and font-locking within the same declarations. This also allows more complete leverage of the powerful cc-mode libraries.

This supersedes #64.

Wrong formats with multi-catch

Hi, as you can see, when i use multi-catch, codes were formated in a wrong way.

try {
    $mongo = new \Mongo($dsn, array("replicaSet" => 'mat_replica'));
} catch(\MongoConnectionException $e) {
    throw $e;
  } catch(\Exception $e) {
      throw $e;
    }

BTW, I use these additional settings. Can someone tell me which should i set to follow PSR-3?

(setq default-tab-width 4)
(setq c-default-style "linux"
      c-basic-offset 4)

(add-hook 'php-mode-hook (lambda ()
                           (defun php-lineup-arglist-intro (langelem)
                             (save-excursion
                               (goto-char (cdr langelem))
                               (vector (+ (current-column) c-basic-offset))))
                           (defun php-lineup-arglist-close (langelem)
                             (save-excursion
                               (goto-char (cdr langelem))
                               (vector (current-column))))
                           (c-set-offset 'arglist-intro 'php-lineup-arglist-intro)
                           (c-set-offset 'arglist-close 'php-lineup-arglist-close)
                           (c-set-offset 'case-label '+)))

My emacs version: GNU Emacs 24.2.1 (x86_64-unknown-linux-gnu)

Multi-line String indentation

If you want to have a multi-line string literal, php-mode does not indent the lines of the string at all. I think they should indent to the column where the first quotation mark is.

errors when indenting codes in php closure

debug trace:

Debugger entered--Lisp error: (void-function cl-count)                                       
  (cl-count (quote arglist-cont-nonempty) syntax)                                            
  (* (cl-count (quote arglist-cont-nonempty) syntax) c-basic-offset)                         
  (delete-char (* (cl-count ... syntax) c-basic-offset))                                     
  (let ((count-func ...)) (beginning-of-line) (delete-char (* ... c-basic-offset)))          
  (save-excursion (let (...) (beginning-of-line) (delete-char ...)))                         
  (if (and (member ... syntax) (or ... ... ... ...)) (save-excursion (let ... ... ...)))     
  (let ((syntax ...)) (if (and ... ...) (save-excursion ...)))                               
  php-unindent-closure()                                                                     
  run-hooks(c-special-indent-hook)                                                           
  c-indent-line(((arglist-cont-nonempty 456 464) (statement-block-intro 456)) t t)           
  c-indent-region(1 2284 nil)                                                                
  funcall(c-indent-region 1 2284 nil)                                                        
  (if (or (not php-mode-warn-if-mumamo-off) php-warned-bad-indent                            
(php-check-html-for-indentation)) (funcall (quote c-indent-region) start end quiet))         
  php-cautious-indent-region(1 2284)                                                         
  indent-region(1 2284)                                                                      
  indent-for-tab-command(nil)                                                                
  call-interactively(indent-for-tab-command)                                                 
  (progn (setq this-command command) (call-interactively command))                           
  (if (and (commandp command) (not ...)) (progn (setq this-command command)                  
(call-interactively command)))                                                               
  (when (and (commandp command) (not ...)) (setq this-command command) (call-interactively   
command))                                                                                    
  (let* ((yas/minor-mode nil) (keys-1 ...) (keys-2 ...) (command-1 ...) (command-2 ...)      
(command ...)) (when (and ... ...) (setq this-command command) (call-interactively command)))
  (cond ((eq yas/fallback-behavior ...) nil) ((eq yas/fallback-behavior ...) (let* ... ...)) 
((and ... ... ...) (if ... ... ...)) (t nil))                                                
  (if templates (let (...) (when template ...)) (cond (... nil) (... ...) (... ...) (t nil)))
  (let* ((--cl-var-- ...) (templates ...) (start ...) (end ...)) (if templates (let ... ...) 
(cond ... ... ... ...)))                                                                     
  (multiple-value-bind (templates start end) (if field (save-restriction ... ...)            
(yas/current-key)) (if templates (let ... ...) (cond ... ... ... ...)))                      
  yas/expand-1()                                                                             
  yas/expand()                                                                               
  call-interactively(yas/expand nil nil)                                                     

Automate regression tests using ERT

The files within the tests directory are great, but effective testing really requires automation. ERT, the Emacs Regression Testing library, is included in Emacs >= 24.1.

Indentation of anonymous functions as arguments

I am testing out the Slim framework and noticed an annoying indentation problem when supplying an anonymous function as an argument; I am using 2-spaces indentation I want my code to look like:

$app->get("/index", function() {
  $app->redirect("foo");
});

But it gets indented as.

$app->get("/index", function() {
    $app->redirect("foo");
  });

Is is possible to achieve indentation as in the first example?

Feature request: indentation styles for drupal and wordpress

Currently there is support for PEAR coding rules.
It could be great to implement such rules for Drupal and Wordpress projects.

Wordpress:

http://codex.wordpress.org/WordPress_Coding_Standards

Drupal:

http://drupal.org/coding-standards

They are quite different. Wordpress rules says "Use real tabs and not spaces" while Drupal "Use an indent of 2 spaces, with no tabs." etc.

There are examples of Emacs and php-mode configuration for Drupal: http://drupal.org/node/59868

I couldn't find anything simmilar for Wordpress so I use these settings:

(setq indent-tabs-mode t
fill-column 78
tab-width 4
c-default-style "php"
c-basic-offset tab-width
c-indent-comments-syntactically-p t
c-set-offset 'arglist-cont 0
c-set-offset 'arglist-intro '+
c-set-offset 'case-label 2
c-set-offset 'arglist-close 0
c-set-offset 'defun-close 0
c-set-offset 'defun-block-intro tab-width)

Could it be possible to implement these rules and provide an easy way to switch between them?

Undo Whitespace Effects When Changing Coding Styles

When using php-enable-drupal-coding-style we perform the following:

(setq show-trailing-whitespace t)
(add-hook 'before-save-hook 'delete-trailing-whitespace)

These values make sense for Drupal's coding style (however see #50) but we should not leave these in effect when switching to another coding style. The other coding styles should undo these settings when enabled.

Array Key Indentation

The readme has this array as an example:

array(
 'select'    => 'title',
 'condition' => 'postID=:postID',
 'params'    => array(':postID' => 10),
)

However, when typing this out manually, it would be aligned like so (note, in your example the => are one space further than the longest key):

array(
 'select' => 'title',
 'condition' => 'postID=:postID',
 'params' => array(':postID' => 10),
)

The way I've currently worked around this is M-x align-regexp RET = RET

I tried to go about adding it to php-mode myself, but couldn't figure it out, this is the primary article I came about during research: http://stackoverflow.com/questions/915985/in-emacs-how-to-line-up-equals-signs-in-a-series-of-initialization-statements

P.S. - Thanks for making/maintaining php-mode, it's great to see PHP get some emacs love!

php-mode isn't loading properly on 23.1.1

Hello,

First off, thanks for updating this library and code.

I'm new to GNU Emacs and so some of this may be user error.

I have downloaded the library from github and included the necessary lines in my .emacs file, but the mode does not recognize php files and emacs says it can't load the mode when I call php-mode. A backtrace says something about
'c-lang-defconst' must be used in a file

I can provide my .emacs file, and the backtrace for clarifying the bug.

Function parameter list indentation

With the new array indentation the indentation for function arguments has also changed:

Used to be:

function someFunc($param1, $param2,
                  $param3)
{
  // do something
}

Has become:

function someFunc($param1, $param2,
    $param3)
{
  // do something
}

Is there a way that we (or I personally with some settings) could use the new indentation for arrays and keep the old style for functions? (I'm sorry, I've never really done much with emacs' and cc-mode's indentation settings)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.