Giter VIP home page Giter VIP logo

php.tmbundle's Introduction

Installation

You can install this bundle in TextMate by opening the preferences and going to the bundles tab. After installation it will be automatically updated for you.

General

License

If not otherwise specified (see below), files in this repository fall under the following license:

Permission to copy, use, modify, sell and distribute this
software is granted. This software is provided "as is" without
express or implied warranty, and with no claim as to its
suitability for any purpose.

An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. For example “tidy” is accompanied by “tidy-license.txt”.

php.tmbundle's People

Contributors

aurora avatar benubois avatar ciaran avatar cowboy avatar gdsmith avatar infininight avatar ingramz avatar jjeising avatar joshvarner avatar koenpunt avatar lilyball avatar martinbean avatar qerub avatar sleetdrop avatar sorbits avatar star-szr avatar stof avatar torsten avatar unrob 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

php.tmbundle's Issues

Using PHP in JavaScript breaks code highlighting for following code

http://f.cl.ly/items/3V192b2V102m3Z333F1c/issue.png

How to reproduce

  • Open a new file
  • Set the file syntax to PHP
  • Type the following code into the new file:
<?php

$var = 1;

?>
<script type="text/javascript">

function foo()
{
    return <?=json_encode($var);?>;
}

function bleh()
{
    return 1;
}

</script>
  • Put your text cursor in the bleh() JavaScript function
  • Press CTRL+SHIFT+P

Expected Result

  • Scope should be source.js.embedded.html

Actual Result

  • Scope is text.html.php. Because of this, the syntax highlighting is completely broken for all following code in the file...

Environment

  • OS X 10.8.5
  • TextMate 2.0-alpha.9487

Syntax Regression

Since 0fb625c syntax highlighting for classes has been completely broken. See the following screenshots for an example.

Right highlight: http://cl.ly/17aQ @ e768d32
Wrong highlight: http://cl.ly/19Hg @ 0fb625c

Unfortunately, because voxwerk decided to change everything at once, this will be a very hard one to track down. I recommend reverting to e768d32 until his changes work properly.

(array) not recognised as storage type

Hi,

It seems that the (array) cast operation is not recognised, e.g. in:

$tags = (array) $tags;

The scope of array is marked as constant.other.php, while it should be marked as storage.type.php like when using (int), (object), etc.

When type hinting in a function definition, array is recognized correctly though.

Syntax highlighting for namespace declaration on same line as opening <?php tag

Laravel’s coding style guide says the namespace declaration must be on the same line as the opening <?php tag: http://laravel.com/docs/master/contributions#coding-style

When I do this in TextMate, the PHP syntax highlighter doesn’t pick up the namespace declaration, but does if it’s on a new line. Is it possible to add syntax highlighting if it’s on the same line as the opening <?php tag as well? I’d do it myself but really not au fait with TextMate package development.

Ability to use "Documentation for Word" on selected text

I usually select functions instead of simply placing the caret inside of them. Since TM_CURRENT_WORD is empty when I do that, I have to drop out of my selection for it to work.

Would it be doable to use the selected text as well as the current word ?

docblock for function with `class` or `interface` in arguments is incorrect

When adding docblocks to existing functions (doc + tab) and the function name or argument contains class or interface there is an docblock inserted for a class instead of for a function.

The problem lies in here: https://github.com/textmate/php.tmbundle/blob/master/Commands/Post-doc.tmCommand#L23

For example:

<?php

/**
 * undocumented class
 *
 * @package default
 * @author Koen Punt
 */
function foreign_key($class_name, $separate_class_name_and_id_with_underscore = true){
// ...
}

Borked brace indentation for TM2 Alpha

In the TM2 Alpha indentation doesn't happen correctly for curly brace indentation.

If I type

{[\n]

I get

{
|}

not

{
    |
}

I checked against Ruby and that is still working as TM1.5 so I'm fairly sure this is not expected behaviour

Bundle freezes TextMate, leaving behind a never ending 50% ruby process until the computer locks

Hi,

In short

Textmate hangs when looking up a function that doesn't exist in PHP and creates a run-away ruby process from hell using 50% CPU and 500 Mb ram each.

Long:

I'm having issues with the PHP bundle that took me a while to track down. Lately I've been noticing that my fan is constantly on (on a new MacBook Pro this is a bad sign) and battery usage was down the drain. When I looked into it I had these:

niklas 26324 47,4 10,7 4344728 899904 ?? R 25Jan11 2330:25.25 ruby -wKU /tmp/temp_textmate.zf90sT
niklas 5008 44,2 4,6 2972536 383580 ?? S Tor11am 639:03.32 ruby -wKU /tmp/temp_textmate.5Vl71x
niklas 10001 43,8 5,5 4003736 457196 ?? S 27Jan11 1727:28.40 ruby -wKU /tmp/temp_textmate.dHpBiN

I had three textmate ruby processes, each eating 47% CPU and 500MB memory and been running for weeks. When I looked into the temp files they are the source of the PHP bundle (ironically written in Ruby).

At the same time TextMate had been crashing for me when I tried to lookup a function name that doesn't exist. Apparently when it hangs the ruby process continues forever.

Recreate

I'm using TextMate 1.5.10, and I've changed the action key for "Documentation for Functionc all (tool tip)" to Alt+§.

  1. Create a new Document
  2. Change it to Php
  3. Write test()
  4. Put your cursor between test and () (testcursor)
  5. Press Alt+§
  6. Textmate hangs

Regards,
Niklas

Requesting update to C/C++ indentation rules for more common switch statement formatting

TextMate auto-indents C and C++ in an unexpected way. To be specific, I would like to get:

This (1):

switch (x) {
    case 3:
        sdrhit;
    case 4:
        dfsdkfsd;
}

Or this (2):

switch (x) {
case 3:
    sdrhit;
case 4:
    dfsdkfsd;
}

Unfortunately, instead, I get this:

switch (x) {
    case 3:
    sdrhit;
    case 4:
    dfsdkfsd;
}

I looked into this, and I understand that the Swift indent rules would behave as I expect. I'm told that I can edit the indentation rules, but for C, I don't see the word "select" mentioned anywhere in the indentation rules, so this is confusing to me. My opinion is that (1) or (2) should be default, but at the very least, documentation somewhere about how to change them to fix this specific case would be really nice.

Jump to definition/declaration of own function/var

Hi,
i am missing key feature for me and it's jump to definition( ctrl+ in Netbeans or Aptana). My question is: Has php budle this feature or do you plan to implement it in some near version of this bundle?

Proper escaping in regex

Example:

$dn = preg_replace('/([^\\\]),(\s+)/u', '\1,', $dn);
$test = 'abc';

In PHP \\ is an escaped \ and \] will just be ignore -> so it results in following regex: [^\\] (which is as regex: everything except a backslash (in regex the backslash also needs to be escaped).

Anyway. If even the regex is wrong it doesn't should cause the highlighter to break anything. The string is still closed and there the highlight should start working again.

Spotted in https://github.com/owncloud/core/blob/4fcfedb03cb60fe60617fd8d7609d5d1397789a5/apps/user_ldap/lib/access.php#L241

Multiline HTML comment breaks indentation

After doing a select all and "Text -> Indent Selection" the indendation breaks at the multiline <!-- html comment. It starts an indent after the <!-- tag. If i put the multiline HTML comment on a single line it indents perfectly

html_indentation

Cannot checkout master branch

error: unable to create file Snippets/… ?>.tmSnippet (Invalid argument)
error: unable to create file Snippets/.tmSnippet (Invalid argument)

error: unable to create file Snippets/… ?>.tmSnippet (Invalid argument)
error: unable to create file Snippets/.tmSnippet (Invalid argument)
error: unable to create file Snippets/.tmSnippet (Invalid argument)
error: unable to create file Snippets/.tmSnippet (Invalid argument)
error: unable to create file Snippets/.tmSnippet (Invalid argument)
error: unable to create file Snippets/ ___ ___ .tmSnippet (Invalid argument)

error: unable to create file Snippets/ ___ .tmSnippet (Invalid argument)
error: unable to create file Snippets/?>…<?php.tmSnippet (Invalid argument)

error: unable to create file Snippets/if ?: a : b;.tmSnippet (Invalid argument)

fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.

Indentation and code highlighting on multiline, quoted SQL queries

When I create a multiline string with an SQL query, and the string begins with a line break, I lose the code highlighting (apparently, sql-string-double-quoted is not matching).

Also, whenever I add a new line break inside the string, Textmate is increasing the indentation level. So , when I try to write something like this:

$qry = "
    SELECT col
    FROM tbl
    WHERE othercol = :val
";

I end up with this:

$qry = "
    SELECT col 
        FROM tbl 
            WHERE othercol = :val
"; 

I posted a question on Stack Overflow about this, here is the link for reference: http://stackoverflow.com/questions/12452333/textmate-php-bundle-adds-extra-indentation-on-multiline-strings-how-to-avoid-it

Language syntax problem

Hi,

I'm experiencing a language syntax problem with this bundle since one of the recent patches (I updated textmate).

The problem is that suddenly my opening and closing brackets { } for code blocks are colored the same way as variables (scope selector sees them as variable.other.php). The same goes for the semi-colon at the end of a line and opening and closing parentheses ( ). They are now all colored blue like my variables, whilst they used to be black, like neutral/unidentified text.

Is this a known issue, or can I fix this in some way?

Thanks,
Ildefonse

Grammar error for (string) embedded variables with complex array subscripts

These two code snippets fail:

Snippet 1

<?php
$str = array("Foo", "Bar");
echo "Name: {$str[($str[1]) ? 1 : 0]}"; // Should echo "Name: Bar"
?>

The text "($str[1" appears highlighted as a syntax error.

Snippet 2

<?php
$insert = mysql_query("INSERT INTO `catalogue` SET
 `model`='{$_POST["page_row{$count}_model"]}',
 `type`='{$_POST["page_row{$count}_type"]}',
 `updated`=UNIX_TIMESTAMP()
;");
?>

Everything in the document after this snippet is treated as a string.

Mailing list thread about this.

Indentation after a PHPDoc/DocBlock

At the end of DocBlocks, pressing return keeps the indentation level because of the leading whitespace before the *. This is annoying because you have to backspace 1 space every time to start your code after the docblock in the right spot.

Sublime Text 2's PHP package works this way (which is what I am now using), but some coworkers are on TM / TM2 and I'm trying to figure out what I need to change to port that change over to the TM/TM2.

For example:

/**
 * 
 * Here's my docBlock 
 */[cursor here]

...hit return...

/**
 * 
 * Here's my docBlock 
 */
 [cursor ends up here, should be back 1 space :(]

Any help would be appreciated!

Invalid syntax hilite

Hi,

After PHP 7 updates for type-hints, function/method arguments can take default value more by its type. But GitHub (and Sublime GitHub theme) shows/assumes it as invalid syntax and is coloring by this way.

E.g:

// this is valid, ok
function foo($x = 'Kerem')

// this is valid too, but colored as invalid
function foo(string $x = 'Kerem')
...

You can see these examples anytime in any source file.

Thank you!

switch statement not auto-indented correctly

When you declare a switch statement with switch[tab], the template looks like this:

switch (variable) {
    case 'value':
        # code...
        break;

    default:
        # code...
        break;
}

The code below the case and default is indented. However, when I try to add a new case by pressing return at the end of the first break;, everything stays indented one more to the right than the first case:

switch (variable) {
    case 'value':
        echo 'hello';
        break;
        case 2:
        echo 'hello';
        break;

    default:
        echo 'hello';
        break;
}

When I use Command-Option-[ to Indent Line / Section, most of the statement gets flattened and doesn't match the template:

switch (variable) {
    case 'value':
    echo 'hello';
    break;
    case 2:
    echo 'hello';
    break;

    default:
    echo 'hello';
    break;
}

I would like the auto-indent to make it look like this:

switch (variable) {
    case 'value':
        echo 'hello';
        break;
    case 2:
        echo 'hello';
        break;

    default:
        echo 'hello';
        break;
}

Indentation inside SQL queries

When writing a query, indentation is altered in unexpected manners when editing the last line having the quotation after the insertion point. Like this, the blinking marker is shown with a |

$query = sprintf("SELECT id
                  FROM a_table
                  WHERE some_value = 2
                  |");

Now if I start typing it will move one indent to the left resulting in:

$query = sprintf("SELECT id
                  FROM a_table
                  WHERE some_value = 2
            AND some_other_value = 1");

This is of-course not the end of the world, but the underlying bug that causes this issue might stir up problems in other places as well.

or/and keywords in if-statement are marked as function-call instead of keyword.operator.logical

Another issue that I came across since the last update is the following;

The keywords 'or' and 'and' are marked as meta.function-call.php when they are inside an if-statement like so:

if (true or (false and false))
if (true and (false and false))

I assume this is because of the opening brackets in the if-statement. Before the patch however, this was correctly filtered out and the keywords were correctly marked as keyword.operator.logical.php.

meta.use.php scope not including the use keyword

Hi, I feel that it is incorrect that the meta.use.php scope has not including the "use" keyword.

Currently the code is:

{ begin = '(?i)\s_(use)\s+(?=[a-z_0-9\ ]+\s_(?:;|,|$))';
end = '(?=;|(?:^\s_$)|(?:\s_(?!(/[/])|#)[^,\s]\s$))';
beginCaptures = { 1 = { name = 'keyword.other.use.php'; }; };
patterns = (
{ include = '#comments'; },
{ name = 'meta.use.php';
....

I think it is more correct this way:
{ name = 'meta.use.php';
begin = '(?i)\s_(use)\s+(?=[a-z_0-9\ ]+\s_(?:;|,|$))';
end = '(?=;|(?:^\s_$)|(?:\s_(?!(/[/])|#)[^,\s]\s$))';
beginCaptures = { 1 = { name = 'keyword.other.use.php'; }; };
patterns = (
{ include = '#comments'; },
.....
....

Wrong indentions of a simple if-clause

The indentions of a simple if-clause gets wrong:

<?php
if (true)
        {
                some code
        }
?>

It should of-course look like this:

<?php
if (true)
{
        some code
}
?>

Documentation for Word tm_dialog2 failure

I am trying to use the "Documentation for Word..." function. It appears to be failing at line 149 of this file:

/Applications/TextMate.app/Contents/SharedSupport/Support/lib/ui.rb

Is this a problem with tm_dialog2? When I run tm_dialog2 on the command line, I get "error reaching server". Like this:

$ /Applications/TextMate.app/Contents/PlugIns/Dialog2.tmplugin/Contents/Resources/tm_dialog2
error reaching server

Should that be the case?

Do you have any suggestions to get the tm_dialog2 binary working again?

I am using TextMate Version 1.5.10 (1631).

PHP syntax highlighting

Description:

PHP Syntax highlighting does not seem to pick up the opening <?php tag inside an HTML tag.
Using TextMate version 2.0-alpha.9443
For reference Textmate < v2 handled this correctly.

Actual and Expected Results:
Please see attached image showing how the PHP code renders inside a tag, and how it renders outside a tag.

screen shot 2013-07-26 at 11 49 45

Jump to included file does not work for relative path

Hi,

When pressing CMD-SHIFT-D (Jump to Included File), only files with an absolute path to the file are recognized.

// active file in ~/Desktop/Test
// does not work:
include 'untitled.php';
// does work:
include '/Users/UserName/Desktop/Test/untitled.php';

Tooltip error: file not found.

Also when pressing ESC when the CMD-SHIFT-D pop-up tooltip is active, the following error occurs:
Failure running "Jump to include File"
Command return status code 1

I'am using TM 2.0 beta 8.6 and OSX 10.11.3n (also happens with TM beta 8.5)

regards,
Feek

Suggestion: lookup for a function inside project directory

Hi,
herewith a bash script in order to lookup for a function definition inside a project folder.
Using this script you can directly jump to a function!
Regards,
Feek

#!/bin/bash
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"

function_name="$TM_CURRENT_WORD"
project_dir="$TM_PROJECT_DIRECTORY"

# find php-related files in project directory, result is a string
files_string=`find "$project_dir" -type f | egrep '\.(module|inc|php|engine|install)$'`

# place multi-line sting in a array, works for file names with spaces!
files_array=()
while read -r line; do
   files_array+=("$line")
done <<< "$files_string"

#
# Lookup for a function declaration inside the file content.
# multi space allowed in function declaration
# <file> <function>
#
function lookup_function {
  local line=`nl -b a "$1" | grep 'function\\s\+'"$2"'\\s*(' | awk '{print $1}'`
  if [[ "$line" -gt 0 ]]; then
    mate "$1" -l "$line"
    exit 0
  fi
}

# Iterate the array with files, works for files with spaces!
for (( i=0; i < ${#files_array[*]}; i++)); do
  file="${files_array[${i}]}"
  lookup_function "$file" "$function_name"
done

# Nothing found
echo 'NOTE: Function '${function_name}' was not found within the current project directory.'

Syntax highlighting of ‘trait’

The trait keyword doesn’t have get highlighted as a keyword. Would be good to add it. I’d have a crack at it myself but I’ve never done anything with TextMate bundles!

screen shot 2013-12-19 at 23 34 41

Syntax Highlighting of Regular Expressions in HEREDOC and NOWDOC

In PHP I use heredoc and nowdoc for writing Regular Expressions:

$a = <<<REGEX
/
  ^
    .*  # Match all
  $
/x
REGEX;
$a = <<<'REGEX'
/
  ^
    .*  # Match all
  $
/x
REGEX;

Often I use the PCRE_EXTENDED mode (ignores whitespace and comments), activated by

  • by the /x flag: /RegEx/x or
  • by prepending (?x): /(?x)RegEx/

I would like to see a syntax highlighting

  • of the embedded regex in heredoc and nowdoc and
  • of regex in PCRE_EXTENDED mode in general

Thanks & Greetings

Snippets File name invalid for NTFS

I tried to clone this repo on Windows, and Some files have incorrect filenames.
Is it possible to rename some with only ASCII characters, or it is absolutely necessary to have unicode characters ?

Indentation broken

In Textmate 2 on OS X 10.9 indentation seems to be broken. Same issue in vico described here: vicoapp/vico#22

Some examples:

<?php
$bar = '{}';
   // indentation level increased
array(
  '1' => '1',
  '#1' => 1,
    // indentation level increased
)
$form['#after_build'] = array('some_string');
  // indentation level increased

This seems to be related to the # character, which is quite vital to coding in Drupal.
I would like to give some help, but I'm getting lost in the regexes.

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.