-
Notifications
You must be signed in to change notification settings - Fork 2.7k
#160 Refactor folders: Element, Container, and Exception #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#160 Refactor folders: Element, Container, and Exception #187
Conversation
- Rename folder Section to Element - Rename folder Exceptions to Exception - Move Section, Header, Footer, Settings to Container folder - Move Element\Footer\PreserveText to Element\PreserveText
…ell` element class.
- Table: Ability to add footnote in table cell - Footnote: Ability to add image in footnote - ListItem: Ability to add list item in header/footer - CheckBox: Ability to add checkbox in header/footer - Link: Ability to add link in header/footer
@Progi1984 @gabrielbull @RomanSyroeshko I've finished refactoring based on #160 plan. Please review. This refactoring should be backward compatible, but since there are a lot of changes in the code structure, I suggest we launch this as a new minor version (0.10) instead of 0.9.2. Thanks |
Nice, I like that you started using the builder design pattern. |
Please, let me time until Monday. Lack of free time. :(
Good idea. I'm with you. |
@gabrielbull Thanks for the link. So that's the name for the method :) I'll learn more from the link that you gave. I hope this approach will reduce code duplication and simplify the process of adding more elements. @RomanSyroeshko Sure. No problem. I'll be adding more refactoring, especially for Media, Header, and Footer. But all changes will still be backward compatible. |
@ivanlanin Very good job. A very good refactoring which permits to work on a better base. |
@Progi1984 Thanks. Yes, PHP-CPD reports better result, but unfortunately, there are still some exact clones. My aim is to eliminate all duplicates. I'll continue pursuing that goal while maintaing backward compatibility. |
@ivanlanin Which clones are again there ? |
Here's from my latest branch: Found 6 exact clones with 508 duplicated lines in 9 files: D:\www\local\phpword\src\PhpWord\Element\CheckBox.php:73-138 D:\www\local\phpword\src\PhpWord\Container\Settings.php:372-567 D:\www\local\phpword\src\PhpWord\Container\Settings.php:428-589 D:\www\local\phpword\src\PhpWord\Writer\ODText\Content.php:51-72 D:\www\local\phpword\src\PhpWord\Writer\ODText\Content.php:122-154 D:\www\local\phpword\src\PhpWord\Writer\ODText.php:42-76 2.53% duplicated lines out of 20044 total lines of code. |
Hi, @ivanlanin, one question: why did you name the class as |
Because those classes (section, header, footer, textrun, footnote, and cell) share the same characteristic that they all can contain other elements (text, etc). Other options that I can offer are "stories" (from OOXML spec) and "destinations" (from RTF spec). OpenDocument spec doesn't give me any specific name. Other "containers" that we can create later are, e.g., endnote, comment, and textbox. |
According to ISO/IEC 29500-1 (known as "OOXML"):
P.S. |
Thanks for the link. My references were from ECMA and are indeed older than the ISO version. I agree that what I called I agree that different doc format will have different terminology. Since we are aiming to "bridge" those formats, we will have to define our own shared features and elaborate specific features for individual doc formats. So, this is what I think we should decide:
|
What do you mean?
AbstractElement
Not sure that I understant what the problem is. Could you please clarify? |
|
As for me, the last thing I want is to invent our own terminilogy and standards here. The more file formats we support, the harder the code will be. It will be a real pain to deal with it. Moreover, our users will have to learn and understand that new general standard instead of just working with lib. It will be a lot simplier to use modular structure where each module supports one file format. Sure, common things should be in common place. This aproach let us follow native standards for each file format and use the appropriate terminilogy. Why somebody have to dive into some new terminilogy and phylosophy when he just needs to write/read OOXML? It's a good way to lose the audience.
Sure.
Why not? |
Ok. Based on the discussion, this is what I'll do:
Is there anything else that we should consider? |
Who knows? Will let you know if something comes to my mind. :) |
I'm finished :) Kindly check for the last time since I want to move on to enhance the All changes should still be backward compatible, but I suggest we release this as 0.10.0. Thanks. |
Why such a hurry? Maybe we will wait for month or two before the next major release? |
I didn't mean we should release now :) I mean "when we release", we should release as 0.10.0 instead of 0.9.2. I close this pull now. Thanks. |
#160 Refactor folders: Element, Container, and Exception
@ivanlanin, couple questions.
/**
* Section
*/
class Section extends AbstractElement
{ I suggest killing them or replacing with something more meaninful. How do you think?
As for me, that means the two things.
Sure, class names in phpDoc annotations can be resolved using @gabrielbull, what's your opinion on p. 2? |
|
|
Ok. I agree with the rule that we only use unqualified names in docblocks for classes in the same namespace. |
Part of #160:
Section
toElement
Exceptions
toException
Element
folder structure (movePreserveText
,Cell
, andRow
up one level)Container
folder and moveSection
,Header
,Footer
,Settings
intoContainer
Container
abstract class, inherited bySection
,Header
,Footer
,Footnote
,TextRun
, andCell
createSection
,createHeader
,createFooter
,createFootnote
, andcreateTextRun
in favor of uniformadd...
methods.Element
abstract class