PHP RFC: Consistent Function Names
Userland implementation of PHP RFC: Consistent Function Names. It
creates aliases with more consistent names., (*1)
There are many functions that named before naming standard in CODING_STANDARDS.
Therefore, PHP has function names like phpversion()
and htmlspecialchars()
., (*2)
We have many function names that comply IEEE 1003.1
standard names. IEEE 1003.1 is also well established names, but it has different naming. IEEE 1003.1 names can be use as
aliases., (*3)
Without cleanups, PHP may have inconsistent API names even if PHP has new APIs for the same purpose because we care
compatibility a lot. Unless we have standard confirming function names at some point, we may keep inconsistent function
names forever and never have consistent function names., (*4)
Please read the RCF for more information: https://wiki.php.net/rfc/consistent_function_names, (*5)
Installation
composer require jasny/php-consistent-function-names
Functions
Functions other than Standard module
http://php.net/manual/en/book.bc.php
- bc_add β bcadd
- bc_comp β bccomp
- bc_div β bcdiv
- bc_mod β bcmod
- bc_mul β bcmul
- bc_pow β bcpow
- bc_pow_mod β bcpowmod
- bc_scale β bcscale
- bc_sqrt β bcsqrt
- bc_sub β bcsub, (*6)
http://php.net/manual/en/book.gettext.php
- gettext_bind_text_domain_codeset β bind_textdomain_codeset
- gettext_bind_text_domain β bindtextdomain
- gettext_dcΒ β dcgettext
- gettext_dcnΒ β dcngettext
- gettext_dΒ β dgettext
- gettext_dnΒ β dngettext
- gettext_nΒ β ngettext
- gettext_text_domain β textdomain, (*7)
http://php.net/manual/en/book.bzip2.php
- bz_close β bzclose
- bz_compress β bzcompress
- bz_decompress β bzdecompress
- bz_errno β bzerrno
- bz_error β bzerror
- bz_errstr β bzerrstr
- bz_flush β bzflush
- bz_open β bzopen
- bz_read β bzread
- bz_write β bzwrite, (*8)
http://php.net/manual/en/book.zlib.php
- gz_close β gzclose
- gz_compress β gzcompress
- gz_decode β gzdecode
- gz_deflate β gzdeflate
- gz_encode β gzencode
- gz_eof β gzeof
- gz_file β gzfile
- gz_getc β gzgetc
- gz_gets β gzgets
- gz_getss β gzgetss
- gz_inflate β gzinflate
- gz_open β gzopen
- gz_passthru β gzpassthru
- gz_puts β gzputs
- gz_read β gzread
- gz_rewind β gzrewind
- gz_seek β gzseek
- gz_tell β gztell
- gz_uncompress β gzuncompress
- gz_write β gzwrite
- gz_read_fileΒ β readgzfile, (*9)
http://php.net/manual/en/book.image.php
- gd_image_sizeΒ β getimagesize
- gd_image_size_from_stringΒ β getimagesizefromstring
- gd_type_to_extension β image_type_to_extension
- gd_type_to_mime_type β image_type_to_mime_type
- gd_2wbmp β image2wbmp
- gd_affine β imageaffine
- gd_affine_matrix_concat β imageaffinematrixconcat
- gd_affine_matrix_get β imageaffinematrixget
- gd_alpha_blending β imagealphablending
- gd_antialias β imageantialias
- gd_arc β imagearc
- gd_char β imagechar
- gd_charup β imagecharup
- gd_color_allocate β imagecolorallocate
- gd_color_allocate_alpha β imagecolorallocatealpha
- gd_color_at β imagecolorat
- gd_color_closest β imagecolorclosest
- gd_color_closest_alpha β imagecolorclosestalpha
- gd_color_closest_hwb β imagecolorclosesthwb
- gd_color_deallocate β imagecolordeallocate
- gd_color_exact β imagecolorexact
- gd_color_exact_alpha β imagecolorexactalpha
- gd_color_match β imagecolormatch
- gd_color_resolve β imagecolorresolve
- gd_color_resolve_alpha β imagecolorresolvealpha
- gd_color_set β imagecolorset
- gd_colors_for_index β imagecolorsforindex
- gd_colors_total β imagecolorstotal
- gd_color_transparent β imagecolortransparent
- gd_convolution β imageconvolution
- gd_copy β imagecopy
- gd_copy_merge β imagecopymerge
- gd_copy_merge_gray β imagecopymergegray
- gd_copy_resampled β imagecopyresampled
- gd_copy_resized β imagecopyresized
- gd_create β imagecreate
- gd_create_from_gd2 β imagecreatefromgd2
- gd_create_from_gd2_part β imagecreatefromgd2part
- gd_create_from_gd β imagecreatefromgd
- gd_create_from_gif β imagecreatefromgif
- gd_create_from_jpeg β imagecreatefromjpeg
- gd_create_from_png β imagecreatefrompng
- gd_create_from_string β imagecreatefromstring
- gd_create_from_wbmp β imagecreatefromwbmp
- gd_create_from_webp β imagecreatefromwebp
- gd_create_from_xbm β imagecreatefromxbm
- gd_create_from_xpm β imagecreatefromxpm
- gd_create_true_color β imagecreatetruecolor
- gd_crop β imagecrop
- gd_crop_auto β imagecropauto
- gd_dashed_line β imagedashedline
- gd_destroy β imagedestroy
- gd_ellipse β imageellipse
- gd_fill β imagefill
- gd_filled_arc β imagefilledarc
- gd_filled_ellipse β imagefilledellipse
- gd_filled_polygon β imagefilledpolygon
- gd_filled_rectangle β imagefilledrectangle
- gd_fill_to_border β imagefilltoborder
- gd_filter β imagefilter
- gd_flip β imageflip
- gd_font_height β imagefontheight
- gd_font_width β imagefontwidth
- gd_ft_bbox β imageftbbox
- gd_ft_text β imagefttext
- gd_gamma_correct β imagegammacorrect
- gd_raw2 β imagegd2
- gd_raw β imagegd
- gd_gif β imagegif
- gd_grab_screen β imagegrabscreen
- gd_grab_window β imagegrabwindow
- gd_interlace β imageinterlace
- gd_is_true_color β imageistruecolor
- gd_jpeg β imagejpeg
- gd_layer_effect β imagelayereffect
- gd_line β imageline
- gd_load_font β imageloadfont
- gd_palette_copy β imagepalettecopy
- gd_palette_to_true_color β imagepalettetotruecolor
- gd_png β imagepng
- gd_polygon β imagepolygon
- gd_ps_bbox β imagepsbbox
- gd_ps_encode_font β imagepsencodefont
- gd_ps_extend_font β imagepsextendfont
- gd_ps_free_font β imagepsfreefont
- gd_ps_load_font β imagepsloadfont
- gd_ps_slant_font β imagepsslantfont
- gd_ps_text β imagepstext
- gd_rectangle β imagerectangle
- gd_rotate β imagerotate
- gd_save_alpha β imagesavealpha
- gd_scale β imagescale
- gd_set_brush β imagesetbrush
- gd_set_interpolation β imagesetinterpolation
- gd_set_pixel β imagesetpixel
- gd_set_style β imagesetstyle
- gd_set_thickness β imagesetthickness
- gd_set_tile β imagesettile
- gd_string β imagestring
- gd_string_up β imagestringup
- gd_widthΒ β imagesx
- gd_heightΒ β imagesy
- gd_true_color_to_palette β imagetruecolortopalette
- gd_ttf_bbox β imagettfbbox
- gd_ttf_text β imagettftext
- gd_types β imagetypes
- gd_wbmp β imagewbmp
- gd_webp β imagewebp
- gd_xbm β imagexbm
- gd_iptc_embed β iptcembed
- gd_iptc_parse β iptcparse
- gd_jpeg2wbmp β jpeg2wbmp
- gd_png2wbmp β png2wbmp, (*10)
http://php.net/manual/en/book.exif.php
- exif_image_type β exif_imagetype
- exif_tag_name β exif_tagname, (*11)
http://php.net/manual/en/book.ctype.php
- ctype modules functions are IEEE functions. Add "ctype_" prefixed IEEE aliases.
- ctype_alnum βΒ ctype_isalnumΒ (IEEE)
- ctype_alpha βΒ ctype_isalphaΒ (IEEE)
- ctype_cntrl βΒ ctype_iscntrlΒ (IEEE)
- ctype_digit βΒ ctype_isdigitΒ (IEEE)
- ctype_graph βΒ ctype_isgraphΒ (IEEE)
- ctype_lower βΒ ctype_islowerΒ (IEEE)
- ctype_print βΒ ctype_isprintΒ (IEEE)
- ctype_punct βΒ ctype_ispunctΒ (IEEE)
- ctype_space βΒ ctype_isspaceΒ (IEEE)
- ctype_upper βΒ ctype_isupperΒ (IEEE)
- ctype_xdigit βΒ ctype_isxdigitΒ (IEEE), (*12)
http://php.net/manual/en/book.mbstring.php
- mb_decode_mime_header β mb_decode_mimeheader
- mb_decode_numeric_entity β mb_decode_numericentity
- mb_encode_mime_header β mb_encode_mimeheader
- mb_encode_numeric_entity β mb_encode_numericentity
- mb_mailΒ β mb_send_mail (There is mail() as standard function), (*13)
Socket Functions
http://php.net/manual/en/book.sockets.php
- IEEE names are prefixed by "socket_".
- socket_get_peer_name β socket_getpeername (IEEE)
- socket_get_sock_name β socket_getsockname (IEEE)
- socket_recv_from β socket_recvfrom (IEEE)
- socket_recv_msg β socket_recvmsg (IEEE)
- socket_send_msg β socket_sendmsg (IEEE)
- socket_send_to β socket_sendto (IEEE)
- socket_errstrΒ β socket_strerror (need more consideration. strerror() is IEEE nameΒ Adjust to accord with other names. errstr/errno abbreviations are used by various functions/classes. e.g. bz_errstr(), MySQLi::$errno.), (*14)
http://php.net/manual/en/book.apache.php
- sapi_request_headersΒ β getallheaders (Categorized as apache function, but available for CLI and FCGI also)
- apache_virtualΒ β virtual
- apache_get_env β apache_getenv
- apache_set_env β apache_setenv, (*15)
Date/Time Functions
http://php.net/manual/en/book.datetime.php
- date_formatΒ β date (Return formatted date string of timestamp)(IEEE)
- date_getΒ β getdate (Return array date)(IEEE)
- date_checkΒ β checkdate
- time_partΒ β idate (Retrieve part of date information as int according to format)
- time_makeΒ β mktime (Return timestamp from number of int parameters)(IEEE)
- time_formatΒ β strftime (Return local time string according to format/locale)(IEEE)
- time_utcΒ β gmdate (Return array GMT/UTC timestamp)
- time_utc_makeΒ β gmmktime (Return GMT/UTC timestamp from array)
- time_utc_formatΒ β gmstrftime (Return GMT/UTC time string according to format/locale)
- time_getΒ β gettimeofday (Return array time of day)(IEEE)
- time_localΒ β localtime (Return localtime() result array. More info than time_get/gettimeofday)(IEEE)
- time_microΒ β microtime (Return microtime resolution time)(IEEE)
- time_parseΒ β strptime (Parse time string generated by time_format/strftime. Return timestamp) (IEEE)
- time_from_stringΒ β strtotime (Parse string time and return timestamp. Return timestamp), (*16)
Directory related : Prefixed by "dir_" It's supposed to be named as "dir module". Note: These functions changes "directory entry" information.
- dir_rename β rename (Rename is actually a directory operation. e.g File deletion/rename is controlled by current dir permission)(IEEE)
- dir_deleteΒ β rmdir (IEEE)
- dir_createΒ β mkdir (IEEE)
- dir_chownβ chown (IEEE)
- dir_chmod β chmod (IEEE)
- dir_chgrp β chgrp(IEEE)
- dir_name β dirname (IEEE)
- dir_glob β glob (IEEE), (*17)
http://php.net/manual/en/ref.dir.php
- dir_setΒ β chdir(IEEE)
- dir_chroot β chroot (IEEE)
- dir_getΒ β getcwd(IEEE)
- dir_openΒ β opendir (IEEE)
- dir_closeΒ β closedir (IEEE)
- dir_readΒ β readdir(IEEE)
- dir_rewindΒ β rewinddir(IEEE)
- dir_scanΒ β scandir (IEEE), (*18)
Function Handling Functions
http://php.net/manual/en/ref.funchand.phpΒ - All of function handling functions are prefixed by "function_" by these.
- function_declaredΒ β get_defined_functions (There are get_defined_constants()/get_defined_vars(), but class/interface/trait use get_declared_classes/interfaces/traits())
- function_createΒ β create_function (There is function_exists())
- function_argΒ β func_get_arg
- function_argsΒ β func_get_args
- function_num_args β func_num_args
- function_call_userΒ β call_user_func
- function_call_user_arrayΒ β call_user_func_array
- function_shutdown_registerΒ β register_shutdown_function
- function_tick_registerΒ β register_tick_function
- function_tick_unregisterΒ β unregister_tick_function
- function_static_call_arrayΒ β forward_static_call_array
- function_static_callΒ β forward_static_call, (*19)
Command Execution Functions
http://php.net/manual/en/ref.exec.php
- exec_passthruΒ β passthru (Named after exec())
- exec_shellΒ β shell_exec
- exec_systemΒ β system (IEEE)
- exec_escape_argΒ β escapeshellarg
- exec_escape_cmdΒ β escapeshellcmd, (*20)
http://php.net/ref.strings
HTMLΒ related:
- html_entities β htmlentities
- html_escapeΒ β htmlspecialchars (Rename it with real meaning)
- html_escape_decodeΒ β htmlspecialchars_decode
- html_nl2brΒ β nl2br
- html_strip_tagsΒ β strip_tags
- html_translation_tableΒ β get_html_translation_table, (*21)
Locate related:
- locale_conv β localeconv (IEEE)
- locale_setΒ β setlocale (IEEE)
- locale_infoΒ β nl_langinfo (IEEE), (*22)
"string" function but no "str_" prefix
- str_cslashesΒ β addcslashes
- str_cslashes_stripΒ β stripcslashes
- str_slashesΒ β addslashes
- str_slashes_stripΒ β stripslashes
- str_chop β chop
- str_count_chars β count_chars
- str_chunk_split β chunk_split
- str_explode β explode
- str_implode β implode
- str_money_format β money_format
- str_number_format β number_format
- str_levenshtein β levenshtein
- str_metaphone β metaphone
- str_parseΒ β parse_str
- str_quote_meta β quotemeta
- str_similar_text β similar_text
- str_soundex β soundex
- str_sscanf β sscanf (IEEE)
- str_rtrim β rtrim
- str_trim β trim
- str_ltrim β ltrim
- str_lc_first β lcfirst
- str_uc_first β ucfirst
- str_uc_words β ucwords
- str_word_wrap β wordwrap, (*23)
Comparison:
- str_cmp β strcmp (IEEE)
- str_ncmp β strncmp (IEEE)
- str_case_cmp β strcasecmp (IEEE)
- str_ncase_cmp β strncasecmp (IEEE)
- str_nat_cmp β strnatcmp (IEEE)
- str_nat_case_cmp β strnatcasecmp (IEEE), (*24)
Conversion:
- str_to_lower β strtolower,Β tolowerΒ (IEEE)
- str_to_upper β strtoupper,Β toupperΒ (IEEE), (*25)
Misc:
- str_get_csv β str_getcsv, (*26)
Named after libc:
- str_chr β strchr (IEEE)
- str_cmp β strcmp (IEEE)
- str_coll β strcoll (IEEE)
- str_cspn β strcspn (IEEE)
- str_ipos β stripos
- str_istr β stristr
- str_len β strlen (IEEE)
- str_pbrk β strpbrk (IEEE)
- str_pos β strpos
- str_rchr β strrchr
- str_rev β strrev
- str_ripos β strripos
- str_rpos β strrpos
- str_spn β strspn (IEEE)
- str_str β strstr (IEEE)
- str_tok β strtok (IEEE)
- str_tr β strtr, (*27)
http://php.net/manual/en/book.mbstring.php
IEEE names are prefixed by "mb_"
- mb_str_cut β mb_strcut
- mb_str_trim_widthΒ β mb_strimwidth
- mb_str_ipos β mb_stripos
- mb_str_istr β mb_stristr
- mb_str_len β mb_strlen (IEEE)
- mb_str_pos β mb_strpos
- mb_str_rchr β mb_strrchr
- mb_str_richr β mb_strrichr
- mb_str_ripos β mb_strripos
- mb_str_rpos β mb_strrpos
- mb_str_str β mb_strstr (IEEE)
- mb_str_to_lower β mb_strtolower,Β mb_tolowerΒ (IEEE)
- mb_str_to_upper β mb_strtoupper,Β mb_toupperΒ (IEEE)
- mb_str_width β mb_strwidth, (*28)
http://php.net/manual/en/book.iconv.php
IEEE names are prefixed by "iconv_"
- iconv_str_len β iconv_strlen (IEEE)
- iconv_str_pos β iconv_strpos
- iconv_str_rpos β iconv_strrpos, (*29)
http://php.net/manual/en/book.intl.php
IEEE names are prefixed by "grapheme_"
- grapheme_str_ipos β grapheme_stripos
- grapheme_str_istr β grapheme_stristr
- grapheme_str_len β grapheme_strlen (IEEE)
- grapheme_str_pos β grapheme_strpos
- grapheme_str_ripos β grapheme_strripos
- grapheme_str_rpos β grapheme_strrpos
- grapheme_str_str β grapheme_strstr (IEEE), (*30)
http://php.net/manual/en/ref.array.php
- array_sort β sort (Sort values)
- array_sort_reverseΒ β rsort (Reverse sort values)
- array_usortΒ β usort (User sort values)
- array_sort_assocΒ β asort (Keep key and sort)
- array_sort_assoc_reverseΒ β arsort (Keep key and reverse sort)
- array_sort_uassocΒ β uasort (Keep key and user sort)
- array_sort_keyΒ β ksort (Sort keys)
- array_sort_key_reverseΒ β krsort (Reverse sort keys)
- array_sort_ukeyΒ β uksort (User key sort)
- array_sort_naturalΒ β natsort (Natural sort)
- array_sort_natural_caseΒ β natcasesort (Natural sort without case)
- array_inΒ β in_array
- array_range β range (Create array of range)
- array_shuffle β shuffle (Randomize values)
- array_inΒ β bool in_array ( mixed $needle , array $haystack [, bool $strict ] )
- array_findΒ β mixed array_search ( mixed $needle , array $haystack [, bool $strict ]
- array_key_findΒ β bool array_key_exists ( mixed $key , array $array ), (*31)
http://php.net/manual/en/ref.filesystem.php
- link_info β linkinfo
- link_statΒ β lstat (IEEE)
- link_chownΒ β lchown (IEEE)
- link_chgrpΒ β lchgrp (IEEE)
- link_readΒ β readlink (IEEE)
- link_symbolicΒ β symlink (IEEE)
- path_base_nameΒ β basename
- path_info β pathinfo
- file_read β readfile (This could be file_read() or file_passthru(). If rename fopen()/etc with "file_" prefix, file_read() may conflict with fread() file_passthru() may conflict with fpassthru().)
- pipe_closeΒ β pclose (IEEE)
- pipe_openΒ β popen (IEEE)
- file_atime β fileatime
- file_ctime β filectime
- file_group β filegroup
- file_inode β fileinode
- file_mtime β filemtime
- file_owner β fileowner
- file_perms β fileperms
- file_size β filesize
- file_type β filetype
- file_name_matchΒ β fnmatch (IEEE)
- file_temp_nameΒ β tempnam (IEEE)
- file_copy β copy (IEEE)
- file_stat β stat (IEEE)
- file_stat_clear_cacheΒ β clearstatcache
- file_move_uploadedΒ β move_upload_file
- file_deleteΒ β unlink (There is dummy "delete()" function entry for unlink(). Unlink is a directory operation in fact, but made it as file_delete(). There will be dir_delete())
- file_rename β rename, (*32)
f*() : Examples are fopen(), fread(). These functions are for file(stream) resource. "f" prefix functions are kept, there should be "ftemp(tmpfile)","frewind(rewind)" because these operates with file(stream) resource.
- fget_csv β fgetcsv (IEEE)
- fput_csv β fputcsv
- frewindΒ β rewind (This one is exception that does not have "f" prefix, but operates with file handle)
- ftempΒ β tmpfile (This one is exception that does not have "f" prefix, but returns file handle) (IEEE), (*33)
Other Standard Functions
http://php.net/manual/en/book.misc.php
- time_sleep β sleep (IEEE)
- time_nano_sleep β time_nanosleep,Β nanosleepΒ (IEEE)
- time_micro_sleepΒ β usleep (IEEE)
- time_unique_id β uniqid (uniqid() is microtime() based)
- sys_get_load_avg β sys_getloadavg
- php_strip_white_space β php_strip_whitespace, (*34)
http://php.net/manual/en/book.url.php
- url_decode β urldecode
- url_encode β urlencode
- url_raw_decode β rawurldecode
- url_raw_encode β rawurlencode
- url_parseΒ β parse_url
- url_build_queryΒ β http_build_query (Make itΒ URLΒ function)
- url_meta_tagsΒ β get_meta_tags (Get meta tags fromΒ URL/file)
- url_headersΒ β get_headers (Get headers fromΒ URL), (*35)
http://php.net/manual/en/ref.info.php
- php_credits β phpcredits
- php_info β phpinfo
- php_version β phpversion
- get_opt β getopt
- get_env β getenv (This could be "env_get") (IEEE)
- put_env β putenv (This could be "env_set") (IEEE)
- Following get_() may be prefixed by "php_" rather than "get_".
- get_last_mod β getlastmod (ReturnΒ mainΒ script timestamp.)
- get_my_gid β getmygid ("my_" prefix used because they return info aboutΒ currentΒ script.)
- get_my_inode β getmyinode
- get_my_pid β getmypid
- get_my_uid β getmyuid
- get_rusage β getrusage, (*36)
http://php.net/manual/en/book.var.php
- bool_val β boolval
- double_val β doubleval
- float_val β floatval
- int_val β intval
- str_val β strval
- type_getΒ β gettype
- type_setΒ β settype
- type_resourceΒ β get_resource_type (Get resource type), (*37)
http://php.net/manual/en/book.var.php
- php_defined_vars β get_defined_vars, (*38)
http://php.net/manual/en/ref.classobj.phpΒ - Most of Class/interface/trait related functions are prefixed by "class_"/"interface_"/"trait_".
- class_calledΒ β get_called_class (Get late static binding class name. There are class_exists()/class_alias())
- class_methods β get_class_methods
- class_vars β get_class_vars (Get class property)
- class_getΒ β get_class (Get class name of an object)
- class_parentΒ β get_parent_class
- class_object_vars β get_object_vars (Get instance property)
- class_declaredΒ β get_declared_classes
- interface_declaredΒ β get_declared_interfaces (There is interface_exists())
- trait_declaredΒ β get_declared_traits (There is trait_exists()), (*39)
http://php.net/manual/en/book.info.phpΒ - PHP related function are prefixed by "php_".
- php_extension_loaded β extension_loaded
- php_extension_loaded_allΒ β get_loaded_extensions (Like ini_get_all())
- php_extension_functionsΒ β get_extension_funcs
- php_dl β dl
- php_cfg_var β get_cfg_var (Get value from configuration(INI) file including non-INI value)
- php_current_user β get_current_user (Owner of current PHP script file)
- php_defined_constants β get_defined_constants (There isΒ get_defined_vars())
- php_include_path_getΒ β get_include_path (Like ini_get/set/restore(). ini_set/get/restore() can do the same. Deprecate all them? or only have php_include_path() does both get/set?)
- php_include_path_setΒ β set_include_path
- php_include_path_restoreΒ β restore_include_path
- php_included_files β get_included_files
- php_required_files β get_required_files
- php_time_limitΒ β set_time_limit ("_set" may be omitted. It changes "max_execution_time" INI. ini_set() can do the same. Deprecate?), (*40)