SlideShare a Scribd company logo
1 of 33
Download to read offline
FTUG
Ext:form


PHP Static Code Linting
15 11 2017
2
Agenda for today
‣ Ext:form
‣ Custom element
‣ Prototype
‣ Tipps & Tricks
‣ PHP Static Code Linting
3
Ext:form
(aka Form Framework)

Ext:form
4
Ext:form
Die Features:
• Form editor
• PHP API
• Konfiguration
• Form elemente
5
Ext:form
Die Features:
• Finishers
• Validators
• Miscellaneous
6
Ext:form
Nicht nur Formulare lassen sich somit
erstellen:
7
8
Custom element
Ext:form - Custom element
9
Ext:form - Custom element
10
Ext:form - Custom element
11
Ext:form - Custom element
12
Ext:form - Custom element
INPUT Nico
13
Ext:form - Custom element
INPUT Nico
14
Ext:form - Custom element
15
Konfiguration für Backend registrieren
Ext:form - Custom element
16
Konfiguration für Frontend registrieren
Ext:form - Custom element
17
Konfiguration für die Sprachdatei registrieren
Ext:form - Custom element
INPUT Nico
18
19
Prototype
Ext:form - Prototype
• Konfigurationen „leben“ in Prototypen
• “standard“ ist der default
• unterschiedliche Formular-Elemente pro Prototyp
• unterschiedliche vordefinierte Formular-Element

Konfigurationen / Validatoren / etc. pro Prototyp
20
Registrieren eines neuen Prototypes
inkl. „boilerplate“
Ext:form - Prototype
TYPO3:
CMS:
Form:
formManager:
selectablePrototypesConfiguration:
200:
identifier: newPrototypeName
label:'syzygy.formEditor.preset.Form.NewPrototypeName.label'
newFormTemplates:
100:
templatePath:'EXT:some_extension/Resources/Private/Backend/Templates/Form/FormEditor/Yaml/
NewForms/NewFormPreset.yaml'
label: 'syzygy.formEditor.preset.NewPrototypeName.label'
prototypes:
newPrototypeName:
__inheritances:
10: 'TYPO3.CMS.Form.prototypes.standard'
21
Prototype registireren
„boilerplate“
22
Tipps & Tricks
Prototype spezifische Templates,
Layouts, Partials
Ext:form - Tipps & Tricks
TYPO3:
CMS:
Form:
prototypes:
newPrototypeName:
formElementsDefinition:
Form:
renderingOptions:
templateRootPaths:
30: 'EXT:some_extension/Resources/Private/Templates/Form/NewPrototypeName/'
partialRootPaths:
40: 'EXT:some_extension/Resources/Private/Partials/Form/NewPrototypeName/'
layoutRootPaths:
40: ‚EXT:some_extension/Resources/Private/Layouts/Form/NewPrototypeName/'
23
Ext:form - Tipps & Tricks
24
Pro
• Sehr einfache Pflege von Formularen
• Formulare sind versionierbar im 

Projekt (z.B. Git)
• Formular-Definitionen „deploybar“
• Komplexe Anforderungen können

abgebildet werden (z.B. PHP-API, etc.)
Contra
• Formulare sind nicht versioniert

innerhalb TYPO3 (kein sys_history, 

kein workspace, etc.)
• Keine Sichtbarkeit bei Bearbeitung
• Keine Edit-Permissions pro Formular
25
PHP Static Code Linting
WHY?
Find Bugs In Your
Code Without
Writing Tests!
26
27
PHPStan
Static Code Linting mit
28
Current Checks
‣ Existence of classes and interfaces in
instanceof, catch, typehints, other language
constructs and even annotations. PHP does
not do this and just stays silent instead.
‣ Existence of variables while respecting
scopes of branches and loops.
‣ Existence and visibility of called methods
and functions.
‣ Existence and visibility of accessed
properties and constants.
‣ Correct types assigned to properties.
29
Current Checks
‣ Correct number and types of parameters
passed to constructors, methods and functions.
‣ Correct types returned from methods and
functions.
‣ Correct number of parameters passed to
sprintf/printf calls based on format strings.
‣ Useless casts like (string) 'foo'.
‣ Unused constructor parameters - they can
either be deleted or the author forgot to use
them in the class code.
‣ That only objects are passed to the clone
keyword.
• Use composer!!!!!1!!111!!!111
• $ composer require --dev phpstan/phpstan
TYPO3? Object Manager? Repository->findOneByX()?
• $ composer require --dev saschaegerer/phpstan-typo3
RUN
• $ vendor/bin/phpstan analyse -c phpstan.neon -l max
30
How to install
31
DEMO?!
Static Code Linting
Links
32
Links
Ext:from - custom form element
• https://gist.github.com/manuelselbach/dc63abd313694c594d480b163a5f3053
Static code linting
• https://github.com/phpstan/phpstan
• https://github.com/sascha-egerer/phpstan-typo3
33
Thank you

More Related Content

Similar to PHP Static Code Linting with PHPStan

IPC 2013 - High Performance PHP with HipHop
IPC 2013 - High Performance PHP with HipHopIPC 2013 - High Performance PHP with HipHop
IPC 2013 - High Performance PHP with HipHopSteve Kamerman
 
Python Linters at Scale.pdf
Python Linters at Scale.pdfPython Linters at Scale.pdf
Python Linters at Scale.pdfJimmy Lai
 
API Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonAPI Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonTEST Huddle
 
Php training100%placement-in-mumbai
Php training100%placement-in-mumbaiPhp training100%placement-in-mumbai
Php training100%placement-in-mumbaivibrantuser
 
Innovative php development
Innovative php developmentInnovative php development
Innovative php developmentTigran Azatyan
 
Asp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentationAsp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentationabhishek singh
 
Code analysis tools (for PHP)
Code analysis tools (for PHP)Code analysis tools (for PHP)
Code analysis tools (for PHP)Karlen Kishmiryan
 
Session 04 - Object Repository Contd.
Session 04 - Object Repository Contd.Session 04 - Object Repository Contd.
Session 04 - Object Repository Contd.rajaselv
 
Non-Blocking Strategies for FFI
 Non-Blocking Strategies for FFI Non-Blocking Strategies for FFI
Non-Blocking Strategies for FFIESUG
 
20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboardsDenis Ristic
 
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...44CON
 
Modern Static Code Analysis in PHP
Modern Static Code Analysis in PHPModern Static Code Analysis in PHP
Modern Static Code Analysis in PHPVladimir Reznichenko
 
PHP to Hack at Slack
PHP to Hack at SlackPHP to Hack at Slack
PHP to Hack at SlackScott Sandler
 
Listen and look at your PHP code
Listen and look at your PHP codeListen and look at your PHP code
Listen and look at your PHP codeGabriele Santini
 
Enforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code GenerationEnforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code GenerationTim Burks
 
9780538745840 ppt ch01 PHP
9780538745840 ppt ch01 PHP9780538745840 ppt ch01 PHP
9780538745840 ppt ch01 PHPTerry Yoast
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshopDamien Seguy
 
How to become a Rational Developer for IBM i Power User
How to become a Rational Developer for IBM i Power UserHow to become a Rational Developer for IBM i Power User
How to become a Rational Developer for IBM i Power UserStrongback Consulting
 

Similar to PHP Static Code Linting with PHPStan (20)

IPC 2013 - High Performance PHP with HipHop
IPC 2013 - High Performance PHP with HipHopIPC 2013 - High Performance PHP with HipHop
IPC 2013 - High Performance PHP with HipHop
 
Python Linters at Scale.pdf
Python Linters at Scale.pdfPython Linters at Scale.pdf
Python Linters at Scale.pdf
 
API Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonAPI Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj Rollison
 
Php training100%placement-in-mumbai
Php training100%placement-in-mumbaiPhp training100%placement-in-mumbai
Php training100%placement-in-mumbai
 
Innovative php development
Innovative php developmentInnovative php development
Innovative php development
 
Asp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentationAsp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentation
 
Code analysis tools (for PHP)
Code analysis tools (for PHP)Code analysis tools (for PHP)
Code analysis tools (for PHP)
 
Session 04 - Object Repository Contd.
Session 04 - Object Repository Contd.Session 04 - Object Repository Contd.
Session 04 - Object Repository Contd.
 
Non-Blocking Strategies for FFI
 Non-Blocking Strategies for FFI Non-Blocking Strategies for FFI
Non-Blocking Strategies for FFI
 
20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards
 
TYPO3 FormZ
TYPO3 FormZTYPO3 FormZ
TYPO3 FormZ
 
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
 
Modern Static Code Analysis in PHP
Modern Static Code Analysis in PHPModern Static Code Analysis in PHP
Modern Static Code Analysis in PHP
 
PHP to Hack at Slack
PHP to Hack at SlackPHP to Hack at Slack
PHP to Hack at Slack
 
Listen and look at your PHP code
Listen and look at your PHP codeListen and look at your PHP code
Listen and look at your PHP code
 
Enforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code GenerationEnforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code Generation
 
9780538745840 ppt ch01 PHP
9780538745840 ppt ch01 PHP9780538745840 ppt ch01 PHP
9780538745840 ppt ch01 PHP
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshop
 
How to become a Rational Developer for IBM i Power User
How to become a Rational Developer for IBM i Power UserHow to become a Rational Developer for IBM i Power User
How to become a Rational Developer for IBM i Power User
 
Php
PhpPhp
Php
 

Recently uploaded

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 

Recently uploaded (20)

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 

PHP Static Code Linting with PHPStan

  • 2. 2 Agenda for today ‣ Ext:form ‣ Custom element ‣ Prototype ‣ Tipps & Tricks ‣ PHP Static Code Linting
  • 5. Ext:form Die Features: • Form editor • PHP API • Konfiguration • Form elemente 5
  • 6. Ext:form Die Features: • Finishers • Validators • Miscellaneous 6
  • 7. Ext:form Nicht nur Formulare lassen sich somit erstellen: 7
  • 9. Ext:form - Custom element 9
  • 10. Ext:form - Custom element 10
  • 11. Ext:form - Custom element 11
  • 12. Ext:form - Custom element 12
  • 13. Ext:form - Custom element INPUT Nico 13
  • 14. Ext:form - Custom element INPUT Nico 14
  • 15. Ext:form - Custom element 15 Konfiguration für Backend registrieren
  • 16. Ext:form - Custom element 16 Konfiguration für Frontend registrieren
  • 17. Ext:form - Custom element 17 Konfiguration für die Sprachdatei registrieren
  • 18. Ext:form - Custom element INPUT Nico 18
  • 20. Ext:form - Prototype • Konfigurationen „leben“ in Prototypen • “standard“ ist der default • unterschiedliche Formular-Elemente pro Prototyp • unterschiedliche vordefinierte Formular-Element
 Konfigurationen / Validatoren / etc. pro Prototyp 20
  • 21. Registrieren eines neuen Prototypes inkl. „boilerplate“ Ext:form - Prototype TYPO3: CMS: Form: formManager: selectablePrototypesConfiguration: 200: identifier: newPrototypeName label:'syzygy.formEditor.preset.Form.NewPrototypeName.label' newFormTemplates: 100: templatePath:'EXT:some_extension/Resources/Private/Backend/Templates/Form/FormEditor/Yaml/ NewForms/NewFormPreset.yaml' label: 'syzygy.formEditor.preset.NewPrototypeName.label' prototypes: newPrototypeName: __inheritances: 10: 'TYPO3.CMS.Form.prototypes.standard' 21 Prototype registireren „boilerplate“
  • 23. Prototype spezifische Templates, Layouts, Partials Ext:form - Tipps & Tricks TYPO3: CMS: Form: prototypes: newPrototypeName: formElementsDefinition: Form: renderingOptions: templateRootPaths: 30: 'EXT:some_extension/Resources/Private/Templates/Form/NewPrototypeName/' partialRootPaths: 40: 'EXT:some_extension/Resources/Private/Partials/Form/NewPrototypeName/' layoutRootPaths: 40: ‚EXT:some_extension/Resources/Private/Layouts/Form/NewPrototypeName/' 23
  • 24. Ext:form - Tipps & Tricks 24 Pro • Sehr einfache Pflege von Formularen • Formulare sind versionierbar im 
 Projekt (z.B. Git) • Formular-Definitionen „deploybar“ • Komplexe Anforderungen können
 abgebildet werden (z.B. PHP-API, etc.) Contra • Formulare sind nicht versioniert
 innerhalb TYPO3 (kein sys_history, 
 kein workspace, etc.) • Keine Sichtbarkeit bei Bearbeitung • Keine Edit-Permissions pro Formular
  • 26. WHY? Find Bugs In Your Code Without Writing Tests! 26
  • 28. 28 Current Checks ‣ Existence of classes and interfaces in instanceof, catch, typehints, other language constructs and even annotations. PHP does not do this and just stays silent instead. ‣ Existence of variables while respecting scopes of branches and loops. ‣ Existence and visibility of called methods and functions. ‣ Existence and visibility of accessed properties and constants. ‣ Correct types assigned to properties.
  • 29. 29 Current Checks ‣ Correct number and types of parameters passed to constructors, methods and functions. ‣ Correct types returned from methods and functions. ‣ Correct number of parameters passed to sprintf/printf calls based on format strings. ‣ Useless casts like (string) 'foo'. ‣ Unused constructor parameters - they can either be deleted or the author forgot to use them in the class code. ‣ That only objects are passed to the clone keyword.
  • 30. • Use composer!!!!!1!!111!!!111 • $ composer require --dev phpstan/phpstan TYPO3? Object Manager? Repository->findOneByX()? • $ composer require --dev saschaegerer/phpstan-typo3 RUN • $ vendor/bin/phpstan analyse -c phpstan.neon -l max 30 How to install
  • 32. Links 32 Links Ext:from - custom form element • https://gist.github.com/manuelselbach/dc63abd313694c594d480b163a5f3053 Static code linting • https://github.com/phpstan/phpstan • https://github.com/sascha-egerer/phpstan-typo3