Skip to content

5 comments

unknown author1 hidden

As always, it all depends on context. This would likely not apply to everyone's case.

If the object on which you call the doSomething() method now aggregates a FileTool object instead of the static call you could just pass another object implementing the same interface to the tested object and an alternative implementation would be used. In case of unit tests you could use PHPUnit's mocking features to automatically generate a mock object for you, which then is passed to the object. (There are also various other mock object libraries out there.)

In other words, only if you involve yourself in something like the above mentioned example should you be concerned.

2 points

If you're using static classes for one-off things, as in Kohana's modules (Date::WEEK, for ex), then you're fine, but if you're doing examples as shown in the blog post, then yes, static isn't the way to go.

1 points
unknown author

Deleted before we saved it.

1 points

Using statics is pretty much just namespaced function calls. No problem if you're happy following a procedural paradigm overall, but mixing it with OO code tends to be nasty.

1 points
unknown author

Deleted before we saved it.

0 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.