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 4623036
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:55:43+00:00 2026-05-22T02:55:43+00:00

If you search on the reasons why static methods are bad the first thing

  • 0

If you search on the reasons why static methods are bad the first thing you find it is because you can’t override it when you are unit testing.

So is this still true considering in PHP 5.3 you can do whatever you want with the introduction of static::?

Add:

http://sebastian-bergmann.de/archives/883-Stubbing-and-Mocking-Static-Methods.html

Note he explains even how to use singleton without any testing problem:

  • http://sebastian-bergmann.de/archives/882-Testing-Code-That-Uses-Singletons.html
  • 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-22T02:55:44+00:00Added an answer on May 22, 2026 at 2:55 am

    If you have a static member function, it could usually be a free function. The usual reaction is then that the coder has opted for a static member function only because of the myth that “everything must be in an object”.

    That’s why people discourage them.

    And, because it’s not a very convincing argument, those people pointed to unit testing instead. Not sure what they’ll do now.

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

Sidebar

Related Questions

I recently answered this question: What are good reasons to use static methods in
For reasons that should be obvious, this is murder to search for... How do
Search the web for the phrase I cosay. I run across this phrase being
In my custom attribute's static constructor, I search the loaded assembly for all classes
first of all, sorry for my bad english, isnt my native language. Im using
This is a follow up post to this one: Recursively search nested lists I've
For some reasons I cannot get anything to come out of task_for_pid() I can't
I am trying to run this basic JPA/EJB code: public static void main(String[] args){
Pagemethods are static and that is why we can not access page control from
For some reason I can't find any results from my valid index of 3552

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.