252 | # # NOTE: order of attributes is not specified.
253 | #
254 | # xm.instruct! #
255 | # xm.html { #
256 | # xm.head { #
257 | # xm.title("History") # History
258 | # } #
259 | # xm.body { #
260 | # xm.comment! "HI" #
261 | # xm.h1("Header") # Header
262 | # xm.p("paragraph") # paragraph
263 | # } #
264 | # } #
265 | #
266 | # == Notes:
267 | #
268 | # * The order that attributes are inserted in markup tags is
269 | # undefined.
270 | #
271 | # * Sometimes you wish to insert text without enclosing tags. Use
272 | # the text! method to accomplish this.
273 | #
274 | # Example:
275 | #
276 | # xm.div { #
277 | # xm.text! "line"; xm.br # line
278 | # xm.text! "another line"; xmbr # another line
279 | # } #
280 | #
281 | # * The special XML characters <, >, and & are converted to <,
282 | # > and & automatically. Use the << operation to
283 | # insert text without modification.
284 | #
285 | # * Sometimes tags use special characters not allowed in ruby
286 | # identifiers. Use the tag! method to handle these
287 | # cases.
288 | #
289 | # Example:
290 | #
291 | # xml.tag!("SOAP:Envelope") { ... }
292 | #
293 | # will produce ...
294 | #
295 | # ... "
296 | #
297 | # tag! will also take text and attribute arguments (after
298 | # the tag name) like normal markup methods. (But see the next
299 | # bullet item for a better way to handle XML namespaces).
300 | #
301 | # * Direct support for XML namespaces is now available. If the
302 | # first argument to a tag call is a symbol, it will be joined to
303 | # the tag to produce a namespace:tag combination. It is easier to
304 | # show this than describe it.
305 | #
306 | # xml.SOAP :Envelope do ... end
307 | #
308 | # Just put a space before the colon in a namespace to produce the
309 | # right form for builder (e.g. "SOAP:Envelope" =>
310 | # "xml.SOAP :Envelope")
311 | #
312 | # * XmlMarkup builds the markup in any object (called a _target_)
313 | # that accepts the << method. If no target is given,
314 | # then XmlMarkup defaults to a string target.
315 | #
316 | # Examples:
317 | #
318 | # xm = Builder::XmlMarkup.new
319 | # result = xm.title("yada")
320 | # # result is a string containing the markup.
321 | #
322 | # buffer = ""
323 | # xm = Builder::XmlMarkup.new(buffer)
324 | # # The markup is appended to buffer (using <<)
325 | #
326 | # xm = Builder::XmlMarkup.new(STDOUT)
327 | # # The markup is written to STDOUT (using <<)
328 | #
329 | # xm = Builder::XmlMarkup.new
330 | # x2 = Builder::XmlMarkup.new(:target=>xm)
331 | # # Markup written to +x2+ will be send to +xm+.
332 | #
333 | # * Indentation is enabled by providing the number of spaces to
334 | # indent for each level as a second argument to XmlBuilder.new.
335 | # Initial indentation may be specified using a third parameter.
336 | #
337 | # Example:
338 | #
339 | # xm = Builder.new(:ident=>2)
340 | # # xm will produce nicely formatted and indented XML.
341 | #
342 | # xm = Builder.new(:indent=>2, :margin=>4)
343 | # # xm will produce nicely formatted and indented XML with 2
344 | # # spaces per indent and an over all indentation level of 4.
345 | #
346 | # builder = Builder::XmlMarkup.new(:target=>$stdout, :indent=>2)
347 | # builder.name { |b| b.first("Jim"); b.last("Weirich) }
348 | # # prints:
349 | # #
350 | # # Jim
351 | # # Weirich
352 | # #
353 | #
354 | # * The instance_eval implementation which forces self to refer to
355 | # the message receiver as self is now obsolete. We now use normal
356 | # block calls to execute the markup block. This means that all
357 | # markup methods must now be explicitly send to the xml builder.
358 | # For instance, instead of
359 | #
360 | # xml.div { strong("text") }
361 | #
362 | # you need to write:
363 | #
364 | # xml.div { xml.strong("text") }
365 | #
366 | # Although more verbose, the subtle change in semantics within the
367 | # block was found to be prone to error. To make this change a
368 | # little less cumbersome, the markup block now gets the markup
369 | # object sent as an argument, allowing you to use a shorter alias
370 | # within the block.
371 | #
372 | # For example:
373 | #
374 | # xml_builder = Builder::XmlMarkup.new
375 | # xml_builder.div { |xml|
376 | # xml.stong("text")
377 | # }
378 | #
379 | class XmlMarkup < XmlBase
380 |
381 | # Create an XML markup builder. Parameters are specified by an
382 | # option hash.
383 | #
384 | # :target=>target_object::
385 | # Object receiving the markup. +out+ must respond to the
386 | # << operator. The default is a plain string target.
387 | # :indent=>indentation::
388 | # Number of spaces used for indentation. The default is no
389 | # indentation and no line breaks.
390 | # :margin=>initial_indentation_level::
391 | # Amount of initial indentation (specified in levels, not
392 | # spaces).
393 | #
394 | def initialize(options={})
395 | indent = options[:indent] || 0
396 | margin = options[:margin] || 0
397 | super(indent, margin)
398 | @target = options[:target] || ""
399 | end
400 |
401 | # Return the target of the builder.
402 | def target!
403 | @target
404 | end
405 |
406 | def comment!(comment_text)
407 | _ensure_no_block block_given?
408 | _special("", comment_text, nil)
409 | end
410 |
411 | # Insert an XML declaration into the XML markup.
412 | #
413 | # For example:
414 | #
415 | # xml.declare! :ELEMENT, :blah, "yada"
416 | # # =>
417 | def declare!(inst, *args, &block)
418 | _indent
419 | @target << ""
435 | _newline
436 | end
437 |
438 | # Insert a processing instruction into the XML markup. E.g.
439 | #
440 | # For example:
441 | #
442 | # xml.instruct!
443 | # #=>
444 | # xml.instruct! :aaa, :bbb=>"ccc"
445 | # #=>
446 | #
447 | def instruct!(directive_tag=:xml, attrs={})
448 | _ensure_no_block block_given?
449 | if directive_tag == :xml
450 | a = { :version=>"1.0", :encoding=>"UTF-8" }
451 | attrs = a.dup.update attrs # was merge, which isn't available with ruby 1.6.8
452 | end
453 | _special(
454 | "#{directive_tag}",
455 | "?>",
456 | nil,
457 | attrs,
458 | [:version, :encoding, :standalone])
459 | end
460 |
461 | private
462 |
463 | # NOTE: All private methods of a builder object are prefixed when
464 | # a "_" character to avoid possible conflict with XML tag names.
465 |
466 | # Insert text directly in to the builder's target.
467 | def _text(text)
468 | @target << text
469 | end
470 |
471 | # Insert special instruction.
472 | def _special(open, close, data=nil, attrs=nil, order=[])
473 | _indent
474 | @target << open
475 | @target << data if data
476 | _insert_attributes(attrs, order) if attrs
477 | @target << close
478 | _newline
479 | end
480 |
481 | # Start an XML tag. If end_too is true, then the start
482 | # tag is also the end tag (e.g.
483 | def _start_tag(sym, attrs, end_too=false)
484 | @target << "<#{sym}"
485 | _insert_attributes(attrs)
486 | @target << "/" if end_too
487 | @target << ">"
488 | end
489 |
490 | # Insert an ending tag.
491 | def _end_tag(sym)
492 | @target << "#{sym}>"
493 | end
494 |
495 | # Insert the attributes (given in the hash).
496 | def _insert_attributes(attrs, order=[])
497 | return if attrs.nil?
498 | order.each do |k|
499 | v = attrs[k]
500 | @target << %{ #{k}="#{v}"} if v
501 | end
502 | attrs.each do |k, v|
503 | @target << %{ #{k}="#{v}"} unless order.member?(k)
504 | end
505 | end
506 |
507 | def _ensure_no_block(got_block)
508 | if got_block
509 | fail IllegalBlockError,
510 | "Blocks are not allowed on XML instructions"
511 | end
512 | end
513 |
514 | end
515 |
516 | end
517 |
518 |
--------------------------------------------------------------------------------
/Support/lib/php.rb:
--------------------------------------------------------------------------------
1 | class PHPFunction
2 | def initialize(prototype)
3 | @parts = prototype.strip.match(/^\s*(?:([0-9A-Za-z|_]+)\s+)?(\w+)\s*\((.*)\).*$/)
4 | end
5 |
6 | def params
7 | params = @parts[3] rescue ''
8 |
9 | params.scan(/(?:\[\s*)?(\w+ )?(&?\$?[\w.|]+)(?:\s*=\s*(.+))?(\])?,?/).map do |(type, name, default, optional_bracket)|
10 | param = type.to_s + name
11 | optional = false
12 | if optional_bracket
13 | # Optional
14 | param = '[' + param + ']'
15 | optional = true
16 | elsif default
17 | # Optional with default
18 | param = '[' + param + ' = ' + default + ']'
19 | optional = true
20 | end
21 | {
22 | :param => param,
23 | :type => type.to_s.strip,
24 | :name => name.to_s,
25 | :optional => optional,
26 | :default => default
27 | }
28 | end
29 | end
30 |
31 | def name
32 | @parts[2]
33 | end
34 |
35 | def type
36 | @parts[1]
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/Support/lib/php_mate.rb:
--------------------------------------------------------------------------------
1 | require "#{ENV["TM_SUPPORT_PATH"]}/lib/scriptmate"
2 |
3 | class PhpScript < UserScript
4 | def lang; "Php" end
5 | # Disable display_errors so that errors are printed to stderr only
6 | # Enabling log_errors (without an error_log) sends errors to stdout
7 | def default_extension; ".php" end
8 | def args
9 | ['-d display_errors=0', '-d log_errors=1', '-d error_log=']
10 | end
11 | def filter_cmd(cmd)
12 | # PHP doesn't understand - to mean stdin :(
13 | cmd[cmd.size - 1] = '--' if cmd.last == '-'
14 | cmd
15 | end
16 | def executable; @hashbang || ENV['TM_PHP'] || 'php' end
17 | def version_string
18 | path = ENV['PATH'].split(':').find { |e| File.exists? File.join(e, executable) }
19 | php_path = File.join(path.to_s, executable)
20 | res = %x{ #{executable} -v }.split[0..2].join %{ }
21 | res + " (#{php_path})"
22 | end
23 | end
24 |
25 | class PhpMate < ScriptMate
26 | def filter_stderr(str)
27 | # strings from stderr are passed through this method before printing
28 | super(str).
29 | gsub(/(#\d+ )((.+?)\((\d+)\)): /) {
30 | $1 + ' ' + $2 + ': '
31 | }.
32 | gsub(/in (.+?) on line (\d+)(
$)?/) {
33 | 'in ' + $1 + ' on line ' + $2 + '' + $3.to_s
34 | }
35 | end
36 |
37 | def filter_stdout(str)
38 | # strings from stderr are passed through this method before printing
39 | super(str).gsub(/\[([^\]]+?) line (\d+)\]
$/) {
40 | '[' + $1 + ' line ' + $2 + ']
'
41 | }
42 | end
43 | end
44 |
45 | script = PhpScript.new(STDIN.read)
46 | PhpMate.new(script).emit_html
47 |
--------------------------------------------------------------------------------
/Support/textmate.php:
--------------------------------------------------------------------------------
1 | = 5.2.0) then it is checked
17 | * and javascript will be printed only if there has been an error
18 | *
19 | * If TEXTMATE_NO_ERRORS is defined then the javascript will never be printed
20 | */
21 |
22 | /*
23 | * Print the javascript to parse and link errors
24 | */
25 | function textmate_print_error_handler() {
26 | @include(dirname(__FILE__) . "/textmate_error_handler.html");
27 | }
28 |
29 | /*
30 | * If TEXTMATE_ERRORS is defined then this will set up a shutdown function
31 | * to automatically print the javascript error parser at the end of the page
32 | * If error_get_last() is available (PHP 5 >= 5.2.0) then the javascript
33 | * will be printed only if an error has occured (since printing at the end
34 | * of the page will invalidate it)
35 | */
36 | if (defined('TEXTMATE_ERRORS')) {
37 | register_shutdown_function(create_function('', '
38 | if (!function_exists("error_get_last") || error_get_last())
39 | textmate_print_error_handler();'
40 | ));
41 | }
42 |
43 | /*
44 | * textmate_backtrace()
45 | *
46 | * Dumps a backtrace in the same format as debug_print_backtrace(), adding links
47 | * to files & lines using the txmt://open schema
48 | *
49 | * Regexing the output of debug_print_backtrace() would be easier but we can't use
50 | * output buffering in case it's already being used
51 | */
52 | function textmate_backtrace() {
53 | echo '';
54 | foreach (debug_backtrace() as $number => $trace) {
55 | echo "#{$number} ";
56 | if (isset($trace['class'])) echo $trace['class'], '::';
57 | echo $trace['function'], '(';
58 | if (isset($trace['args'])) echo implode(', ', $trace['args']);
59 | echo ') called at [';
60 | $file = $line = '';
61 | if (strpos($trace['file'], 'eval') !== false) {
62 | $matches = array();
63 | if (preg_match('/^(.+)\((\d+)\) : eval/', $trace['file'], $matches))
64 | list($dummy, $file, $line) = $matches;
65 | } else {
66 | $file = $trace['file'];
67 | $line = $trace['line'];
68 | }
69 | echo '', $trace['file'], ':', $trace['line'], "]\n";
70 | }
71 | echo '
';
72 | }
73 | ?>
--------------------------------------------------------------------------------
/Support/textmate_error_handler.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Tests/indentation.php:
--------------------------------------------------------------------------------
1 | '1',
55 | '#1' => 1,
56 | // # in previous line shoud not make this line be indented
57 | );
58 | $form['#after_build'] = array('some_string');
59 | // # in previous line shoud not make this line be indented
60 |
61 | # No indent after comment lines
62 | bar();
63 | // No indent after comment lines
64 | baz();
65 |
66 | ?>
--------------------------------------------------------------------------------
/Tests/insert-call-to-parent.php:
--------------------------------------------------------------------------------
1 | function (stdClass $foo = invalid, array $blah) use (&$foo, $bar) {
156 | $test = 'test';
157 | }
158 | );
159 |
160 | $blah();
161 | $blah(1, 2, 3);
162 | blah(1, 2, 3);
163 |
164 | $blah = new Foo();
165 | $blah = new Foo;
166 | $blah = new \blah\Foo();
167 | $blah = new blah\Foo();
168 | $blah = new $foo();
169 | $blah = new $foo;
170 | $blah = new blah\$Foo();
171 |
172 | Foo::bar(new test());
173 | Foo::bar(new test);
174 | blah\Foo::bar(new blah\test());
175 |
176 | // ========================
177 | // = String interpolation =
178 | // ========================
179 | '$foo'
180 | '\''
181 | '\\'
182 | "1\1111"
183 | "1\x111"
184 | "$foo"
185 | "$foo[bar]" // 'bar' is treated as a string automatically by PHP
186 | "{$foo[bar]}" // 'bar' is treated as a *constant*
187 | "$foo[0]"
188 | "$foo[$bar]"
189 | "$foo->bar"
190 | "$foo->bar(" // Should show as access to property ->bar, not as a call to ->bar()
191 | "$foo->$bar" // Should not show as an object property access, but as two separate variables
192 | "{$foo->$bar}"
193 | "{$foo->{$bar}}"
194 | "{$foo->${bar}}"
195 | "{$foo->{$bar . $baz}}"
196 | "{$foo->bar}"
197 | "{$foo->bar[0]->baz}"
198 | "{$foo->bar(12, $foo)}"
199 | "{$foo(12, $foo)}"
200 |
201 | $foo = $foo->{'foo' . 'bar'};
202 | $foo = $foo->{"foo{$bar}"};
203 |
204 | $beer = 'Heineken';
205 | echo "$beer's taste is great"; // works; "'" is an invalid character for variable names
206 | echo "He drank some $beers"; // won't work; 's' is a valid character for variable names but the variable is "$beer"
207 | echo "He drank some ${beer}s"; // works
208 | echo "He drank some {$beer}s"; // works
209 |
210 | // The text "($str[1" should *not* be highlighted as a syntax error.
211 | $str = array("Foo", "Bar");
212 | echo 'Name: ' . $str[($str[1]) ? 1 : 0]; // Should echo "Name: Bar"
213 | echo "Name: {$str[($str[1]) ? 1 : 0]}"; // Should echo "Name: Bar"
214 |
215 | echo "{\$";
216 | echo "$foo";
217 | echo "$_SERVER[foo]";
218 | echo "{$_SERVER['foo']}";
219 | echo "{$foo}";
220 | echo "${foo}"; // 'foo' should be variable.other.php
221 | echo "$foo->${bar}"; // '->' should not be keyword.operator.class.php
222 | echo "This works: " . $arr['foo'][3];
223 | echo "This works too: {$obj->values[3]->name}";
224 | echo "This is the value of the var named $name: {${$name}}";
225 | echo "This is the value of the var named by the return value of getName(): {${getName()}}";
226 | echo "Blah: {${Foo::bar()}}";
227 |
228 | $blah = $foo[123];
229 | $blah = $foo[$bar];
230 | $blah = $foo[bar()];
231 | $blah = $foo->bar(123);
232 | $blah = ${'foo'};
233 |
234 | $blah = $foo[123];
235 | $blah = $_POST['blah'];
236 | $blah = new $_POST['blah'];
237 | $blah = new $foo;
238 | $blah = new $foo->{$bar};
239 | $blah = new $foo->{$bar . '123'};
240 | $blah = new $foo->{${bar()}};
241 |
242 | $bar = array(
243 | '123' => '321',
244 | );
245 | $x = 2;
246 |
247 | echo 'foo ' . $bar['1' . $x . '3'];
248 | echo 'foo ' . $bar["1{$x}3"];
249 | echo "foo {$bar["1{$x}3"]}";
250 |
251 | // Heredoc
252 | $foo = <<bar}
254 | Stuff goes here
255 | BLAH;
256 |
257 | // Nowdoc (no interpolation should occur here)
258 | $foo = <<<'BLAH'
259 | Blah blah $foo blah {$foo->bar}
260 | Stuff goes here
261 | BLAH;
262 |
263 | namespace foo\bar;
264 |
265 | E_ERROR
266 | E_DEPRECATED
267 | E_NOTICE
268 | E_COMPILE_ERROR
269 | E_PARSE
270 | E_USER_DEPRECATED
271 | __FILE__
272 | __DIR__
273 | __NAMESPACE__
274 | CURRENCY_SYMBOL
275 | \CURRENCY_SYMBOL
276 | foo\CURRENCY_SYMBOL
277 | E_ERROR
278 | \E_ERROR
279 | foo\E_ERROR
280 |
281 | array_map();
282 | array_map($test, 'foo', MY_CONST);
283 | \array_map();
284 | blah\array_map();
285 | namespace\array_map($test, 'foo');
286 |
287 | // `namespace` should not be highlighted as a namespace component but rather as an operator like
288 | // `self` or `static`
289 | \foo\blah();
290 | namespace\foo();
291 | $blah = new foo();
292 | $blah = new foo\bar();
293 | $blah = new foo\bar\();
294 | $blah = new namespace\Foo();
295 | $blah = new self\Foo();
296 | $foo->bar();
297 |
298 | // `self` and `static` should be storage.type.php
299 | self::foo();
300 | static::foo();
301 | static::foo();
302 | parent::foo();
303 | Blah::foo();
304 | \foo\Blah::foo();
305 |
306 | $foo = self::BAR;
307 | $foo = static::BAR;
308 | $foo = self::$bar;
309 | $foo = static::$bar;
310 |
311 | static::${$test} = 'test';
312 | Blah::${$test} = 'test';
313 | \foo\Blah::${$test} = 'test';
314 | ${$test} = 'test';
315 |
316 | new self(); // `self` should highlight differently
317 | new static(); // `static` should highlight differently
318 | new Blah();
319 |
320 | goto foo;
321 |
322 | foo:
323 |
324 | goto blah;
325 |
326 | blah: {
327 |
328 | }
329 |
330 |
331 | // =======
332 | // = SQL =
333 | // =======
334 |
335 | // This looks like a mess, but there are quite a few ways you can trick the grammar here, and the
336 | // following lines know all the tricks.
337 |
338 | 'SELECT * from foo WHERE bar = \'foo \\ ' . $foo . ' AND blah';
339 | 'SELECT * from foo WHERE bar = \'foo \\ ' . $foo . " AND blah";
340 | 'SELECT * from foo WHERE bar = "foo" asdas' . $foo . '" asdasd';
341 |
342 | "SELECT \"$foo\" FROM bar";
343 | "SELECT `$foo` FROM bar";
344 | "SELECT '$foo' FROM bar";
345 | 'SELECT \'$foo\' FROM bar';
346 | 'SELECT `$foo` FROM bar';
347 | 'SELECT "$foo" FROM bar';
348 | "SELECT * from foo WHERE bar = 'asd $foo $foo->bar {$foo->bar[12]} asda' 'unclosed string";
349 | "SELECT * from foo WHERE bar = \"dsa$foo\" \"unclosed string";
350 | 'SELECT * from foo WHERE bar = "unclosed string';
351 |
352 | 'SELECT * from foo WHERE bar = ' . $foo . ' bar" AND foo = 1';
353 | 'SELECT * from foo WHERE bar = ' . ' bar" AND foo = 1';
354 |
355 | 'SELECT * from foo WHERE bar = "foo \" ' . $foo . ' bar" AND foo = 1';
356 |
357 | 'SELECT * FROM `foo' . $bar . '` WHERE foo = 1' . fasdf('asdf') . ' AND other = "blah"';
358 | "SELECT * FROM `foo" . $bar . "` WHERE foo = 1";
359 | "SELECT * FROM `foo` WHERE foo = 'blah" . $x . "' AND other = 'stuff'";
360 | "SELECT * FROM `foo` WHERE foo = '{$xblah}" . "' AND other = 'stuff'";
361 | // Something
362 |
363 | 'SELECT * FROM \` blah';
364 | "SELECT * FROM `foo` WHERE foo = \"blah" . $x . "\" AND other = 'stuff'";
365 | 'SELECT * FROM `foo` WHERE foo = "blah' . '" AND other = "stuff"';
366 | 'SELECT * FROM `foo` WHERE foo = "blah' . $x . '" AND other = "stuff"';
367 | "SELECT * FROM \``foo" . $bar . "` WHERE foo = 'blah'";
368 | "SELECT * FROM \"foo" . $bar . "baz\" WHERE foo = 'blah'";
369 | "SELECT * FROM `foo" . $bar . "baz` WHERE foo = 'blah'";
370 | "SELECT * FROM 'foo" . $bar . "baz' WHERE foo = 'blah'";
371 | 'SELECT * FROM \'foo' . $bar . 'baz\' WHERE foo = "blah"';
372 | 'SELECT * FROM `foo' . $bar . 'baz` WHERE foo = "blah"';
373 | 'SELECT * FROM "foo' . $bar . 'baz" WHERE foo = "blah"';
374 | 'SELECT * FROM "foo' . ($bar) . 'baz" WHERE foo = "blah"';
375 | ('SELECT * FROM "foo') . ($bar) . 'baz" WHERE foo = "blah"';
376 | 'SELECT * FROM foo' . $bar + 1 . 'baz WHERE foo = "blah"');
377 | 'SELECT * FROM foo WHERE blah = "blah"';
378 | 'SELECT * FROM `foo` WHERE blah = "blah"';
379 | 'SELECT * FROM `f\`' . 'oo` WHERE blah = "blah"';
380 | 'SELECT * FROM `f\` asd`f \` asdf`' . 'oo` WHERE blah = "blah"';
381 | 'SELECT * FROM `foo` WHERE blah = "bl\"' . 'ah"';
382 | "SELECT * FROM foo WHERE blah = 'blah'";
383 | "SELECT * FROM foo WHERE blah = 'bl\'" . "ah'";
384 | "SELECT * FROM `foo` WHERE blah = 'blah'";
385 | "SELECT * FROM `f\`" . "oo` WHERE blah = 'blah'";
386 | // Comments
387 |
388 | 'SELECT * FROM # foo bar \' asdassdsaas';
389 | 'SELECT * FROM -- foo bar \' asdassdsaas';
390 | "SELECT * FROM # foo bar \" asdassdsaas";
391 | "SELECT * FROM -- foo bar \" asdassdsaas";
392 |
393 |
394 | $foo = new Bar();
395 |
396 | $mode = PDO::FETCH_ASSOC;
397 | $mode = \PDO::FETCH_ASSOC;
398 | $mode = namespace\PDO::FETCH_ASSOC;
399 | $blah = \stuff\PDO::FETCH_ASSOC;
400 | $more = stuff\PDO::FETCH_ASSOC;
401 | $blah = \stuff\more\PDO::FETCH_ASSOC;
402 | $more = stuff\more\PDO::FETCH_ASSOC;
403 | $blah = $blah::FETCH_ASSOC;
404 | $blah = \blah\$blah::FETCH_ASSOC;
405 | $blah = \blah\$blah\foo\$blah::FETCH_ASSOC;
406 |
407 | $mode = PDO::$prop;
408 | $mode = \PDO::$prop;
409 | $mode = namespace\PDO::$prop;
410 | $blah = \stuff\PDO::$prop;
411 | $more = stuff\PDO::$prop;
412 | $blah = \stuff\more\PDO::$prop;
413 | $more = stuff\more\PDO::$prop;
414 |
415 | $mode = PDO::staticMethod();
416 | $mode = \PDO::staticMethod();
417 | $mode = namespace\PDO::staticMethod();
418 | $blah = \stuff\PDO::staticMethod();
419 | $more = stuff\PDO::staticMethod();
420 | $blah = \stuff\more\PDO::staticMethod();
421 | $more = stuff\more\PDO::staticMethod();
422 | $blah = $foo::staticMethod();
423 | $blah = ($foo::staticMethod());
424 | $blah = ( $foo::staticMethod());
425 |
426 | $mode = funcCall();
427 | $mode = \funcCall();
428 | $mode = namespace\funcCall();
429 | $blah = \stuff\funcCall();
430 | $more = stuff\funcCall();
431 | $blah = \stuff\more\funcCall();
432 | $more = stuff\more\funcCall();
433 |
434 | $blah = $foo->test;
435 | $blah = foo->test;
436 | $blah = ${'foo'}->test;
437 |
438 | // When type hinting:
439 | class Test {
440 | public function __construct(\My\Namespace\MyClass $myClass) {
441 | // ..
442 | }
443 | }
444 | class Test {
445 | public function __construct(namespace\MyClass $myClass) {
446 | // ..
447 | }
448 | }
449 |
450 | // Assuming this is in the same area as type hinting, in catch blocks:
451 |
452 | try {
453 | // ..
454 | } catch (PDOException $e) {
455 | // ..
456 | }
457 | try {
458 | // ..
459 | } catch (asdf\PDOException $e) {
460 | // ..
461 | }
462 | try {
463 | // ..
464 | } catch (\asdf\foo\PDOException $e) {
465 | // ..
466 | }
467 | try {
468 | // ..
469 | } catch (namespace\PDOException $e) {
470 | // ..
471 | }
472 |
473 | // Also while technically not an issue, the namespace keyword isn't actually interpreted as a library keyword and rather as if it was a user defined namespace. (http://www.php.net/manual/en/language.namespaces.nsconstants.php)
474 |
475 | $keyword = new \MyClass();
476 | $keyword = new namesace\MyClass();
477 | $blah = new namespace\MyClass();
478 | $blah = new \namespace\MyClass();
479 | $blah = new foo\namespace\MyClass();
480 |
481 | $blah = new blah();
482 | $blah = new blah\blah();
483 | $blah = new blah\$blah\$blah\blah();
484 |
485 | if ($test == 1) {
486 |
487 | } else if (123 === $foo) {
488 |
489 | } elseif (CONST) {
490 |
491 | } else {
492 |
493 | }
494 |
495 | if ($blah instanceof MyClass) {
496 |
497 | }
498 |
499 | if ($blah instanceof foo\MyClass) {
500 |
501 | }
502 |
503 | if ($blah instanceof namespace\foo\MyClass) {
504 |
505 | }
506 |
507 | if ($blah instanceof $b) {
508 |
509 | }
510 |
511 | foo(&$blah); // Ampersand should be invalid.deprecated.call-time-pass-by-reference.php
512 | foo(&$blah, array(), &$blah); // Ampersand should be invalid.deprecated.call-time-pass-by-reference.php
513 | foo(array($blah, &$foo)); // Ampersand should be storage.modifier.reference.php
514 |
515 | $foo = <<
527 |
528 | HTML;
529 |
530 | // test
531 |
532 | $blah =<<test()
623 | /* something */
624 | ->blah()
625 | // test
626 | ->oneMore();
627 |
628 | $blah = "INSERT INTO foo SET blah = '12"; // Unclosed single quote should not be a problem
629 | $blah = "INSERT INTO `catalogue` SET
630 | `model`='{$_POST["page_row{$count}_model"]}',
631 | `type`='{$_POST["page_row{$count}_type"]}'
632 | ;");
633 |
634 | $str = 'foo' . 'bar';
635 | $str .= 'foo';
636 |
637 | $x = 0;
638 | $x++;
639 | $y--;
640 | $x += 1;
641 | $x -= 1;
642 | $y = 2;
643 |
644 | $x = $x + $y;
645 | $x = $x - $y;
646 | $x = $x / $y;
647 | $x = $x * $y;
648 | $x = $x % $y;
649 | $x = $x << $y;
650 | $x = $x >> $y;
651 | $x = $x ~ $y;
652 | $x = $x ^ $y;
653 | $x = $x & $y;
654 | $x = $x | $y;
655 |
656 | $bar =& foo();
657 | $bar = &foo();
658 | $baz =& $bar;
659 | $baz = &$bar;
660 |
661 | foo(&$bar);
662 |
663 | $x = $x || $y;
664 | $x = $x && $y;
665 | $x = $x and $y;
666 | $x = $x or $y;
667 | $x = $x xor $y;
668 | $x = $x as $y;
669 |
670 | if ($x == 0) { }
671 | if ($x === 0) { }
672 | if ($x != 0) { }
673 | if ($x !== 0) { }
674 | if ($x < 0) { }
675 | if ($x <= 0) { }
676 | if ($x > 0) { }
677 | if ($x >= 0) { }
678 | if ($x <= 0) { }
679 | if ($x <> 0) { }
680 |
681 | $arr = array(1, 2, 3);
682 | $arr = array(array(1, 2, 3), array(1, 2, 3));
683 |
684 | $foo();
685 | $$foo();
686 |
687 | if (true and false) {}
688 | if (true or (true and false)) {}
689 |
690 | $blah = (binary) $foo;
691 | $blah = (int) $foo;
692 | $blah = (integer) $foo;
693 | $blah = (bool) $foo;
694 | $blah = (boolean) $foo;
695 | $blah = (float) $foo;
696 | $blah = (double) $foo;
697 | $blah = (real) $foo;
698 | $blah = (string) $foo;
699 | $blah = (array) $foo;
700 | $blah = (object) $foo;
701 | $blah = (unset) $foo;
702 |
703 | ?>
--------------------------------------------------------------------------------
/Tests/uncommon-comments.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | contactEmailRot13
6 | pvnjny@tznvy.pbz
7 | contactName
8 | Ciarán Walsh
9 | deleted
10 |
11 | 6FABC1A4-8CD0-11D9-B507-000D93C8BE28
12 | D723521E-CC93-419A-8056-D5178F28615B
13 | 9E187BE5-3E25-49A1-9FA1-D7EF18DF027D
14 | ADE95F8E-EC59-482C-AAD6-0212D5D7AB61
15 | C65A0A03-956D-11D9-B0A1-000D93382786
16 | FDFDEE91-956D-11D9-B0A1-000D93382786
17 | 13266D30-956E-11D9-B0A1-000D93382786
18 | 2CDD1B21-956E-11D9-B0A1-000D93382786
19 |
20 | description
21 | <a href="http://www.php.net/">PHP</a> is a widely-used general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
22 | mainMenu
23 |
24 | excludedItems
25 |
26 | 26BC937A-5A0B-493E-B51F-1AF6E6FEFAD4
27 | 6F7E7868-F5A2-4B7D-ACFB-2A8DE2CD04E2
28 | 89385241-0117-42AE-BDAE-0471554CC3DF
29 | 647C793F-9098-481B-8B5A-BCEF3B48CB03
30 | E0FF5942-5249-4097-A4EE-E01FAE518CD2
31 |
32 | items
33 |
34 | 774E75DA-A747-4CB4-B8AF-DE720B01E295
35 | EC271DAE-BEC9-11D9-8856-000D93589AF6
36 | F82CE7A9-5E20-4B01-95EE-85255FB5A489
37 | B3E79B47-40E9-4EF9-BAD9-11FEEE0D238F
38 | ------------------------------------
39 | 412481DC-89B7-11D9-9FE3-000A9584EC8C
40 | 19A164B7-4A3C-421B-9866-85FB9077A983
41 | 7E7936B6-7334-455B-A5ED-D51CA49CF532
42 | ------------------------------------
43 | D2D8EC3B-7ABB-4309-BF61-438772AF1404
44 | C8984E70-D940-4477-B3F7-B0EB6F949012
45 | A3930E6A-FFFE-4E60-B797-052D34824F68
46 | ------------------------------------
47 | DC9A3E58-34D0-4BD3-9D86-944F5DAC76A8
48 | ------------------------------------
49 | 46E85E86-E85A-40EB-BC7A-0F06BC4AE9FB
50 | ------------------------------------
51 | 8AAEC70A-8CCF-11D9-B507-000D93C8BE28
52 | A94E02E2-8CCF-11D9-B507-000D93C8BE28
53 | 60129434-8CCF-11D9-B507-000D93C8BE28
54 | 6E25DCEF-8CCF-11D9-B507-000D93C8BE28
55 | 34E2C808-8CCF-11D9-B507-000D93C8BE28
56 | 4833C612-8CCF-11D9-B507-000D93C8BE28
57 | ------------------------------------
58 | 2B91DE5F-8CD0-11D9-B507-000D93C8BE28
59 | 1634287E-035A-4617-9AD8-09133183F8FE
60 | CBF8F204-8CCF-11D9-B507-000D93C8BE28
61 | 7720523B-8CCE-11D9-B507-000D93C8BE28
62 | ------------------------------------
63 | C81F7FF7-7899-48F5-AD79-F248B7BC3DCB
64 |
65 | submenus
66 |
67 | 46E85E86-E85A-40EB-BC7A-0F06BC4AE9FB
68 |
69 | items
70 |
71 | 6F3ABAC6-EEC9-4797-8D4A-6FD549094852
72 | 9C891C7B-CFA8-4860-B76F-4E3AD60B0E13
73 |
74 | name
75 | Support
76 |
77 | 93896C6F-4D1B-47EA-94B2-887CAB6ABFC2
78 |
79 | items
80 |
81 | BB471E3A-8CCD-11D9-B507-000D93C8BE28
82 | 117476CE-7A7F-4DC4-9A4E-772D282983A3
83 | ED759470-69D7-4ADF-9842-D890DEB00F19
84 | 4F33617A-80FE-47D2-84AF-AA3D5D8A7128
85 | E863B097-0FD5-43D5-8547-235330081203
86 | 3F335934-360B-40F2-9D5C-CB299FD2F215
87 | 1E34E416-CD16-4C16-A369-9CDC3FAFD4C4
88 | 5F800F2D-55DA-4E06-99A3-41B734C8768E
89 | 7553818C-6FF8-455D-BD83-D2A587BAF6F4
90 |
91 | name
92 | Wrapped in <?php … ?>
93 |
94 | A3930E6A-FFFE-4E60-B797-052D34824F68
95 |
96 | items
97 |
98 | 80D861BF-8CD0-11D9-B507-000D93C8BE28
99 | 459B8A24-8CD0-11D9-B507-000D93C8BE28
100 | 56873C6E-8CD0-11D9-B507-000D93C8BE28
101 |
102 | name
103 | Return
104 |
105 | C8984E70-D940-4477-B3F7-B0EB6F949012
106 |
107 | items
108 |
109 | E8BDF86F-8CD0-11D9-B507-000D93C8BE28
110 | 9B253562-8CD0-11D9-B507-000D93C8BE28
111 | B90F3AE5-8CD0-11D9-B507-000D93C8BE28
112 | FF0A8A5C-8CD0-11D9-B507-000D93C8BE28
113 | CF29C6B5-8CD0-11D9-B507-000D93C8BE28
114 | 4E18C61F-8CD1-11D9-B507-000D93C8BE28
115 | 19B4F695-8CD1-11D9-B507-000D93C8BE28
116 | 306E5B79-8CD1-11D9-B507-000D93C8BE28
117 | 40A7709D-8CD1-11D9-B507-000D93C8BE28
118 |
119 | name
120 | Globals
121 |
122 | D2D8EC3B-7ABB-4309-BF61-438772AF1404
123 |
124 | items
125 |
126 | 93896C6F-4D1B-47EA-94B2-887CAB6ABFC2
127 | ------------------------------------
128 | 35F46C2E-8CCE-11D9-B507-000D93C8BE28
129 | 4B72EA1F-8CCE-11D9-B507-000D93C8BE28
130 | 609FE8EB-B251-11D9-872D-000D93C8BE28
131 | 61DCF7E4-8CCE-11D9-B507-000D93C8BE28
132 | AC5561AA-8CCE-11D9-B507-000D93C8BE28
133 | C0229432-8CCE-11D9-B507-000D93C8BE28
134 | DA4B6728-8CCE-11D9-B507-000D93C8BE28
135 | F262B1FA-8CCE-11D9-B507-000D93C8BE28
136 | 0D955946-8CCF-11D9-B507-000D93C8BE28
137 | 1C06D786-8CCF-11D9-B507-000D93C8BE28
138 | 0F39268F-8CD0-11D9-B507-000D93C8BE28
139 | EC96DA26-8CCF-11D9-B507-000D93C8BE28
140 | DF786227-F5C9-48A1-8C80-49306AE82B6A
141 | ------------------------------------
142 | C1B97DFD-7F2E-4CF8-881D-F63843DE8BD5
143 | ------------------------------------
144 | FE39640E-A69C-48DF-9282-633672AAEFD2
145 | F7751DAF-AC95-4D47-955F-FE2534FDE4F5
146 | 978B5E5E-F5C6-4FD8-B346-B0C85883D600
147 |
148 | name
149 | Declarations
150 |
151 | DC9A3E58-34D0-4BD3-9D86-944F5DAC76A8
152 |
153 | items
154 |
155 | EBD6D4CF-9F5E-4616-9880-5D3FF21EF408
156 | 42F50AE3-4F1C-43EB-9722-D80261A19625
157 | ------------------------------------
158 | 775F7FCC-C43C-4C23-B935-9D5F6C25CF1D
159 | 94D8B40B-9F49-4B6D-90B5-DBFF5FB36590
160 | ------------------------------------
161 | 9086BA3F-87E7-11D9-A6A3-000D93589AF6
162 | 90879700-87E7-11D9-A6A3-000D93589AF6
163 | ------------------------------------
164 | 9086E254-87E7-11D9-A6A3-000D93589AF6
165 | ------------------------------------
166 | 9087051B-87E7-11D9-A6A3-000D93589AF6
167 | 908774B1-87E7-11D9-A6A3-000D93589AF6
168 | ------------------------------------
169 | 90872B90-87E7-11D9-A6A3-000D93589AF6
170 | 90874D6F-87E7-11D9-A6A3-000D93589AF6
171 |
172 | name
173 | PHPDoc
174 |
175 |
176 |
177 | name
178 | PHP
179 | ordering
180 |
181 | E8BDF86F-8CD0-11D9-B507-000D93C8BE28
182 | 9B253562-8CD0-11D9-B507-000D93C8BE28
183 | B90F3AE5-8CD0-11D9-B507-000D93C8BE28
184 | FF0A8A5C-8CD0-11D9-B507-000D93C8BE28
185 | CF29C6B5-8CD0-11D9-B507-000D93C8BE28
186 | 4E18C61F-8CD1-11D9-B507-000D93C8BE28
187 | 19B4F695-8CD1-11D9-B507-000D93C8BE28
188 | 306E5B79-8CD1-11D9-B507-000D93C8BE28
189 | 40A7709D-8CD1-11D9-B507-000D93C8BE28
190 | BB471E3A-8CCD-11D9-B507-000D93C8BE28
191 | 117476CE-7A7F-4DC4-9A4E-772D282983A3
192 | ED759470-69D7-4ADF-9842-D890DEB00F19
193 | 1E34E416-CD16-4C16-A369-9CDC3FAFD4C4
194 | E863B097-0FD5-43D5-8547-235330081203
195 | 4F33617A-80FE-47D2-84AF-AA3D5D8A7128
196 | 3F335934-360B-40F2-9D5C-CB299FD2F215
197 | C1B97DFD-7F2E-4CF8-881D-F63843DE8BD5
198 | 26BC937A-5A0B-493E-B51F-1AF6E6FEFAD4
199 | 9C891C7B-CFA8-4860-B76F-4E3AD60B0E13
200 | 6F3ABAC6-EEC9-4797-8D4A-6FD549094852
201 | 90879700-87E7-11D9-A6A3-000D93589AF6
202 | 9086BA3F-87E7-11D9-A6A3-000D93589AF6
203 | 9086E254-87E7-11D9-A6A3-000D93589AF6
204 | 908774B1-87E7-11D9-A6A3-000D93589AF6
205 | 9087051B-87E7-11D9-A6A3-000D93589AF6
206 | 90872B90-87E7-11D9-A6A3-000D93589AF6
207 | 90874D6F-87E7-11D9-A6A3-000D93589AF6
208 | 775F7FCC-C43C-4C23-B935-9D5F6C25CF1D
209 | 0F39268F-8CD0-11D9-B507-000D93C8BE28
210 | 8AAEC70A-8CCF-11D9-B507-000D93C8BE28
211 | A94E02E2-8CCF-11D9-B507-000D93C8BE28
212 | 1C06D786-8CCF-11D9-B507-000D93C8BE28
213 | 2B91DE5F-8CD0-11D9-B507-000D93C8BE28
214 | 609FE8EB-B251-11D9-872D-000D93C8BE28
215 | 61DCF7E4-8CCE-11D9-B507-000D93C8BE28
216 | AC5561AA-8CCE-11D9-B507-000D93C8BE28
217 | C0229432-8CCE-11D9-B507-000D93C8BE28
218 | EC96DA26-8CCF-11D9-B507-000D93C8BE28
219 | DF786227-F5C9-48A1-8C80-49306AE82B6A
220 | 1634287E-035A-4617-9AD8-09133183F8FE
221 | 7720523B-8CCE-11D9-B507-000D93C8BE28
222 | 4B72EA1F-8CCE-11D9-B507-000D93C8BE28
223 | 35F46C2E-8CCE-11D9-B507-000D93C8BE28
224 | 34E2C808-8CCF-11D9-B507-000D93C8BE28
225 | 4833C612-8CCF-11D9-B507-000D93C8BE28
226 | CBF8F204-8CCF-11D9-B507-000D93C8BE28
227 | 60129434-8CCF-11D9-B507-000D93C8BE28
228 | 6E25DCEF-8CCF-11D9-B507-000D93C8BE28
229 | 80D861BF-8CD0-11D9-B507-000D93C8BE28
230 | 56873C6E-8CD0-11D9-B507-000D93C8BE28
231 | 459B8A24-8CD0-11D9-B507-000D93C8BE28
232 | F262B1FA-8CCE-11D9-B507-000D93C8BE28
233 | DA4B6728-8CCE-11D9-B507-000D93C8BE28
234 | FE39640E-A69C-48DF-9282-633672AAEFD2
235 | F7751DAF-AC95-4D47-955F-FE2534FDE4F5
236 | 0D955946-8CCF-11D9-B507-000D93C8BE28
237 | 978B5E5E-F5C6-4FD8-B346-B0C85883D600
238 | 7E7936B6-7334-455B-A5ED-D51CA49CF532
239 | 42F50AE3-4F1C-43EB-9722-D80261A19625
240 | 19A164B7-4A3C-421B-9866-85FB9077A983
241 | C81F7FF7-7899-48F5-AD79-F248B7BC3DCB
242 | B3E79B47-40E9-4EF9-BAD9-11FEEE0D238F
243 | 412481DC-89B7-11D9-9FE3-000A9584EC8C
244 | EBD6D4CF-9F5E-4616-9880-5D3FF21EF408
245 | 94D8B40B-9F49-4B6D-90B5-DBFF5FB36590
246 | 774E75DA-A747-4CB4-B8AF-DE720B01E295
247 | EC271DAE-BEC9-11D9-8856-000D93589AF6
248 | 6F7E7868-F5A2-4B7D-ACFB-2A8DE2CD04E2
249 | B5E34751-D5EB-4AC8-9DB1-779BD6489C76
250 | 22986475-8CA5-11D9-AEDD-000D93C8BE28
251 | 06276449-AA4E-424F-A2B6-9F4138416E50
252 | CBE2288F-76FC-4813-B69B-B90FFAE3391C
253 | 2543E52B-D5CF-4BBE-B792-51F1574EA05F
254 | FD4397A8-415F-47BC-9F8D-E0F0EC364286
255 | E2D08D2E-A99C-4F3A-9B1D-05A75D37A819
256 | CA15DF69-E80D-46DA-BD45-E88C68E92117
257 | F15B444C-13E3-4A3C-83E1-4A6E0C1A84F3
258 | 5157F71C-2801-4385-92EA-3D0B72AEE7C5
259 | 77F2D17D-A48A-4E19-B2A4-B2FBCBD1264D
260 | 998BFB01-C049-4A24-A88E-86173C967748
261 | 89385241-0117-42AE-BDAE-0471554CC3DF
262 | E0FF5942-5249-4097-A4EE-E01FAE518CD2
263 | 647C793F-9098-481B-8B5A-BCEF3B48CB03
264 | 5F800F2D-55DA-4E06-99A3-41B734C8768E
265 | 7553818C-6FF8-455D-BD83-D2A587BAF6F4
266 |
267 | uuid
268 | 467A1966-6227-11D9-BFB1-000D93589AF6
269 |
270 |
271 |
--------------------------------------------------------------------------------