PHP's documentation maintaining its usual level of precision
Description
A screenshot of the official-looking documentation for the PHP `count()` function. The header 'count' is shown in purple text, followed by a dotted underline. Below, it indicates compatibility with '(PHP 4, PHP 5, PHP 7)'. The function's description reads: 'count - Count all elements in an array, or something in an object'. The humor lies in the extremely vague and unprofessional phrase 'or something in an object'. Technical documentation is expected to be precise and unambiguous, but this wording is the opposite, playing directly into the long-running stereotype of PHP having inconsistent and poorly defined language features. This resonates deeply with senior developers who have historical context of PHP's evolution and its reputation for quirks
Comments
13Comment deleted
I see PHP is still using the 'I have no idea what this does to objects but it returns a number so ship it' philosophy for its core functions
PHP manual: count() counts elements in an array - or “something” in an object. After 20 years of duct-taping Countable, Traversable, and magic __get(), even the docs have adopted our code-review strategy: ship it and let prod figure out what “something” means
"Count all elements in an array, or something in an object" - the exact level of type safety that led to three rewrites, two migrations, and one CTO asking why our API returns different counts depending on the phase of the moon
Ah yes, PHP's count() function: 'Count all elements in an array, or something in an object.' That 'or something' is doing more heavy lifting than a microservice architecture at a FAANG company. It's the documentation equivalent of 'TODO: figure this out later' that somehow shipped to production in 2000 and has been there ever since. Senior engineers know that 'or something' translates to 'implements Countable, or returns 1 for objects that don't, except when it returns 0, or throws a warning, depending on which PHP version's mood swings you're dealing with today.' It's the kind of spec ambiguity that makes you appreciate strongly-typed languages with exhaustive documentation - or at least makes you understand why your architect insists on wrapping every PHP built-in in a well-tested abstraction layer
PHP’s count(): arrays return cardinality; objects return “something” - either 1, a warning, or whatever your Countable decides, depending on which decade your codebase was written
PHP's count(): Arrays get precision engineering; objects get 'or something' - the original lazy interface spec
Only PHP docs can define count() as handling arrays… or “something in an object” - which is exactly how our PHP 5 → 7.2 migration spec read until Countable showed up with a clipboard
😂 Comment deleted
Ну да. Интерфейс Countable предпологает свободную реализацию: public function count():int { return 4; } Comment deleted
Код из прода?)) Comment deleted
нет на проде private const COUNT = 4; public function count():int { return self::COUNT; } Comment deleted
лол Comment deleted
Выпал Comment deleted