0

I am reading about "Extracting fields", but I was not able to find any information on what a "field" is on the Net.

https://www.jetbrains.com/help/phpstorm/extract-field.html

What could be a definition of a PhpStorm "field", so I can understand its meaning?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
now_m
  • 109
  • 8
  • Extract Field refactoring declares a new field and initializes it with **the selected expression**. That's what that page says – apokryfos Sep 25 '17 at 07:45
  • Yes, but what a "field" is? – now_m Sep 25 '17 at 07:46
  • Whatever you've selected.In the example the string `param_query` was selected and was therefore extracted as a field – apokryfos Sep 25 '17 at 07:46
  • Ok. So this could be "a" or 'echo "Hello World!";' or like 100 lines of code? It would be all a "field"? And this is how this "storage container" or functionality is called in the phpStorm? – now_m Sep 25 '17 at 07:47
  • If you try it with `echo "Hello world";` it will inform you it can't because that's not a correct expression.(So I guess the question you should be asking is what's an expression in PHP). With `'a'` it will work and make a new string property with value `a` – apokryfos Sep 25 '17 at 07:50
  • By the way an expression is whatever can be evaluated to produce a value. – apokryfos Sep 25 '17 at 07:51
  • Thanks for the info! I was not able to find it on the Net. – now_m Sep 25 '17 at 07:53

1 Answers1

1

A "Field" is a variable of a class. It can be a static or belong to an instance of that class. Take a look at this post, it contains a discussion on the same topic.

Yury Fedorov
  • 14,508
  • 6
  • 50
  • 66