The most frequently used PHP functions on GitHub
While preparing the April meetup of the PHP User Group Rheinhessen, Christian came up with an idea: Let's take a look at one of the least used and most "exotic" internal functions of PHP and discuss them. Soon, the question arose, "which functions are only infrequently used?" - A: "Let's take a look at PHP repos on Github!"
After studying Github's Search API, it soon became clear that it's not possible to search all PHP repositories for functions this way. What I had to do was to write a simple crawler that POSTed search queries to the search form on the Github website (while respecting the rate limit, of course).
The results were parsed and saved to a JSON file, and I built a bar chart that visualizes the collected data:
Results & Findings
This approach has some limitations. For example, the most frequent function, file()
, is used almost twice as much as the runner-up, link()
. On closer inspection, however, we found that our search query also returned results containing the __FILE__
magic constant, comments containing the word "file" and other occurrences of this quite common English term.
Other functions, e.g. intlcal_*
were rarely found; we suspect that most of the time the IntlCalendar class
is used instead. So while we the results are not super accurate, they convey a general picture of the frequency of function usage.
We aimed at finding uncommon functions that are useful all the same. The following list is not exhaustive, but interesting, and might serve as inspiration for your next project:
IntlCalendar
: builds on the ICU's Calendar API- ResourceBundle: implements access to ICU resource data files. These files are binary data arrays which ICU uses to store the localized data.
- PCNTL functions: implements the Unix style of process creation, program execution, signal handling and process termination
- Mailparse functions: Mailparse is an extension for parsing and working with email messages.
- Socket functions: The socket extension implements a low-level interface to the socket communication functions based on the popular BSD sockets, providing the possibility to act as a socket server as well as a client.
- NumberFormatter: By invoking the methods provided by the NumberFormatter class, you can format numbers, currencies, and percentages according to the specified or default locale.
- …
Discussion
If you want to discuss the findings and the functions, and generally want to meet nice people and have interesting disucssions, why not join the next meetup of our PHP User Group Rheinhessen (or any other User Group close to you)? You're also invited to play around with the results or the project itself (it's on GitHub).
Kommentare
Ansicht der Kommentare: Linear | Verschachtelt