mirror of
https://github.com/php/php-src.git
synced 2026-04-27 01:48:26 +02:00
03f3b8479b
This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
69 lines
1.9 KiB
Plaintext
69 lines
1.9 KiB
Plaintext
Title: Loose type requirements for functions
|
|
Version: $Id$
|
|
Status: draft
|
|
Maintainer: Brian Moon <brianm@dealnews.com>
|
|
Created: 2001-09-17
|
|
Modified: 2001-09-17
|
|
|
|
|
|
1. Background/Need
|
|
==================
|
|
|
|
Many internal functions of PHP will reject parameters because of their
|
|
type (the array and variable function come to mind). For userland
|
|
this is not an easy task as there is no uniform way to do it. An
|
|
addition to the engine for requiring loose types would allow
|
|
developers to know that the data passed to their functions are of the
|
|
correct type and reduce the need for duplicating the same code in
|
|
every function to check for the type of data.
|
|
|
|
|
|
2. Overview
|
|
===========
|
|
|
|
Loose typing mostly means evaluating the contents of the variable and
|
|
not the type of the variable itself. The requirements for this would
|
|
and should work much like several of the is_* functions do now.
|
|
|
|
The typing of parameters would be optional and those not typed would
|
|
simply continue to be treated as they are now.
|
|
|
|
3. Functionality
|
|
================
|
|
|
|
3.1. Allowed Types
|
|
==================
|
|
|
|
Only loose types should be needed to ensure the data is usable by the
|
|
function. Duplicating the functionallity of is_scalar, is_resource,
|
|
is_array and is_object should give developers all the information they
|
|
need to use a variable correctly.
|
|
|
|
3.2. Syntax
|
|
===========
|
|
|
|
The current function syntax should be expanded to allow typing of
|
|
variables inline in a C style.
|
|
|
|
function foo ($var){
|
|
}
|
|
|
|
could be changed to require an array such as:
|
|
|
|
function foo (array $var){
|
|
}
|
|
|
|
3.3. Errors
|
|
===========
|
|
|
|
Mis-matches in type should be reported as fatal errors and should halt
|
|
the execution of a script as that function cannot be run and code
|
|
following could not reliably run.
|
|
|
|
|
|
4. Compatibility Notes
|
|
======================
|
|
|
|
Old code that does not take advantage of this will run without
|
|
modifications.
|