This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 181207 - Better support for fluent interfaces
Summary: Better support for fluent interfaces
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-25 08:03 UTC by berdir
Modified: 2016-09-22 03:34 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description berdir 2010-02-25 08:03:17 UTC
Fluent interfaces (http://en.wikipedia.org/wiki/Fluent_interface#PHP) are often formatted by placing each method call on a new line.

Currently, when you have such an interface and hit [Enter] to go the the next line, the curser jumps to a strange position:

----
    db_delete('comment')
      ->condition('cid', array_keys($comments), 'IN')
            | (<-- after Enter, curser is here)
---

Especially in Drupal with the new OOP DB Abstraction layer, code like the above example will become more and more popular, it would be great if the curser would jump to the correct position.

Not that these interfaces might get complexer than the above example.

Some typical ones from common Drupal 7 code:
----- Multi-line array arguments:
$comment->cid = db_insert('comment')
  ->fields(array(
    'nid' => $comment->nid,
    'pid' => empty($comment->pid) ? 0 : $comment->pid,
    'uid' => $comment->uid,
    'subject' => $comment->subject,
    'hostname' => ip_address(),
    'created' => $comment->created,
    'changed' => $comment->changed,
    'status' => $comment->status,
    'thread' => $thread,
    'name' => $comment->name,
    'mail' => $comment->mail,
    'homepage' => $comment->homepage,
    'language' => $comment->language,
  ))
  ->execute();
----- Nested stuff (not necessarly good coding style :) )
$query->condition(db_or()
  ->condition('ur.requester_id', $value)
  ->condition(db_and()
    ->condition(db_or()
      ->condition('ur.approved', 1, '<>')
      ->condition('urt.is_oneway', 0, '<>')
    )
    ->condition('ur.requestee_id', $value)
  )
);

I can provide more examples if you need them, but you can also check the source yourself, for example through the github mirror: http://github.com/drupal/drupal
Comment 1 Filip Zamboj 2010-09-15 12:30:54 UTC
batch reassigning
Comment 2 amobilia 2016-09-22 03:34:40 UTC
Reproductible in 8.2rc / Dev 201609210002