Child pages
  • Results online survey Type Safety in PHP
Skip to end of metadata
Go to start of metadata

Table of Contents

Introduction

An online survey was conducted from mid December 2012 to the end of February 2013 with the topic "Type Safety in PHP" were in total 460 person from 24 different countries participated.
The following figures and numbers show intentionally just the results without any interpretation. This is left to the reader. An interpretation of some questions can be found in the Bachelor Thesis - Type-Safe PHP: A compile time approach.

The survey was conducted in German and in English. The page in German can be found here: Resultate der Online Umfrage Typensicherheit in PHP

Grouping

 Click here to expand...

The participants have been divided into 4 groups depending on their experience and other criteria. The groups are explained in the following sub-chapters

Group 1 - Chosen experts

Member of this group have been chosen by the author and consists of the following members:

  • PHP core developers
  • Heads of Zend Technologies
  • Heads of Dupral
  • Heads of Wordpress
  • Heads of Joomla
  • Heads of Typo3
  • Heads of Symfony2
  • Heads of Doctrine
  • Authors of leading php tools
    • phpunit
    • phpDocumentor
    • DocBlox
    • PHP_CodeSniffer
    • phpmd
    • phpdepend

Group 2 - Long term users

Members of this group are

  • Participants who have 7 years or more of experience with PHP (experience >= 7)
  • Participants who have less than 7 years of experience with PHP, but the summed experience with PHP and the experience with a type safe programming language (such as C# or Java) is 7 years or more. However, the participant needs at least 4 years of experience with PHP. (experience PHP + experience type safe programming language >= 7 && experience PHP >= 4)

Furthermore the following requirements were defined for this group:

  • The participant is not a member of Group1
  • The participant has worked at least 2 years as PHP developer or as a developer using a type-safe programming language
  • The participant has not answered a question with 'I do not know'.
  • The participant is familiar with design patterns (Q32), base design principles (Q33), unit tests (Q34) and continuous integration (Q35)

If one has the necessary experience but does not fulfil the defined requirements then he/she will either be part of Group 3 or 4

Group 3 - normal users

Members of this group are

  • Participants who have 4 years or more of experience with PHP (experience >= 4)
  • Participants who have less than 4 years of experience with PHP, but the summed experience with PHP and the experience with a type safe programming language  (such as C# or Java) is 4 years or more. However, the participant needs at least 2 years of experience with PHP. (experience PHP + experience type safe programming language >= 4 && experience PHP >= 2)

Furthermore the following requirements were defined for this group:

  • The participant is not a member of Group 1 or 2
  • The participant has to answer the question 'Do you think type safety in PHP should be improved?' (Q1) either with 'yes' or 'no' (not with 'I do not know').

Group 4 - beginners

All participants who are not member of Group 1, 2, or 3 are member of this group.

Flow

The participants were displayed questions depending on the answers given so far. The fully detailed flow of the survey can be found in the Bachelor Thesis - Type-Safe PHP: A compile time approach (download the DVD goto /docs/Survey.pdf – chapter Flow Questionnaire)

Results

Q1 Do you think type safety in PHP should be improved?

 

 yes noI do not knowtotal
chosen experts107421
long term users3928067
normal users5540095
beginners1515571277
 total25513075460

See also Q1 + Q11.

Interim Information 1

Please be aware, that if not mentioned otherwise, presented examples are unrealisable with the current PHP version (PHP 5.4). The examples would become realisable if one of the improvements would be implemented in a newer PHP version.

Changes are denoted in red.

Q2 Should the following improvement towards type safety be made?

Scalar types such as int or string can be used as parameter type. For instance

public function setName(string name){

    //...
}

 yes noI do not knowtotal
chosen experts103114
long term users363039
normal users540155
beginners143259177
total2433111285

See also Q2 + Q13

Q3 Parameters - which improvement towards type safety should be made?

Possible answers in detail:

  1. A type for each parameter has to be defined in all functions/methods
  2. A type for each parameter has to be defined in public functions/methods
  3. I do not know

 

 allpublic & protectedpublicnoneI do not knowtotal
chosen experts301719
long term users142122023
normal users243125228
beginners3635391155
total77889314115

See also Q3 + Q14

Q4 Return types of functions/methods - which improvement towards type safety should be made?

Two example of how return types could look like:

public function string getName(){
    //...
}
public function void getName(){
    //...
}

Possible answers in detail:

  1. public and protected functions/methods have to define a return type - private can optionally
  2. functions/methods can optionally define a return type
  3. none of the above mentioned
  4. I do not know

 

 

 allpublic & protectedpublicoptionalnoneI do not knowtotal
chosen experts30160212
long term users1121241039
normal users2220301055
beginners2633478794
total6275107109200

See also Q4 + Q15

Q5 Class and instance variables - which improvement towards type safety should be made?

An example of how a type for an instance variable could be defined:

class Person
{
    private string $name;
}

 

Possible answers in detail:

  1. A type has to be defined for all class and instance variable

  2. A type has to be defined for public and protected class and instance variables - (private optionally)

  3. A type has to be defined for public class and instance variables - (private and protected optionally)

  4. A type can optionally be defined for class and instance variables

  5. none of the above mentioned

  6. I do not know

 

 

 allpublic & protectedpublicoptionalnoneI do not knowtotal
chosen experts30151212
long term users1210260039
normal users1920322055
beginners2612507894
total60431131010200
See also Q5 + Q16

Q6 Local variables - which improvement towards type safety should be made?

An example of how a type for a local variable could be defined:

public function doSomething(){
    int $counter=0;
    while(...){
        ++$counter;
    }
}

Possible answers in detail:

  1. A type for local variables can optionally be defined

  2. None of the above mentioned

 

 

 mustoptionalnoneI do not knowtotal
chosen experts263112
long term users7257039
normal users17343155
beginners215412794
total47119259200
See also Q6 + Q17

Q7 Templates, files which will be included respectively - which improvement towards type safety should be made?

As an example the following problem which would result in a fatal error during runtime

class Person
{
    public function getTitle(){...}
    public function getFirstname(){...}
    public function getSurname(){...}
}
class View
{
    public function renderGreeting(){
        $prson = $this->getPerson(); //forgot inadvertently the e
        include 'greeting.php';
    }
}

greeting.php:


echo '<div class="greeting">'.
$person->getTitle().' '. //$person does not exist -> fatal error
$person->getFirstname().' '.
$person->getSurname().'</div>';

 

The goal of the following improvements is to avoid such errors. A context for templates is introduces. Templates can define a context in which they can be used by defining the variables which have to exist in outer scope and...

Possible answers in detail:

  1. ...what type they must have.
    Take the example, greeting.php would define that there must exist a variable $person of type Person.
  2. ... optionally what type they must have.
    Take the example, greeting.php would define that there must exist a variable $person and optionally that $person must have the type Person.
  3. ... the type of the variable cannot be defined.
    Take the example, greeting.php would define that there must exist a variable $person.
  4. None of the above mentioned and no context

  5. I do not know

 

 

 mustoptionalcannotnoneI do not knowtotal
chosen experts1306010
long term users817113039
normal users7173151355
beginners8102222062
total244765633166
See also Q7 + Q18

Q8 Are there other improvements towards type safety which should be made?

Individual text answers are not shown here.

Q9 Do you think PHP should be type-safe - should support type safety completely?

 yes noI do not knowtotal
chosen experts312217
long term users2641067
normal users3355795
beginners286610104
total9017419283


See also Q9 + Q19

Interim Information 2

I want to introduce shortly my project with the title 'Type-Safe PHP: A compile time approach'.
This project adopts a static type safety paradigm (type safety during compile time) and introduces Type-Safe PHP (TSPHP) on a next higher level than PHP. TSPHP will be a mild extension of PHP syntax and would be translated to PHP during compiling. This would enable that developers can work with a PHP which better/completely support type safety, without altering the current specification of PHP or the current interpreter.

Please consider in the following questions, that an improvement does not include any change to PHP but can be realised with TSPHP. PHP still remains without complete type safety and serves as a perfect language for beginners.

Q10 Would you have answered the previous questions differently if you had had the above information?

 yesnototal
chosen experts11314
long term users43842
normal users134962
beginners184058
total36140176

Notice

This notice was not part of the survey. The questions Q11- Q19  are a repetition of question Q1 - Q9 and have been shown to the user only if he/she had answered the question Q10 with yes and only if he/she has not already chosen the most severe answer (in direction of type safety - that means if the user has not chosen the first possibility).
The unions of those questions (for instance Q1 + Q11) present how the users would have answered the questions if he/she had the Interim Information 2 straight at the beginning. It was taken that users who have chosen the most severe answer at first, would have chosen the most severe answer also the second time.

Q11 Do you think type safety in PHP should be improved through TSPHP?

 yes noI do not knowtotal
chosen experts1001
long term users4004
normal users111113
beginners81514
total242632

Q1 + Q11

Do you think type safety in PHP should be improved through TSPHP? See Q11 for more information.

 yes noI do not knowtotal
chosen experts107421
long term users4126067
normal users6133195
beginners1585069277
total27011674460

Q12 Why would you not improve type safety in PHP?

Individual text answers are not shown here.

Q13 Should the following improvement towards type safety be made?

Scalar types such as int or string can be used as parameter type. For instance

public function setName(string name){

    //...
}

 yes noI do not knowtotal
chosen experts1001
long term users4004
normal users120012
beginners90110
total260127

Q2 + Q13

Scalar types such as int or string can be used as parameter type. See Q13 for more information.

 yesnoI do not knowtotal
chosen experts103114
long term users383041
normal users610162
beginners147249180
total2563011297

Q14 Parameters - which improvement towards type safety should be made?

Possible answers in detail:

  1. A type for each parameter has to be defined in all functions/methods
  2. A type for each parameter has to be defined in public functions/methods
  3. I do not know

 allpublic & protectedpublicnoneI do not knowtotal
chosen experts100001
long term users101204
normal users7113012
beginners501118
total14136125

Q3 + Q14

Parameters - which improvement towards type safety should be made? See Q14 for more information.

 allpublic & protectedpublicnoneI do not knowtotal
chosen experts4016112
long term users142124041
normal users314124262
beginners4136371097
total90999113212

Q15 Return types of functions/methods - which improvement towards type safety should be made?

Two example of how return types could look like:

public function string getName(){
    //...
}
public function void getName(){
    //...
}

Possible answers in detail:

  1. public and protected functions/methods have to define a return type - private can optionally
  2. functions/methods can optionally define a return type
  3. none of the above mentioned
  4. I do not know

 allpublic & protectedpublicoptionalnoneI do not knowtotal
chosen experts1000001
long term users1012004
normal users60150012
beginners3006009
total1102130026

Q4 + Q15

Return types of functions/methods - which improvement towards type safety should be made? See Q15 for more information.

 allpublic & protectedpublicoptionalnoneI do not knowtotal
chosen experts40160112
long term users1121261041
normal users2821301062
beginners2933478797
total7276109108212

Q16 Class and instance variables - which improvement towards type safety should be made?

An example of how a type for an instance variable could be defined:

class Person
{
    private string $name;
}

Possible answers in detail:

  1. A type has to be defined for all class and instance variable

  2. A type has to be defined for public and protected class and instance variables - (private optionally)

  3. A type has to be defined for public class and instance variables - (private and protected optionally)

  4. A type can optionally be defined for class and instance variables

  5. none of the above mentioned

  6. I do not know

 allpublic & protectedpublicoptionalnoneI do not knowtotal
chosen experts1000001
long term users2002004
normal users51240012
beginners4005009
total1212110026

Q5 + Q16

Class and instance variables - which improvement towards type safety should be made? See Q16 for more information.

 allpublic & protectedpublicoptionalnoneI do not knowtotal
chosen experts40151112
long term users1210280041
normal users2432312062
beginners3012497897
total7055113109212

Q17 Local variables - which improvement towards type safety should be made?

An example of how a type for a local variable could be defined:

public function doSomething(){
    int $counter=0;
    while(...){
        ++$counter;
    }
}

Possible answers in detail:

  1. A type for local variables can optionally be defined

  2. None of the above mentioned

 

 mustoptionalnoneI do not knowtotal
chosen experts01001
long term users13004
normal users390012
beginners35109
total7181026

Q6 + Q17

Local variables - which improvement towards type safety should be made? See Q17 for more information.

 mustoptionalnoneI do not knowtotal
chosen experts272112
long term users7286041
normal users20393062
beginners245313797
total53127248212

Q18 Templates, files which will be included respectively - which improvement towards type safety should be made?

As an example the following problem which would result in a fatal error during runtime

class Person
{
    public function getTitle(){...}
    public function getFirstname(){...}
    public function getSurname(){...}
}
class View
{
    public function renderGreeting(){
        $prson = $this->getPerson(); //forgot inadvertently the e
        include 'greeting.php';
    }
}

greeting.php:


echo '<div class="greeting">'.
$person->getTitle().' '. //$person does not exist -> fatal error
$person->getFirstname().' '.
$person->getSurname().'</div>';

 

The goal of the following improvements is to avoid such errors. A context for templates is introduces. Templates can define a context in which they can be used by defining the variables which have to exist in outer scope and...

Possible answers in detail:

  1. ...what type they must have.
    Take the example, greeting.php would define that there must exist a variable $person of type Person.
  2. ... optionally what type they must have.
    Take the example, greeting.php would define that there must exist a variable $person and optionally that $person must have the type Person.
  3. ... the type of the variable cannot be defined.
    Take the example, greeting.php would define that there must exist a variable $person.
  4. None of the above mentioned and no context

  5. I do not know

 mustoptionalcannotnoneI do not knowtotal
chosen experts100001
long term users030104
normal users2601312
beginners240118
total51303425

Q7 + Q18 

Templates, files which will be included respectively (include 'template.php';) - which improvement towards type safety should be made? See Q18 for more information.

 mustoptionalcannotnoneI do not knowtotal
chosen experts2206010
long term users818114041
normal users9213131662
beginners10112221964
total295265535177

Q19 Do you think TSPHP with complete support for type safety should be developed?

 

yes 

no

I do not know

total

chosen experts

0

0

1

1

long term users

3

1

0

4

normal users

10

0

3

13

beginners

4

1

3

8

total

17

2

7

26

Q9 + Q19

Do you think TSPHP with complete support for type safety should be developed? See Q19 for more information.

 yes noI do not knowtotal
chosen experts311317
long term users2938067
normal users4344895
beginners325913104
total10715224283

 

Q20 Why would you not introduce complete support for type safety in PHP?

Individual text answers are not shown here.

Q21 If you could wish - in which time should TSPHP be developed regardless of whether it is feasible or not?

 0 <= x <= 6 6 < x <= 1212 < x <= 2424 < xtotal
chosen experts00000
long term users482115
normal users11121125
beginners42118
total19224348

Q22 Which of the following concepts should be supported by PHP/TSPHP?

Enums

 yesnototal
chosen experts51015
long term users333467
normal users435295
beginners102232
total91118209

Generics

 yesnototal
chosen experts21315
long term users214667
normal users276895
beginners32932
total53156209

Operator Overloading

 yesnototal
chosen experts11415
long term users313667
normal users455095
beginners62632
total83126209

Properties as in C#

 yesnototal
chosen experts6915
long term users194867
normal users187795
beginners23032
total45164209

Object Initialiser as in C#

 yesnototal
chosen experts31215
long term users264167
normal users237295
beginners92332
total61148209

Collection Initialiser as in C#

 yesnototal
chosen experts11415
long term users155267
normal users108595
beginners62632
total32177209

Catching multiple Exceptions in the same block as in Java

 yesnototal
chosen experts6915
long term users402767
normal users573895
beginners181432
total12188209

Q23 Do you miss other concepts in PHP - TSPHP?

Individual text answers are not shown here.

Q24 Which IDE do you use mostly - would you define as your IDE?

IDENumber of Participants
PHPStorm48
Netbeans45
Eclipse34
VIM16
Sublime Text15
Zend Studio11
Notepad++7
emacs3
DreamWeaver3
Komodo2
Edit+2
notepad2
vi2
textmate2
geany2
bb edit1
Intellij IDEA1
coda1
Textpad1
Aptana studio1
Rapid PHP1
kate1
xemacs1
NuShpere PHPED1

Q25A How satisfied are you with the refactoring support for PHP within IDEs?

1 stays for 'not satisfied at all' and 10 for 'fully satisfied'

 12345678910I do not knowtotal
chosen experts1011111300615
long term users614334171991067
normal users315186612484195
beginners30012204151028
total13210614132438141457205

Q25B How satisfied are you with the code-completion-functionalities (CTRL+Space) within your IDE corresponding the recommended completions?

1 stays for 'not satisfied at all' and 10 for 'fully satisfied'

 12345678910I do not knowtotal
chosen experts0000113241315
long term users2233244161714067
normal users11547381812181895
beginners2002022273828
total538910101738403629205

Q25C How satisfied are you with the code-completion-functionalities (CTRL+Space) within your IDE corresponding the time it takes until the recommendations are displayed?

1 stays for 'not satisfied at all' and 10 for 'fully satisfied'

 12345678910I do not knowtotal
chosen experts0001212231315
long term users133455581518067
normal users12324451414222495
beginners3102022435628
total566911121428354633205

Q26 How many years of experience do you have in developing with PHP?

 0 <= x < 22 <= x < 44 <= x < 77 <= xtotal
chosen experts0011314
long term users00105767
normal users05256595
beginners5141424
total5640149200

See also Q26 + Q28

Q27 How many years have you worked - have you been employed as a PHP developer?

 0 <= x < 22 <= x < 44 <= x < 77 <= xtotal
chosen experts0021214
long term users38173967
normal users247293595
beginners639624
total33185792200

See also Q27 + Q29

Q28 How many years of experience do you have with type safe languages such as Java or C#?

 0 <= x < 22 <= x < 44 <= x < 77 <= xtotal
chosen experts234514
long term users515212667
normal users3120261895
beginners1282224
total50465351200

See also Q26 + Q28

Q29 How many years have you worked - employed - with type safe languages such as Java or C#?

 0 <= x < 22 <= x < 44 <= x < 77 <= xtotal
chosen experts632314
long term users2617131167
normal users641212795
beginners2021124
total116342822200

See also Q27 + Q29

Q26 + Q28

How many years of experience do you have

  • in developing with PHP +
  • with type safe languages such as Java or C#

 

 0 <= x < 44 <= x < 88 <= x < 1414 <= xtotal
chosen experts0041014
long term users00244367
normal users019433395
beginners6114324
total6208589200

Q27 + Q29

How many years have you worked

  • as a PHP developer +
  • with type safe languages such as Java or C#

 0 <= x < 44 <= x < 88 <= x < 1414 <= xtotal
chosen experts028414
long term users221291567
normal users2528281495
beginners896124
total35607134200

Q30 Are you currently employed as a PHP developer?

 yesnototal
chosen experts12214
long term users58967
normal users623395
beginners19524
total15149200

Q31 With which PHP version do you develop mainly?

 5.45.35.25.15.0An older version than 5.0total
chosen experts77000014
long term users2145010067
normal users2856920095
beginners714200124
total6312211301200

Q32 Are you familiar with design patterns?

Such as

  • Factory Method
  • Strategy
  • Decorator
  • Observer
  • etc.

 yes noI do not knowtotal
chosen experts140014
long term users670067
normal users8011293
beginners182424
total179136198

Q33 Are you familiar with the following principles?

  • Separation of concerns
  • Information hiding
  • Low coupling / high cohesion

 yes noI do not knowtotal
chosen experts140014
long term users670067
normal users65171193
beginners182424
total1641915198

Q34 Are you familiar with unit-tests (e.g. phpunit)?

 yes noI do not knowtotal
chosen experts140014
long term users670067
normal users7418193
beginners165324
total171234198

Q35 Are you familiar with continuous integration?

 yes noI do not knowtotal
chosen experts140014
long term users670067
normal users5630793
beginners155424
total1523511198

Q36 Are you using unit-tests during your development process?

 yes noI do not knowtotal
chosen experts140014
long term users589067
normal users4033174
beginners133016
total125451171

Q37 Are you using test-driven development as development process?

 yes noI do not knowtotal
chosen experts77014
long term users105015
normal users99220
beginners2002
total2821251

Q38 Are you practising continuous integration?

 yes noI do not knowtotal
chosen experts122014
long term users5017067
normal users2630056
beginners96015
total97550152

Q39 At which trigger point is TSPHP relevant to the PHP community?

Imagine you are the counsellor of the project TSPHP and you have to give advice on whether a further development of TSPHP is worth it or not.

You would examine the question "Do you think TSPHP with complete support for type safety should be developed?" (Q9 + Q19). What percentage of 'yes' answers out of 'yes' and 'no' answers would be necessary, that you rate TSPHP relevant to the PHP community and give the advice to proceed with the development? 

 

 0% <= x <= 10%10% < x <= 20%20% < x <= 30%30% < x <= 40%40% < x <= 50%50% < x <= 60%60% < x <= 70%70% < x <= 80%80% < x <= 90%90 % < xtotal
chosen experts222021050014
long term users3397810996367
normal users7913105811185793
beginners401442340224
total16142521192123361112198

Q43 What is your sex?

 femalemaletotal
chosen experts01313
long term users16162
normal users08686
beginners11819
total2178180

Q44 How old are you?

 0<= x < 1616 <= x <= 2121 < x < 3030 <= x < 4040<= x < 5050 <= xtotal
chosen experts00453012
long term users0127311161
normal users1437278279
beginners00762217
total157569145169

Q45 Where are you from?

 chosen expertslong term usersnormal usersbeginnerstotal
Australia13206
Austria01001
Brazil01014226
Bulgaria00101
Canada01113
Colombia00022
France10113
Germany31419440
Iran00101
Israel02103
Italy10012
Japan10001
Lithuania02002
Netherlands167115
Norway00011
Portugal01102
Russia01001
Slovakia01001
Spain00202
Sweden00202
Switzerland11114
Turkey04318
UK027211
USA31417539
total12638022177

Q46 What is the highest education degree you have earned?

Possible answers:

  • No Degree
  • SChool degree
  • Associate degree
  • College degree
  • Bachelors degree
  • Masters degree
  • Doctorate (PhD)
  • Other degree (was assigned to one of the degrees above which seemed to be the most similar one)

 noschoolassociatecollegeprofessionalbachelorsmastersdoctoratetotal
chosen experts0022144013
long term users24582309565
normal users61312122299386
beginners21251100021
total10182127673228185
  • No labels