Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6243739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:11:55+00:00 2026-05-24T12:11:55+00:00

Ok, guys. Here’s something I’ve been thinking about for a while: As it’s possible

  • 0

Ok, guys. Here’s something I’ve been thinking about for a while:

As it’s possible to chain methods in PHP5, I wonder if it is possible to take the concept even further by in a smart way determining if a method is the last in the chain to be executed – and that’s without utilizing a third method named getResult()?

Normal method calling:

$myClass->dofirst(); // Data is returned from the dofirst-method

What I would like;

$myclass->dofirst()->sortOutputfromDofirstAndReturn();

The idea is that the second method, sortOutputfromDofirstAndReturn() would prevent the dofirst() method from returning, and instead perform the logic stated inside the second method, without needing a third method to bounce the return to the user.

Maybe a bit confusing so let me know if I need to clarify anything!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:11:56+00:00Added an answer on May 24, 2026 at 12:11 pm

    There are few possibilities:

    Add one (or few special) methods (see Doctrien 1.2) that finish chain (execute is special)

    $q = new Doctrine_Query();
    $q->select('Foo')->where('bar = 1')->orderBy('bar')->execute();
    

    If final result is always array like object than You can implement Iterator interface with Your chain logic.

    class Chain implements Iterator { /* implementation */ }
    $c = new Chain();
    foreach ($c->first()->second() as $item) { /* do stuff */ }
    

    Half stupid one. If Your result is string, than reimplement __toString method…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello struggling here guys.. Is it possible to string replace anything between the the
I want to achieve something similar to what these guys do here: - (NSUInteger)countForFetchRequest:(NSFetchRequest
Just a quick question here guys. I've been searching to no avail so far.
Possible Duplicate: How to create a custom sapi voice for tts Hey Guys here's
guys. Here's another sample script in VBScript. It opens internet explorer, navigates to google,
Hey guys I have a little issue here. I have a panel where I
Ok guys and gals, here is my problem: I've built a custom control that
Here is a nice underhand lob pitch to you guys. So basically I've got
Hi guys anyone know what the helll is going on here? ERROR SNIPPET: Loading
Hey Guys, here is my code for this, the only help i get from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.