├── .github └── FUNDING.yml ├── typo3scan ├── typo3scan.phar ├── .gitignore ├── Documentation └── Screenshots │ ├── Html.png │ ├── Junit.png │ └── Screenshot.png ├── composer.json ├── LICENSE └── Readme.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: michielroos 2 | -------------------------------------------------------------------------------- /typo3scan: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mschwemer/typo3scan/HEAD/typo3scan -------------------------------------------------------------------------------- /typo3scan.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mschwemer/typo3scan/HEAD/typo3scan.phar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /test.php 2 | /la.php 3 | /bin/php-parse 4 | /bin/phpunit 5 | /vendor/ 6 | /.idea 7 | -------------------------------------------------------------------------------- /Documentation/Screenshots/Html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mschwemer/typo3scan/HEAD/Documentation/Screenshots/Html.png -------------------------------------------------------------------------------- /Documentation/Screenshots/Junit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mschwemer/typo3scan/HEAD/Documentation/Screenshots/Junit.png -------------------------------------------------------------------------------- /Documentation/Screenshots/Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mschwemer/typo3scan/HEAD/Documentation/Screenshots/Screenshot.png -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "michielroos/typo3scan", 3 | "description": "TYPO3 scanner", 4 | "type": "project", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Michiel Roos", 9 | "email": "michiel@michielroos.com" 10 | } 11 | ], 12 | "require": { 13 | "php": "^7.0 || ^8.0" 14 | }, 15 | "bin": [ 16 | "typo3scan.phar", 17 | "typo3scan" 18 | ], 19 | "extra": { 20 | "branch-alias": { 21 | "dev-master": "1.7.6-dev" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Michiel Roos 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # TYPO3 scanner 2 | Scans code for usage of deprecated and or changed code. 3 | 4 | ## What about actually FIXING the broken code automatically? 5 | TYPO3scan only _reports_ on code that needs to be fixed when migrating to a higher version of TYPO3. If you want a tool that **automatically fixes the code for you** take a look at the [TYPO3 Rector project](https://github.com/sabbelasichon/typo3-rector). 6 | 7 | ## What does it do? 8 | [![demo](https://asciinema.org/a/201851.png)](https://asciinema.org/a/201851?autoplay=1) 9 | 10 | TYPO3 publishes [breaking changes and deprecations since version 7](https://docs.typo3.org/typo3cms/extensions/core/stable/Index.html). 11 | 12 | This tool scans a folder for any code that is broken or deprecated. It's a wrapper around the [TYPO3 scanner library](https://github.com/ohader/scanner) that has been extracted from the TYPO3 v9 core. You can scan for deprecations and breaking changes for v7 and up. 13 | 14 | ## Is TYPO3 scan helping you to migrate your TYPO3 site more smoothly? 15 | Then please consider a sponsorship so I can make this tool even more awesome! 16 | - Become a patron on [Patreon](https://www.patreon.com/michielroos) 17 | - Make a donation via [PayPal](https://paypal.me/MichielRoos) 18 | 19 | Thank you! ♥ 20 | 21 | ## Requirements 22 | The scanner requires **PHP 7.0** or higher to run. Why? *Because this tool was written in 2018!* Still running that old site on PHP 5.6? Move your extensions over to a system with PHP 7.0+ to scan them. 23 | 24 | If there is enough demand I can downgrade components of the scanner so it can also run on PHP 5.6. This would also mean that the TYPO3 scanner library will need to be adjusted. It is taken from the TYPO3 9 core which requires PHP 7.2 at the time of writing. This sounds like quite a hassle to me, so if you want to run the LTS version of TYPO3 . . . ugrading your PHP version is the preferred practice. 25 | 26 | ## Installation 27 | Install into an existing composer project: 28 | ```bash 29 | composer require "michielroos/typo3scan" 30 | ``` 31 | 32 | ## Usage 33 | ### Scan a path 34 | Specify a path to scan. 35 | ```bash 36 | php ./typo3scan.phar scan ~/tmp/source 37 | ``` 38 | 39 | ### Scan for changes in certain TYPO3 version 40 | By default the scanner scans for breaking changes and deprecations in the most recent version of TYPO3. At the time of writing, this is version `10`. 41 | - long option: `--target` 42 | - short option: `-t` 43 | - values: `7`, `8`, `9`, `10`, `11`, `12` and `13` 44 | - default: `13` 45 | ```bash 46 | php ./typo3scan.phar scan --target 8 ~/tmp/source 47 | ``` 48 | 49 | ### Show only certain types of changes 50 | You can filter out specific change types (breaking, deprecation, feature, important) 51 | - long option: `--only` 52 | - short option: `-o` 53 | - values: `breaking`, `deprecation`, `feature`, `important` 54 | - default: `breaking,deprecation,feature,important` 55 | ```bash 56 | php ./typo3scan.phar scan --only breaking ~/tmp/source 57 | 58 | php ./typo3scan.phar scan --only breaking,deprecation ~/tmp/source 59 | ``` 60 | 61 | ### Show only certain indicator types (strong / weak) 62 | You can filter out specific indicator types (strong, weak) 63 | - long option: `--indicators` 64 | - short option: `-i` 65 | - values: `strong`, `weak` 66 | - default: `strong,weak` 67 | ```bash 68 | php ./typo3scan.phar scan --indicators weak ~/tmp/source 69 | 70 | php ./typo3scan.phar scan --indicators strong ~/tmp/source 71 | ``` 72 | 73 | ### Change output format 74 | You can specify a different output format. 75 | - long option: `--format` 76 | - short option: `-f` 77 | - values: `html`, `junit`, `markdown`, `plain` 78 | - default: `plain` 79 | ```bash 80 | php ./typo3scan.phar scan --format markdown ~/tmp/source 81 | ``` 82 | 83 | ### Specify report filename 84 | Instead of piping the output to a file, typo3scanner can write directly to a report file 85 | - long option: `--reportFile` 86 | - short option: `-r` 87 | ```bash 88 | php ./typo3scan.phar scan -r ~/tmp/report.txt ~/tmp/source 89 | ``` 90 | 91 | ### Specify custom template folder 92 | You can output in ANY format of your choosing by specifying a custom templatePath. 93 | - long option: `--templatePath` 94 | 95 | The scanner looks for a file with the name `Format.twig`. So if you create a HTML template and store that in `~/path/to/templates/Html.twig`, then you can generate a HTML report with the following command: 96 | ```bash 97 | php ./typo3scan.phar scan --format html --templatePath ~/path/to/templates ~/tmp/source 98 | ``` 99 | If you want to output the report as Restructured Text, you would create a `Rst.twig` template and generate rest using: 100 | ```bash 101 | php ./typo3scan.phar scan --format rst --templatePath ~/path/to/templates ~/tmp/source 102 | ``` 103 | 104 | ### Capture output in a file 105 | You can redirect the output to a file 106 | ```bash 107 | php ./typo3scan.phar scan --format markdown ~/tmp/source > source.md 108 | ``` 109 | 110 | ### Loop over a list of extensions 111 | If you have a list of extension keys you want to scan, you can do something like: 112 | ```bash 113 | for e in `cat ~/extensions.txt`; 114 | do 115 | php ./typo3scan.phar scan --format markdown ~/tmp/ext/$e > ~/tmp/reports/$e.md; 116 | done 117 | ``` 118 | 119 | ### Run the TYPO3scan tool from within Gitlab CI 120 | 121 | Check multiple extensions in the folder `web/typo3conf/ext/` adjust that path if needed. 122 | 123 | The result is an artifact which contains a `Build/Report/Deprecations` where you have a file per extension and TYPO3 Version 7, 8, 9 and 10. 124 | 125 | This way you can easily review each extension. 126 | 127 | With the planned junit ouput this can be nicely integrated into the gitlab merge request widget as well. 128 | 129 | ``` 130 | checkDeprecations: 131 | image: docker.kay-strobach.de/docker/php:7.1 132 | stage: test 133 | variables: 134 | SCANNER_RELEASE: "https://github.com/Tuurlijk/typo3scan/releases/download/1.3.0/typo3scan.phar" 135 | script: 136 | - curl -L $SCANNER_RELEASE --output typo3scan.phar 137 | - php ./typo3scan.phar 138 | - mkdir -p Build/Report/Deprecations 139 | - for d in web/typo3conf/ext/*/ ; do (php ./typo3scan.phar scan --target 7 --format markdown $d > Build/Report/Deprecations/v7-$(basename $d).md); done 140 | - for d in web/typo3conf/ext/*/ ; do (php ./typo3scan.phar scan --target 8 --format markdown $d > Build/Report/Deprecations/v8-$(basename $d).md); done 141 | - for d in web/typo3conf/ext/*/ ; do (php ./typo3scan.phar scan --target 9 --format markdown $d > Build/Report/Deprecations/v9-$(basename $d).md); done 142 | - for d in web/typo3conf/ext/*/ ; do (php ./typo3scan.phar scan --target 10 --format markdown $d > Build/Report/Deprecations/v10-$(basename $d).md); done 143 | artifacts: 144 | when: on_success 145 | expire_in: 7 days 146 | paths: 147 | - Build 148 | ``` 149 | 150 | ## Example output 151 | You can find example templates in the [Resources/Private/Templates](./src/Resources/Private/Templates) folder. 152 | ### Plain 153 | A part of the plain output for: 154 | ```bash 155 | typo3scan.phar scan ~/tmp/source/powermail 156 | ``` 157 | Looks like this: 158 | ``` 159 | powermail 160 | 161 | Found 26 matches in 1.09s when checking for changes and deprecations in TYPO3 7 162 | 163 | strong weak DEPRECATION BREAKING 164 | 29.41% 70.59% 5.88% 94.12% 165 | 166 | Classes/Finisher/SendParametersFinisher.php 167 | Call to method "isEnabled()" (weak) 168 | 60 if ($this->isEnabled()) { 169 | Deprecation: #37171 - Deprecate t3editor->isEnabled() 170 | https://docs.typo3.org/typo3cms/extensions/core/Changelog/7.3/Deprecation-67171-T3editorIsEnabled.html 171 | 172 | Configuration/TCA/tx_powermail_domain_model_answer.php 173 | Usage of array key "dividers2tabs" (strong) 174 | 14 'dividers2tabs' => true, 175 | Breaking: #62833 - Removed dividers2tabs functionality 176 | https://docs.typo3.org/typo3cms/extensions/core/Changelog/7.0/Breaking-62833-Dividers2Tabs.html 177 | 178 | Usage of array key "canNotCollapse" (weak) 179 | 240 'canNotCollapse' => 1 180 | Breaking: #67753 - Drop "Show secondary options" 181 | https://docs.typo3.org/typo3cms/extensions/core/Changelog/7.4/Breaking-67753-DropSecondaryOptions.html 182 | 183 | Usage of array key "_PADDING" (weak) 184 | 206 '_PADDING' => 2, 185 | Breaking: #63846 - FormEngine refactoring 186 | https://docs.typo3.org/typo3cms/extensions/core/Changelog/7.3/Breaking-63846-FormEngineRefactoring.html 187 | 188 | ext_localconf.php 189 | Access to array key "formevals" (weak) 190 | 71 $TYPO3_CONF_VARS['SC_OPTIONS']['tce']['formevals']['\In2code\Powermail\Tca\EvaluateEmail'] = 191 | Breaking: #67749 - Force class auto loading for various hooks 192 | https://docs.typo3.org/typo3cms/extensions/core/Changelog/7.4/Breaking-67749-ForceAutoloadingForVariousHooks.html 193 | ``` 194 | ### HTML 195 | A part of the html output for: 196 | ```bash 197 | typo3scan.phar scan ~/tmp/source/coreapi -f html -t 7 198 | ``` 199 | Looks like this: 200 | 201 | ![](./Documentation/Screenshots/Html.png) 202 | ### Junit 203 | A part of the junit output for: 204 | ```bash 205 | typo3scan.phar scan ~/tmp/source/coreapi -f junit -t 7 206 | ``` 207 | Looks like this: 208 | 209 | ![](./Documentation/Screenshots/Junit.png) 210 | 211 | ## Contributing 212 | If you want to help improve this tool to reduce the amount of false positives, improve matchers, add new matchers etc., your contributions are very welcome! 213 | 214 | You can contribute here: [TYPO3scan src repository](https://github.com/Tuurlijk/typo3scan-src) 215 | 216 | ## Sponsors 217 | This project was generously sponsored by [Stichting Praktijkleren](https://www.stichtingpraktijkleren.nl/). 218 | --------------------------------------------------------------------------------