From 7790f19a740327d0588b92ce5c6ed9df0793a2ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Sun, 9 Apr 2017 14:19:35 +0200 Subject: [PATCH 001/100] FEATURE: Convert to php-codesniffer-standards composer package type --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 26d1954..cd6575f 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "siepmann/typo3_update", "description": "Auto migrate PHP Source of extensions to be compatible.", - "type": "project", + "type": "php-codesniffer-standards", "autoload-dev": { "psr-4": { "Typo3Update\\Tests\\": "tests/" @@ -18,7 +18,8 @@ "require": { "helmich/typo3-typoscript-parser": "1.1.*", "squizlabs/php_codesniffer": "2.8.*", - "symfony/yaml": "3.2.*" + "symfony/yaml": "3.2.*", + "higidi/composer-phpcodesniffer-standards-plugin": "*" }, "license": "GPL-2.0+", "authors": [ From 4ef69c91ac899676ed6cccf60da3553bdfbfa87c Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 11 Apr 2017 14:39:47 +0200 Subject: [PATCH 002/100] TASK: Update readme with project website * As github is no longer the home but a mirror, we will tell everyone. --- Readme.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Readme.rst b/Readme.rst index dcc9770..3ba4905 100644 --- a/Readme.rst +++ b/Readme.rst @@ -7,10 +7,16 @@ Our goal is to provide an automated migration for TYPO3 updates. This should include source code modifications like adjusting old legacy class names to new ones. +The official project home page can be found at https://git.higidi.com/Automated-TYPO3-Update/automated-typo3-update . +Please open new issues and merge requests there. You can login with your Github account. + +Github is just used as a mirror for the project. + Requirements ============ -- ``composer`` needs to be installed and inside your ``$PATH``. +- ``composer`` needs to be installed and inside your ``$PATH``. Otherwise run ``make + install-composer``. Installation ============ From abdc7f0f72dacc4616091ae183278a3b3cbef487 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 11 Apr 2017 15:49:01 +0200 Subject: [PATCH 003/100] TASK: Add sync to github via pipelines * To make github an auto mirror --- .gitlab-ci.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 70c0f43..32e099a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,8 +5,23 @@ before_script: - mkdir -p result stages: + - sync - test +sync:github: + stage: sync + before_script: + - apt-get -y update && apt-get -y upgrade + - apt-get -y install openssh-client rsync + # SSH deploy key + - eval $(ssh-agent -s) + - ssh-add <(echo "$SSH_PRIVATE_KEY") + - mkdir -p ~/.ssh + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' + script: + - git push github + + lint:coding-guideline: image: php:7.0-alpine stage: test From bef8c1a91380732b6223a92ad3790efeef18ce0b Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 11 Apr 2017 15:51:20 +0200 Subject: [PATCH 004/100] TASK: Install git instead of rsync * To make sync work via git --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 32e099a..6e26063 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,7 @@ sync:github: stage: sync before_script: - apt-get -y update && apt-get -y upgrade - - apt-get -y install openssh-client rsync + - apt-get -y install openssh-client git # SSH deploy key - eval $(ssh-agent -s) - ssh-add <(echo "$SSH_PRIVATE_KEY") From 813aa480104c0b2cfd522ef5c74a193038f4ae86 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 11 Apr 2017 15:54:18 +0200 Subject: [PATCH 005/100] TASK: Push to github project * Mirror current repository state --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6e26063..fef7f7e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,8 +19,9 @@ sync:github: - mkdir -p ~/.ssh - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' script: - - git push github - + - git clone --mirror ${CI_REPOSITORY_URL} mirror + - cd mirror + - git push --mirror ${MIRROR_GIT_URL} lint:coding-guideline: image: php:7.0-alpine From 7d4fec959c426525ca985af6176448a3ff444e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Tue, 11 Apr 2017 18:23:09 +0200 Subject: [PATCH 006/100] BUGFIX: Set default gitlab-ci image (alpine) & switch commands --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fef7f7e..2d8d1cb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,5 @@ +image: 'bash:latest' + before_script: - apk add --no-cache make wget git - make install-composer @@ -11,8 +13,7 @@ stages: sync:github: stage: sync before_script: - - apt-get -y update && apt-get -y upgrade - - apt-get -y install openssh-client git + - apk add --no-cache openssh-client git # SSH deploy key - eval $(ssh-agent -s) - ssh-add <(echo "$SSH_PRIVATE_KEY") From 2aec0d955c0f971b604d247e7a4cdc58b10d750b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Tue, 11 Apr 2017 18:39:15 +0200 Subject: [PATCH 007/100] HOTFIX: Reactivate gitlab runners --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fef7f7e..7363f62 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,5 @@ +image: 'php:latest' + before_script: - apk add --no-cache make wget git - make install-composer From 5ec3d2eea2207f6775d3755ebe5040f5485fbdcf Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 11 Apr 2017 20:21:20 +0200 Subject: [PATCH 008/100] WIP|BUGFIX: Allow ssh auth for github sync * Use variable as in all other scripts. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2d8d1cb..9141aac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ sync:github: - apk add --no-cache openssh-client git # SSH deploy key - eval $(ssh-agent -s) - - ssh-add <(echo "$SSH_PRIVATE_KEY") + - ssh-add <(echo "${SSH_PRIVATE_KEY}") - mkdir -p ~/.ssh - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' script: From 771d84e548bd22cb1c9ecce724e6b03f5bc09698 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 11 Apr 2017 20:56:30 +0200 Subject: [PATCH 009/100] BUGFIX: Allow ssh agent to work on alpine * Use a file instead of bash expansion. --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9141aac..0ff57a6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,9 @@ sync:github: - apk add --no-cache openssh-client git # SSH deploy key - eval $(ssh-agent -s) - - ssh-add <(echo "${SSH_PRIVATE_KEY}") + - echo "$SSH_PRIVATE_KEY" > /tmp/private_key + - chmod go-rwx /tmp/private_key; chmod u-x /tmp/private_key + - ssh-add /tmp/private_key - mkdir -p ~/.ssh - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' script: From dde46a8d375f89507eec7cfdc782b2a10758bd38 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 08:46:17 +0200 Subject: [PATCH 010/100] FEATURE: Add documentation rendering Relates: #63 --- .gitlab-ci.yml | 14 +- Documentation/.gitignore | 1 + Documentation/source/conf.py | 293 +++++++++++++++++++++++++++++++++ Documentation/source/index.rst | 22 +++ 4 files changed, 328 insertions(+), 2 deletions(-) create mode 100644 Documentation/.gitignore create mode 100644 Documentation/source/conf.py create mode 100644 Documentation/source/index.rst diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c4161e6..8b0591d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: 'bash:latest' +image: 'bash:latest' before_script: - apk add --no-cache make wget git @@ -9,6 +9,7 @@ before_script: stages: - sync - test + - render sync:github: stage: sync @@ -66,4 +67,13 @@ test:latest: script: - ./vendor/bin/phpunit -# Further stages, and jobs e.g. linting, cgl, etc. +render:documentation: + image: danielsiepmann/sphinx:latest + stage: render + before_script: + - cd Documentation + script: + - make html + artifacts: + paths: + - Documentation/build/html diff --git a/Documentation/.gitignore b/Documentation/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/Documentation/.gitignore @@ -0,0 +1 @@ +build diff --git a/Documentation/source/conf.py b/Documentation/source/conf.py new file mode 100644 index 0000000..709fc0e --- /dev/null +++ b/Documentation/source/conf.py @@ -0,0 +1,293 @@ +# -*- coding: utf-8 -*- +# +# Automated TYPO3 Update documentation build configuration file, created by +# sphinx-quickstart on Thu Apr 13 07:58:42 2017. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.intersphinx', + 'sphinx.ext.todo', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'Automated TYPO3 Update' +copyright = u'2017, Daniel Siepmann' +author = u'Daniel Siepmann' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = u'0.1.0' +# The full version, including alpha/beta/rc tags. +release = u'0.1.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. +# " v documentation" by default. +#html_title = u'Automated TYPO3 Update v0.1.0' + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not None, a 'Last updated on:' timestamp is inserted at every page +# bottom, using the given strftime format. +# The empty string is equivalent to '%b %d, %Y'. +#html_last_updated_fmt = None + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' +#html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# 'ja' uses this config value. +# 'zh' user can custom change `jieba` dictionary path. +#html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +#html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'AutomatedTYPO3Updatedoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', + +# Latex figure (float) alignment +#'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'AutomatedTYPO3Update.tex', u'Automated TYPO3 Update Documentation', + u'Daniel Siepmann', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'automatedtypo3update', u'Automated TYPO3 Update Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'AutomatedTYPO3Update', u'Automated TYPO3 Update Documentation', + author, 'AutomatedTYPO3Update', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'https://docs.python.org/': None} diff --git a/Documentation/source/index.rst b/Documentation/source/index.rst new file mode 100644 index 0000000..eeb03d1 --- /dev/null +++ b/Documentation/source/index.rst @@ -0,0 +1,22 @@ +.. Automated TYPO3 Update documentation master file, created by + sphinx-quickstart on Thu Apr 13 07:58:42 2017. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to Automated TYPO3 Update's documentation! +================================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + From 5c56c1cded0d60d7715f2fde7995d5b8a563c0bc Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 09:04:02 +0200 Subject: [PATCH 011/100] TASK: Add Makefile for documentation rendering --- Documentation/Makefile | 230 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 Documentation/Makefile diff --git a/Documentation/Makefile b/Documentation/Makefile new file mode 100644 index 0000000..4dfa749 --- /dev/null +++ b/Documentation/Makefile @@ -0,0 +1,230 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) + $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don\'t have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source + +.PHONY: help +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " applehelp to make an Apple Help Book" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " epub3 to make an epub3" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + @echo " coverage to run coverage check of the documentation (if enabled)" + @echo " dummy to check syntax errors of document sources" + +.PHONY: clean +clean: + rm -rf $(BUILDDIR)/* + +.PHONY: html +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +.PHONY: dirhtml +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +.PHONY: singlehtml +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +.PHONY: pickle +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +.PHONY: json +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +.PHONY: htmlhelp +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +.PHONY: qthelp +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/AutomatedTYPO3Update.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/AutomatedTYPO3Update.qhc" + +.PHONY: applehelp +applehelp: + $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp + @echo + @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." + @echo "N.B. You won't be able to view it unless you put it in" \ + "~/Library/Documentation/Help or install it in your application" \ + "bundle." + +.PHONY: devhelp +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/AutomatedTYPO3Update" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/AutomatedTYPO3Update" + @echo "# devhelp" + +.PHONY: epub +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +.PHONY: epub3 +epub3: + $(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3 + @echo + @echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3." + +.PHONY: latex +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +.PHONY: latexpdf +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: latexpdfja +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +.PHONY: text +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +.PHONY: man +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +.PHONY: texinfo +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +.PHONY: info +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +.PHONY: gettext +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +.PHONY: changes +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +.PHONY: linkcheck +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +.PHONY: doctest +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +.PHONY: coverage +coverage: + $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage + @echo "Testing of coverage in the sources finished, look at the " \ + "results in $(BUILDDIR)/coverage/python.txt." + +.PHONY: xml +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +.PHONY: pseudoxml +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." + +.PHONY: dummy +dummy: + $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy + @echo + @echo "Build finished. Dummy builder generates no files." From c388a7e8b3df256bc98609e06c8e4a1071748c83 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 09:06:34 +0200 Subject: [PATCH 012/100] TASK: Provide _static folder for docs --- Documentation/_static/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Documentation/_static/.gitkeep diff --git a/Documentation/_static/.gitkeep b/Documentation/_static/.gitkeep new file mode 100644 index 0000000..e69de29 From 8bbc92ba949c206dc384f83cb77315302b0a01d0 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 09:07:54 +0200 Subject: [PATCH 013/100] BUGFIX: Allow local docs rendering * Update .gitlab-ci.yml to allow running gitlab-runner exec docker render:documentation locally --- .gitlab-ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b0591d..7e5bbb1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,3 @@ -image: 'bash:latest' - before_script: - apk add --no-cache make wget git - make install-composer @@ -12,6 +10,7 @@ stages: - render sync:github: + image: 'bash:latest' stage: sync before_script: - apk add --no-cache openssh-client git @@ -68,7 +67,7 @@ test:latest: - ./vendor/bin/phpunit render:documentation: - image: danielsiepmann/sphinx:latest + image: 'danielsiepmann/sphinx:latest' stage: render before_script: - cd Documentation From a0e83ebef097aa34fc648a736b714bd5dc3bf1fd Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 09:16:46 +0200 Subject: [PATCH 014/100] TASK: Add checks for documentation * Check for syntax issues. * Check for link integrity. --- .gitlab-ci.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e5bbb1..cd8a2f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,6 +66,32 @@ test:latest: script: - ./vendor/bin/phpunit +test:documentation:syntax: + image: 'danielsiepmann/sphinx:latest' + stage: test + before_script: + - cd Documentation + script: + - make dummy + artifacts: + when: on_failure + artifacts: + paths: + - Documentation/build/dummy + +test:documentation:external-links: + image: 'danielsiepmann/sphinx:latest' + stage: test + before_script: + - cd Documentation + script: + - make linkcheck + artifacts: + when: on_failure + artifacts: + paths: + - Documentation/build/linkcheck/output.txt + render:documentation: image: 'danielsiepmann/sphinx:latest' stage: render From 8cb68ff6bb4e75301154ca461bd7f39433ade62a Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 10:54:32 +0200 Subject: [PATCH 015/100] TASK: Migrate / write documentation * Add further information and sections, e.g. about contribution and extending. Relates: #63 --- Documentation/source/conf.py | 26 ++++- Documentation/source/configuration.rst | 154 +++++++++++++++++++++++++ Documentation/source/contribution.rst | 36 ++++++ Documentation/source/extending.rst | 94 +++++++++++++++ Documentation/source/features.rst | 110 ++++++++++++++++++ Documentation/source/index.rst | 79 ++++++++++--- Documentation/source/usage.rst | 45 ++++++++ 7 files changed, 525 insertions(+), 19 deletions(-) create mode 100644 Documentation/source/configuration.rst create mode 100644 Documentation/source/contribution.rst create mode 100644 Documentation/source/extending.rst create mode 100644 Documentation/source/features.rst create mode 100644 Documentation/source/usage.rst diff --git a/Documentation/source/conf.py b/Documentation/source/conf.py index 709fc0e..406a886 100644 --- a/Documentation/source/conf.py +++ b/Documentation/source/conf.py @@ -109,9 +109,23 @@ todo_include_todos = True # -- Options for HTML output ---------------------------------------------- +import guzzle_sphinx_theme + +html_theme_path = guzzle_sphinx_theme.html_theme_path() +html_theme = 'guzzle_sphinx_theme' + +# Register the theme as an extension to generate a sitemap.xml +extensions.append("guzzle_sphinx_theme") + +# Guzzle theme options (see theme.conf for more information) +# html_theme_options = { +# # Set the name of the project to appear in the sidebar +# "project_nav_name": project, +# } + # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'alabaster' +# html_theme = 'alabaster' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -123,7 +137,7 @@ html_theme = 'alabaster' # The name for this set of Sphinx documents. # " v documentation" by default. -#html_title = u'Automated TYPO3 Update v0.1.0' +html_title = u'Automated TYPO3 Update v0.1.0' # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None @@ -157,7 +171,13 @@ html_static_path = ['_static'] #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +html_sidebars = { + '**': ['logo-text.html', + 'globaltoc.html', + 'localtoc.html', + 'searchbox.html', + ], +} # Additional templates that should be rendered to pages, maps page names to # template names. diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst new file mode 100644 index 0000000..07023b2 --- /dev/null +++ b/Documentation/source/configuration.rst @@ -0,0 +1,154 @@ +.. _configuration: + +Configuration +============= + +Configuration is done through PHPCS Standards, e.g. provide a custom :file:`ruleset.xml` or inside your +project using a :file:`phpcs.xml.dist`. As this is just a PHPCS-Standard, the official documentation +applies. + +All options available in :file:`ruleset.xml` are also available in your :file:`phpcs.xml` files, as +already documented by phpcs itself. Therefore this documentation will just mention +:file:`ruleset.xml`. + +Beside that, some options are also available through CLI. Examples are always provided. + +The following configuration options are available: + +.. _configuration-legacyExtensions: + +legacyExtensions +---------------- + +Configures which extension names are legacy. Used to provide further checks and warnings about +possible legacy code. All class usages starting with ``Tx_`` where ExtensionName is +defined in this array, will produce a warning, until the class is already found to be deprecaed. + +Can and have to be configured for each sniff, e.g. ``Instanceof`` and ``DocComment``. + +Example: + +.. code:: xml + + + + + + + + +.. _configuration-allowedTags: + +allowedTags +----------- + +Only used inside Sniff ``Typo3Update.LegacyClassnames.DocComment``. + +Configures which tags are checked for legacy class names. + +This way you can add checks for further tags you are using. All strings inside the tag are checked, +so no matter where the class name occurs inside the tag. + +Example: + +.. code:: xml + + + + + + + +.. _configuration-mappingFile: + +mappingFile +----------- + +For auto migrating usages of old class names, a PHP file with a mapping is required. The file has to +be in the composer structure :file:`autoload_classaliasmap.php`. +If TYPO3 is already installed using composer, you can use this file through configuration, or by +copying to the default location, which is :file:`LegacyClassnames.php` in the root of this project. + +Configure where the `LegacyClassnames.php` is located, through ``ruleset.xml`` or using +``--runtime-set``. Default is `LegacyClassnames.php` in the project root. + +Using :file:`ruleset.xml`: + +.. code:: xml + + + +Using ``runtime-set``: + +.. code:: bash + + --runtime-set mappingFile /projects/typo3_installation/vendor/composer/autoload_classaliasmap.php + +.. _configuration-vendor: + +vendor +------ + +Used while adding namespaces to legacy class definitions and updating plugin and module +registrations. Default is ``YourCompany`` to enable you to search and replace afterwards. + +If you use multiple vendors through your projects, use the cli to define the vendor and run +``phpcbf`` over specific folders, this way you can update your project step by step with different +vendors. + +Using :file:`ruleset.xml`: + +.. code:: xml + + + +Example: + +.. code:: bash + + --runtime-set vendor YourVendor + +.. _configuration-removedFunctionConfigFiles: + +removedFunctionConfigFiles +-------------------------- + +Configure where to look for configuration files defining the removed functions and methods. Default +is ``Configuration/Removed/Functions/*.yaml`` inside the standard itself. We already try to deliver +as much as possible. +Globing is used, so placeholders like ``*`` are possible, see +https://secure.php.net/manual/en/function.glob.php + +Using :file:`ruleset.xml`: + +.. code:: xml + + + +Example: + +.. code:: bash + + --runtime-set removedFunctionConfigFiles "/Some/Absolute/Path/*.yaml" + +.. _configuration-removedConstantConfigFiles: + +removedConstantConfigFiles +-------------------------- + +Configure where to look for configuration files defining the removed constants. Default is +``Configuration/Removed/Functions/*.yaml`` inside the standard itself. We already try to deliver as +much as possible. Globing is used, so placeholders like ``*`` are possible, see +https://secure.php.net/manual/en/function.glob.php + +Using :file:`ruleset.xml`: + +.. code:: xml + + + +Example: + +.. code:: bash + + --runtime-set removedConstantConfigFiles "/Some/Absolute/Path/*.yaml" diff --git a/Documentation/source/contribution.rst b/Documentation/source/contribution.rst new file mode 100644 index 0000000..7a0ad9d --- /dev/null +++ b/Documentation/source/contribution.rst @@ -0,0 +1,36 @@ +.. _highlight: bash + +Contribution +============ + +The project is hosted at https://git.higidi.com/Automated-TYPO3-Update/automated-typo3-update fill +issues there. Also you can fork and clone the project there and provide merge requests. + +Also you can contact us on `TYPO3 slack`_. + +Documentation +------------- + +Documentation is written using `reStructuredText`_ ans `sphinx`_. + +Just open the files with a text editor and update contents. + +To render documentation locally install `docker`_ and run:: + + docker run -v "$PWD/Documentation":/sphinx danielsiepmann/sphinx + +from within the project root. + +Code +---- + +A :file:`.editorconfig` is already provided to setup your editor. Also `phpcs` is configured, so +make sure to check your coding style with `phpcs`_. + +New sniffs have to be covered by tests, see :ref:`extending-tests`. + +.. _TYPO3 slack: https://typo3.slack.com/messages/@danielsiepmann +.. _docker: https://www.docker.com/ +.. _phpcs: https://github.com/squizlabs/PHP_CodeSniffer +.. _reStructuredText: http://docutils.sourceforge.net/rst.html +.. _sphinx: http://www.sphinx-doc.org/en/stable/ diff --git a/Documentation/source/extending.rst b/Documentation/source/extending.rst new file mode 100644 index 0000000..ad71a8a --- /dev/null +++ b/Documentation/source/extending.rst @@ -0,0 +1,94 @@ +.. _extending: + +Extending +========= + +It's possible to extend the provided migrations. + +Also adding tests is pretty easy and done by adding a folder with an input file and an file +holding the expectations. + +.. _extending-sniffs: + +Sniffs +------ + +Follow the official docs of `phpcs`_: +https://github.com/squizlabs/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial#creating-the-sniff + +The following resources might be helpful during working with ``phpcs``: + +- https://secure.php.net/manual/en/tokens.php + +- :file:`CodeSniffer/Tokens.php` + +- :file:`CodeSniffer/File.php` + +.. _extending-tests: + +Tests +----- + +We are using `phpunit` as testing framework. + +Adding tests for sniffs is as easy as providing the same folder structure as for the sniff, just +inside the :file:`tests/Fixtures` folder. Instead of adding the sniff as a file, you have to provide +a folder named like the sniff. E.g. you want to add a test for sniff +:file:`src/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff.php`, the following folder +has to exist: :file:`tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/`. + +.. _extending-tests-single: + +Single test per sniff +--------------------- + +Inside of the folder at least a file :file:`InputFileForIssues.php` has to exist, containing PHP +code to use for the test. Also a file :file:`Expected.json` has to exist, with the json result of +calling ``phpcs`` with :file:`InputFileForIssues.php`. + +Everything else is done out of the box. + +If your sniff also implements fixable errors or warnings, you can further provide a +:file:`Expected.diff` which is generated by ``phpcbf``. + +.. _extending-tests-multiple: + +Multiple tests per sniff +------------------------ + +Also it's possible to provide multiple tests for a single sniff, e.g. with different cli arguments +like options for the sniff. In that case you have to place a :file:`Arguments.php` in the folder. +This file returns an array: + +.. code-block:: php + [], + 'customVendor' => [ + 'runtime-set' => [ + 'vendor' => 'MyCustomVendor', + ], + ], + ]; + +In the example above ``defaultVendor`` and ``customVendor` are subfolders containing the same +structure as documented for :ref:`extending-tests-single`. +This way it's possible to run multiple tests per sniff. + +Also you can provide further cli arguments on a key -> value base. Where ``runtime-set`` is special, +as it contains a sub array to provide multiple runtime sets. + +How sniff tests are implemented +------------------------------- + +We just find all folders below :file:`tests/Fixtures/Standards/Typo3Update/Sniffs` ending with +``Sniff`` and check the structure. They are provided to the test itself through a dataprovider in +phpunit. + +We then build the phpcs cli call and execute it against the :file:`InputFileForIssues.php` and +compare the result against the :file:`Expected.json`. Same for :file:`Expected.diff`. The existence +of :file:`Expected.diff` itself will trigger the test for ``phpcbf``. + +.. _phpcs: https://github.com/squizlabs/PHP_CodeSniffer +.. _phpunit: https://phpunit.de/ diff --git a/Documentation/source/features.rst b/Documentation/source/features.rst new file mode 100644 index 0000000..a042484 --- /dev/null +++ b/Documentation/source/features.rst @@ -0,0 +1,110 @@ +.. _features: + +Features +======== + +Migration of old legacy classnames to namespace class names +----------------------------------------------------------- + +Currently we can migrate calls to old legacy class names of the TYPO3 core like ``Tx_Extbase...`` to +new ones like ``\TYPO3\Extbase\...``. This is done for: + +Possible configurations for all sniffs: + +- :ref:`configuration-legacyExtensions` + +Implemented sniffs: + +- PHPDocuments, like Includes and annotations for IDEs. + + Possible extra configurations: + + - :ref:`configuration-allowedTags` + + +- Inheritance like ``extends`` and ``implements``. + +- Static calls like ``t3lib_div::`` to ``\TYPO3\Core\Utility\GeneralUtility``. + +- Static call also checks for ``::class``, as technically we just look before the ``::``. + +- Typehints in methods and function like injects. + +- ``instanceof`` checks. + +- Inline comments for IDEs, e.g. ``/* @var $configurationManager + Tx_Extbase_Configuration_ConfigurationManager */`` + +- Instantiation through ``new``. + +- Instantiation through ``makeInstance``. Only Classnames in Strings are supported, no ``::class``. + +- Instantiation through ``ObjectManager``, check afterwards as this is static and all function calls + using ``get`` and ``create`` will be adjusted. Might be useful to exclude this sniff and run it + separately. + Only Classnames in Strings are supported, no ``::class``. + +- ``use`` statements. + +- ``catch`` of legacy class names. + + +Also definitions of classes, traits and interfaces are migrated too: + +Possible extra configurations: + +- :ref:`configuration-vendor` + + +Definitions are migrated, where namespace is added right after opening php-tag and class name is +replaced with last part. We split by ``_`` as Extbase convention. + +After definitions were migrated, we also migrate the usage in the same way as documented above for +TYPO3 core classes. On first run the definition will be converted, on second run the usage. This is +due to the fact, that PHPCS might find the definition after the usage, so please run twice. + +.. note:: + The configured file will be updated after each run, for each converted class, trait and + interface definition. See :ref:`configuration-mappingFile`. + + +This also covers adding the vendor to plugin and modules in :file:`ext_tables.php` and +:file:`ext_localconf.php`: + +Possible extra configurations: + +- :ref:`configuration-vendor` + + +Add missing vendor to plugin and module registrations and configurations. You might want to set +this to non fixable and warning if you already provide the vendor inside a single Variable, together +with your extension key, as this is not recognized. So the following will be recognized: + + - ``$_EXTKEY,`` + + - ``$VENDOR . $_EXTKEY,`` + + - ``'VENDOR.' . $_EXTKEY,`` + + +While the following will not: + + - ``$key = 'Vendor.' . $_EXTKEY;`` + +Check for removed calls +----------------------- + +Also we check for the following deprecated calls: + +Check for usage of *removed functions* in general. The functions are configured via yaml files. The +location of them is configurable, default is inside the standard itself, and we try to deliver all +information. For configuration options see ``removedFunctionConfigFiles``. + +Check for usage of *removed constants*. The constants are configured in same way as removed +functions. For configuration options see ``removedConstantConfigFiles``. + + +Further checks +-------------- + +- Legacy ajax registrations for TYPO3 Backend. diff --git a/Documentation/source/index.rst b/Documentation/source/index.rst index eeb03d1..93ec3be 100644 --- a/Documentation/source/index.rst +++ b/Documentation/source/index.rst @@ -1,22 +1,69 @@ -.. Automated TYPO3 Update documentation master file, created by - sphinx-quickstart on Thu Apr 13 07:58:42 2017. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. +.. _highlight: bash -Welcome to Automated TYPO3 Update's documentation! -================================================== +About +===== -Contents: +Our goal is to provide automated migrations for TYPO3 updates, as much as possible. + +This should include source code modifications like adjusting old legacy class names to new ones and +providing a list of deprecated calls. + +The official project home page can be found at https://git.higidi.com/Automated-TYPO3-Update/automated-typo3-update . +Please open new issues and merge requests there. You can login with your Github account. + +Github is just used as a mirror for the project. + +Requirements +============ + +To install the project you need ``composer`` to be installed and inside your ``$PATH``. +Otherwise run ``make install-composer`` to install composer. + +Installation +============ + +Run:: + + make install + +Afterwards the :ref:`configuration-mappingFile` is required. + +What does it look like? +======================= + +.. code:: + + $ ./vendor/bin/phpcs -p --colors -s + E + + + FILE: + ---------------------------------------------------------------------- + FOUND 5 ERRORS AFFECTING 5 LINES + ---------------------------------------------------------------------- + 8 | ERROR | [x] Legacy classes are not allowed; found + | | backend_toolbarItem + | | (Typo3Update.LegacyClassnames.Inheritance.legacyClassname) + 14 | ERROR | [x] Legacy classes are not allowed; found TYPO3backend + | | (Typo3Update.LegacyClassnames.DocComment.legacyClassname) + 16 | ERROR | [x] Legacy classes are not allowed; found TYPO3backend + | | (Typo3Update.LegacyClassnames.TypeHint.legacyClassname) + 48 | ERROR | [x] Legacy classes are not allowed; found t3lib_extMgm + | | (Typo3Update.LegacyClassnames.StaticCall.legacyClassname) + 61 | ERROR | [x] Legacy classes are not allowed; found t3lib_div + | | (Typo3Update.LegacyClassnames.StaticCall.legacyClassname) + ---------------------------------------------------------------------- + PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY + ---------------------------------------------------------------------- + + Time: 35ms; Memory: 5Mb .. toctree:: :maxdepth: 2 + :hidden: - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - + features + configuration + usage + extending + contribution diff --git a/Documentation/source/usage.rst b/Documentation/source/usage.rst new file mode 100644 index 0000000..0159d9c --- /dev/null +++ b/Documentation/source/usage.rst @@ -0,0 +1,45 @@ +.. _highlight: bash + +Usage +===== + +If everything is configured, you can run:: + + ./vendor/bin/phpcbf + +This will run the auto fixer recursive for ```` fixing all issues. + +For some tasks you need to run the above command twice, e.g. for namespace migrations. + +Afterwards you should run:: + + ./vendor/bin/phpcs + +To get information about possible issues that were not autofixed. + +To prevent issues, use the following setup:: + + ./vendor/bin/phpcs --standard=Typo3Update -p --colors --runtime-set mappingFile + +Same for ``phpcbf``. + +Further examples +---------------- + +You might want to add ``-p --colors`` to see that something is happening. + +Also make sure to ignore certain files like libraries or js and css files while running the update. +Check out the official docs for how to do so. + +FAQ +--- + +I do not see any issues regarding TYPO3 update but lots of coding style. + Then you probably have a :file:`phpcs.xml` in your project taking precedence. Add the + ``-standard=`` argument to the call:: + + ./vendor/bin/phpcs --standard=Typo3Update + +I see the error message ``Failed opening required 'Standards/Typo3Update/Sniffs/../../../../LegacyClassnames.php'`` + Then you didn't configure :ref:`configuration-mappingFile`, check the link and update the + configuration. From e05941ea460a5866650dc5651dfea19e096ef5e0 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 10:55:08 +0200 Subject: [PATCH 016/100] TASK: Add requirements.txt to enable read the docs * As we use a different theme. Relates: #63 --- Documentation/requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 Documentation/requirements.txt diff --git a/Documentation/requirements.txt b/Documentation/requirements.txt new file mode 100644 index 0000000..0908555 --- /dev/null +++ b/Documentation/requirements.txt @@ -0,0 +1 @@ +guzzle_sphinx_theme == 0.7 From d15388849efc4d2dee63c6eaf234381880d718b5 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 10:58:07 +0200 Subject: [PATCH 017/100] TASK: Cleanup gitlab-ci.yml * Remove artifacts which are not necessary as output is shown in job --- .gitlab-ci.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cd8a2f7..70cce9b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -73,11 +73,6 @@ test:documentation:syntax: - cd Documentation script: - make dummy - artifacts: - when: on_failure - artifacts: - paths: - - Documentation/build/dummy test:documentation:external-links: image: 'danielsiepmann/sphinx:latest' @@ -86,11 +81,6 @@ test:documentation:external-links: - cd Documentation script: - make linkcheck - artifacts: - when: on_failure - artifacts: - paths: - - Documentation/build/linkcheck/output.txt render:documentation: image: 'danielsiepmann/sphinx:latest' From c87546de29282e4ceabf5f8525f3bb63a321433b Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 11:02:50 +0200 Subject: [PATCH 018/100] BUGFIX: Broken documentation * Fix broken links * Fix broken syntax Relates: #63 --- Documentation/source/contribution.rst | 2 +- Documentation/source/extending.rst | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/source/contribution.rst b/Documentation/source/contribution.rst index 7a0ad9d..a5df793 100644 --- a/Documentation/source/contribution.rst +++ b/Documentation/source/contribution.rst @@ -29,7 +29,7 @@ make sure to check your coding style with `phpcs`_. New sniffs have to be covered by tests, see :ref:`extending-tests`. -.. _TYPO3 slack: https://typo3.slack.com/messages/@danielsiepmann +.. _TYPO3 slack: https://typo3.slack.com/?redir=%2Fmessages%2F%40danielsiepmann .. _docker: https://www.docker.com/ .. _phpcs: https://github.com/squizlabs/PHP_CodeSniffer .. _reStructuredText: http://docutils.sourceforge.net/rst.html diff --git a/Documentation/source/extending.rst b/Documentation/source/extending.rst index ad71a8a..05748bb 100644 --- a/Documentation/source/extending.rst +++ b/Documentation/source/extending.rst @@ -14,7 +14,7 @@ Sniffs ------ Follow the official docs of `phpcs`_: -https://github.com/squizlabs/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial#creating-the-sniff +https://github.com/squizlabs/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial#user-content-creating-the-sniff The following resources might be helpful during working with ``phpcs``: @@ -61,6 +61,7 @@ like options for the sniff. In that case you have to place a :file:`Arguments.ph This file returns an array: .. code-block:: php + Date: Thu, 13 Apr 2017 11:49:53 +0200 Subject: [PATCH 019/100] TASK: Add missing test for GenericConstantUsageSniff Relates: #64 --- .../GenericConstantUsageSniff/Expected.json | 33 +++++++++++++++++++ .../InputFileForIssues.php | 23 +++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json new file mode 100644 index 0000000..6e63f1d --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json @@ -0,0 +1,33 @@ +{ + "files": { + "InputFileForIssues.php": { + "errors": 0, + "messages": [ + { + "column": 9, + "fixable": false, + "line": 22, + "message": "Legacy calls are not allowed; found constant PATH_tslib. Removed in 7.0. The folder and constant no longer exist. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61459-RemovalTslib.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericConstantUsage.PATH_tslib", + "type": "WARNING" + }, + { + "column": 11, + "fixable": false, + "line": 23, + "message": "Legacy calls are not allowed; found constant TYPO3_MOD_PATH. Removed in 7.4. It is required to route modules through typo3/mod.php from now on in case the module relies on the definition of those constants. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-67987-RemovedEntryScriptHandling.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericConstantUsage.TYPO3_MOD_PATH", + "type": "WARNING" + } + ], + "warnings": 2 + } + }, + "totals": { + "errors": 0, + "fixable": 0, + "warnings": 2 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php new file mode 100644 index 0000000..944af55 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php @@ -0,0 +1,23 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +$file = PATH_tslib . 'something.php'; +$module = TYPO3_MOD_PATH . '/folder'; From 9a905c492a3ef2c3ded055e96e274abd2728738f Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 11:56:52 +0200 Subject: [PATCH 020/100] TASK: Add missing test for GenericFunctionCallSniff Resolves: #64 --- .../GenericFunctionCallSniff/Expected.json | 60 +++++++++++++++++++ .../InputFileForIssues.php | 35 +++++++++++ 2 files changed, 95 insertions(+) create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json new file mode 100644 index 0000000..f2e61ab --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json @@ -0,0 +1,60 @@ +{ + "files": { + "InputFileForIssues.php": { + "errors": 0, + "messages": [ + { + "column": 41, + "fixable": false, + "line": 24, + "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", + "type": "WARNING" + }, + { + "column": 17, + "fixable": false, + "line": 26, + "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", + "type": "WARNING" + }, + { + "column": 44, + "fixable": false, + "line": 28, + "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", + "type": "WARNING" + }, + { + "column": 8, + "fixable": false, + "line": 31, + "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController->includeTCA. Removed in 7.0. Full TCA is always loaded during bootstrap in FE, the method is obsolete. If an eid script calls this method to load TCA, use \\TYPO3\\CMS\\Frontend\\Utility\\EidUtility::initTCA() instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-FrontendTcaFunctionsRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.TypoScriptFrontendController.includeTCA", + "type": "WARNING" + }, + { + "column": 17, + "fixable": false, + "line": 35, + "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController->includeTCA. Removed in 7.0. Full TCA is always loaded during bootstrap in FE, the method is obsolete. If an eid script calls this method to load TCA, use \\TYPO3\\CMS\\Frontend\\Utility\\EidUtility::initTCA() instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-FrontendTcaFunctionsRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericFunctionCall.TypoScriptFrontendController.includeTCA", + "type": "WARNING" + } + ], + "warnings": 5 + } + }, + "totals": { + "errors": 0, + "fixable": 0, + "warnings": 5 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/InputFileForIssues.php new file mode 100644 index 0000000..5f65331 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/InputFileForIssues.php @@ -0,0 +1,35 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use TYPO3\CMS\Core\Utility\GeneralUtility; + +\TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('some_tca_table'); +// Both works, as we check last part of class name only. +GeneralUtility::loadTCA('some_tca_table'); +// Also matches, as we don't check whole name for now, to enable the above check with imported name. +\OwnVendor\ExtName\Utility\GeneralUtility::loadTCA('some_tca_table'); + +$test = new \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController(); +$test->includeTCA(); + +$someThingElse = new \DateTime(); +// Is also detected, as we do not check type of variable. +$someThingElse->includeTCA(); From 6a3d18ecfc8379c51b6e6ea6c89aa76afcaa0ca5 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 12:02:44 +0200 Subject: [PATCH 021/100] TASK: Add further test cases to GenericConstantUsageSniff * To show what's also working and what will potentially provide non helpful warnings. Relates: #64 --- .../GenericConstantUsageSniff/Expected.json | 31 +++++++++++++++++-- .../InputFileForIssues.php | 6 ++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json index 6e63f1d..e3072f3 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json @@ -20,14 +20,41 @@ "severity": 5, "source": "Typo3Update.Removed.GenericConstantUsage.TYPO3_MOD_PATH", "type": "WARNING" + }, + { + "column": 75, + "fixable": false, + "line": 24, + "message": "Legacy calls are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericConstantUsage.SearchFormController.WILDCARD_LEFT", + "type": "WARNING" + }, + { + "column": 39, + "fixable": false, + "line": 27, + "message": "Legacy calls are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericConstantUsage.SearchFormController.WILDCARD_LEFT", + "type": "WARNING" + }, + { + "column": 66, + "fixable": false, + "line": 29, + "message": "Legacy calls are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", + "severity": 5, + "source": "Typo3Update.Removed.GenericConstantUsage.SearchFormController.WILDCARD_LEFT", + "type": "WARNING" } ], - "warnings": 2 + "warnings": 5 } }, "totals": { "errors": 0, "fixable": 0, - "warnings": 2 + "warnings": 5 } } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php index 944af55..1a199ae 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/InputFileForIssues.php @@ -21,3 +21,9 @@ $file = PATH_tslib . 'something.php'; $module = TYPO3_MOD_PATH . '/folder'; +$someVariable = \TYPO3\CMS\IndexedSearch\Controller\SearchFormController::WILDCARD_LEFT . '/folder'; +use \TYPO3\CMS\IndexedSearch\Controller\SearchFormController; +// Will work, as we only check last part of class name. +$someVariable = SearchFormController::WILDCARD_LEFT . '/folder'; +// Also matches, as we don't check whole name for now, to enable the above check with imported name. +$someVariable = \Vendor\ExtName\Controller\SearchFormController::WILDCARD_LEFT . '/folder'; From fc8d3579ffd0b35a5ce782f12f098b6e080cf4c6 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 12:04:46 +0200 Subject: [PATCH 022/100] TASK: Add hint how to disable warnings for specific deprecations --- Documentation/source/configuration.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst index 07023b2..6209816 100644 --- a/Documentation/source/configuration.rst +++ b/Documentation/source/configuration.rst @@ -13,6 +13,10 @@ already documented by phpcs itself. Therefore this documentation will just menti Beside that, some options are also available through CLI. Examples are always provided. +To disable warnings for specific deprecated parts, e.g. a specific function, you can use the full +sniff name, as we try to add the concrete constant or function name to the sniff. Just run ``phpcs`` +with the ``-s`` option to see sniff names. + The following configuration options are available: .. _configuration-legacyExtensions: From 0bddc8c291fa2dae708c9f8b070791aa1522e01a Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 12:28:33 +0200 Subject: [PATCH 023/100] TASK: Update readme * As documentation exists now, we don't need all the information in readme. * Just link the official documentation. * We can safely point to the domain and adjust the redirect at read the docs itself. Relates: #63, !71 --- Readme.rst | 239 +---------------------------------------------------- 1 file changed, 1 insertion(+), 238 deletions(-) diff --git a/Readme.rst b/Readme.rst index 3ba4905..c987855 100644 --- a/Readme.rst +++ b/Readme.rst @@ -1,5 +1,3 @@ -.. _highlight: bash - About ===== @@ -12,239 +10,4 @@ Please open new issues and merge requests there. You can login with your Github Github is just used as a mirror for the project. -Requirements -============ - -- ``composer`` needs to be installed and inside your ``$PATH``. Otherwise run ``make - install-composer``. - -Installation -============ - -Run:: - - make install - -and copy the ``vendor/composer/autoload_classaliasmap.php`` generated by ``composer`` in your TYPO3 -installation to ``LegacyClassnames.php`` in the root of this project. - -Usage -===== - -Run:: - - ./vendor/bin/phpcbf - -This will run the auto fixer recursive for ```` fixing all issues. - -Afterwards you should run:: - - ./vendor/bin/phpcs - -To get information about possible issues that were not autofixed. - -What's included? -================ - -Currently we can migrate calls to old legacy class names of the TYPO3 core like ``Tx_Extbase...`` to -new ones like ``\TYPO3\Extbase\...``. This is done for: - -- PHPDocuments, like Includes and annotations for IDEs. - -- Inheritance like ``extends`` and ``implements``. - -- Static calls like ``t3lib_div::`` to ``\TYPO3\Core\Utility\GeneralUtility``. - -- Static call also checks for ``::class``, as technically we just look before the ``::``. - -- Typehints in methods and function like injects. - -- ``instanceof`` checks. - -- Inline comments for IDEs, e.g. ``/* @var $configurationManager - Tx_Extbase_Configuration_ConfigurationManager */`` - -- Instantiation through ``new``. - -- Instantiation through ``makeInstance``. Only Classnames in Strings are supported, no ``::class``. - -- Instantiation through ``ObjectManager``, check afterwards as this is static and all function calls - using ``get`` and ``create`` will be adjusted. Might be useful to exclude this sniff and run it - separately. - Only Classnames in Strings are supported, no ``::class``. - -- ``use`` statements. - -- ``catch`` of legacy class names. - -- Convert old legacy class *definitions* in extensions to namespaces. - -- Convert usage of previously converted class definitions. On first run the definition will be - converted, on second run the usage. This is due to the fact, that PHPCS might find the definition - after the usage, so please run twice. - - *NOTE* The configured file will be updated after each run, for each converted class, trait and - interface definition. See options. - -- Add missing vendor to plugin and module registrations and configurations. - You might want to set this to non fixable and warning if you already provide the vendor inside a - single Variable, together with your extension key, as this is not recognized. So the following - will be recognized: - - - ``$_EXTKEY,`` - - - ``$VENDOR . $_EXTKEY,`` - - - ``'VENDOR.' . $_EXTKEY,`` - - While the following will not: - - - ``$key = 'Vendor.' . $_EXTKEY;`` - -Also we check for the following deprecated calls: - -- Check for ``create`` on ``ObjectManager``, which is "stupid" just all ``create`` calls are marked - with a warning. - -Beside the features above which are covered by ``phpcs`` and phpcbf``, the following linting is also -available to generate a report of possible issues and during coding through ``phpcs``: - -- Check for usage of removed functions. - The functions are configured via yaml files. The location of them is configurable, default is - inside the standard itself, and we try to deliver all information. - For configuration options see ``removedFunctionConfigFiles``. - -- Check for usage of removed constants. - The constants are configured in same way as removed functions. - For configuration options see ``removedConstantConfigFiles``. - -What does it look like? -======================= - -.. code:: - - $ ./vendor/bin/phpcs -p --colors -s - E - - - FILE: - ---------------------------------------------------------------------- - FOUND 5 ERRORS AFFECTING 5 LINES - ---------------------------------------------------------------------- - 8 | ERROR | [x] Legacy classes are not allowed; found - | | backend_toolbarItem - | | (Typo3Update.LegacyClassnames.Inheritance.legacyClassname) - 14 | ERROR | [x] Legacy classes are not allowed; found TYPO3backend - | | (Typo3Update.LegacyClassnames.DocComment.legacyClassname) - 16 | ERROR | [x] Legacy classes are not allowed; found TYPO3backend - | | (Typo3Update.LegacyClassnames.TypeHint.legacyClassname) - 48 | ERROR | [x] Legacy classes are not allowed; found t3lib_extMgm - | | (Typo3Update.LegacyClassnames.StaticCall.legacyClassname) - 61 | ERROR | [x] Legacy classes are not allowed; found t3lib_div - | | (Typo3Update.LegacyClassnames.StaticCall.legacyClassname) - ---------------------------------------------------------------------- - PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY - ---------------------------------------------------------------------- - - Time: 35ms; Memory: 5Mb - -Configuration -============= - -Configuration is done through PHPCS Standards, e.g. provide a custom ``ruleset.xml`` or customize -the provided one. - -``legacyExtensions`` - Configures which extension names are legacy. Used to provide further checks and warnings about - possible legacy code. E.g. inside of non auto migrated situations. - - Example: - -.. code:: xml - - - - - - - -Typo3Update.LegacyClassnames.DocComment: ``allowedTags`` - Configures which tags are checked for legacy class names. - - Example: - -.. code:: xml - - - - - - - -``mappingFile`` - Configure where the `LegacyClassnames.php` is located, through ``ruleset.xml`` or using - ``--runtime-set``. Default is `LegacyClassnames.php` in the project root. - - Example: - -.. code:: xml - - - -Example: - -.. code:: bash - - --runtime-set mappingFile /projects/typo3_installation/vendor/composer/autoload_classaliasmap.php - -``vendor`` - Configure your vendor through ``ruleset.xml`` or using ``--runtime-set``. Default is - ``YourCompany``. - - Example: - -.. code:: xml - - - -Example: - -.. code:: bash - - --runtime-set vendor YourVendor - -``removedFunctionConfigFiles`` - Configure your vendor through ``ruleset.xml`` or using ``--runtime-set``. Default is - ``Configuration/Removed/Functions/*.yaml`` inside the standard itself. - Globing is used, so placeholders like ``*`` are possible, see - https://secure.php.net/manual/en/function.glob.php - - Example: - -.. code:: xml - - - -Example: - -.. code:: bash - - --runtime-set removedFunctionConfigFiles "/Some/Absolute/Path/*.yaml" - -``removedConstantConfigFiles`` - Configure your vendor through ``ruleset.xml`` or using ``--runtime-set``. Default is - ``Configuration/Removed/Constants/*.yaml`` inside the standard itself. - Globing is used, so placeholders like ``*`` are possible, see - https://secure.php.net/manual/en/function.glob.php - - Example: - -.. code:: xml - - - -Example: - -.. code:: bash - - --runtime-set removedConstantConfigFiles "/Some/Absolute/Path/*.yaml" +Check out the official documentation at: https://automated-typo3-update.readthedocs.io From 896117aa0127b5e4b907ee674de0e80d27ef0949 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 13:25:35 +0200 Subject: [PATCH 024/100] TASK: Add docs how to lint TypoScript Relates: #54 --- Documentation/source/usage.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/source/usage.rst b/Documentation/source/usage.rst index 0159d9c..2d231cb 100644 --- a/Documentation/source/usage.rst +++ b/Documentation/source/usage.rst @@ -31,6 +31,17 @@ You might want to add ``-p --colors`` to see that something is happening. Also make sure to ignore certain files like libraries or js and css files while running the update. Check out the official docs for how to do so. +Lint TypoScript +--------------- + +To lint TypoScript, include the files in your linting and add the following arguments per file +extension:: + + --extensions=txt/TypoScript,ts/TypoScript + +Make sure to ignore files with same file extension but different meaning, like documentatons, readme +or changelogs. + FAQ --- From e7dbac4d33d822f2d2e429aa39ad2ccdda3f8c89 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 13:31:32 +0200 Subject: [PATCH 025/100] TASK: Cleanup php code * Adjust variable name, as this is generic and not about constants. --- .../Sniffs/Removed/AbstractGenericUsage.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php index 13697f0..87e5caf 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php @@ -45,7 +45,7 @@ abstract class AbstractGenericUsage implements PhpCsSniff protected $configured = []; /** - * Constant for the current sniff instance. + * Entries removed in current sniff. * @var array */ protected $removed = []; @@ -203,16 +203,16 @@ abstract class AbstractGenericUsage implements PhpCsSniff */ protected function addMessage(PhpCsFile $phpcsFile, $tokenPosition) { - foreach ($this->removed as $constant) { + foreach ($this->removed as $removed) { $phpcsFile->addWarning( 'Legacy calls are not allowed; found %s. Removed in %s. %s. See: %s', $tokenPosition, - $this->getIdentifier($constant), + $this->getIdentifier($removed), [ - $this->getOldUsage($constant), - $this->getRemovedVersion($constant), - $this->getReplacement($constant), - $this->getDocsUrl($constant), + $this->getOldUsage($removed), + $this->getRemovedVersion($removed), + $this->getReplacement($removed), + $this->getDocsUrl($removed), ] ); } @@ -283,7 +283,7 @@ abstract class AbstractGenericUsage implements PhpCsSniff /** * Allow user to lookup the official docs related to this deprecation / breaking change. * - * @param array $config The converted structure for a single constant. + * @param array $config * * @return string */ From 7a999212e20414e142ce27d7a31750791e0a9597 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 13:32:20 +0200 Subject: [PATCH 026/100] FEATURE: Add first TypoScript sniff * Add configuration for removed object identifiers. * Add sniff for removed object identifiers. Relates: #54 --- .../TypoScript/ObjectIdentifier/7.0.yaml | 5 ++ .../TypoScriptObjectIdentifierSniff.php | 86 +++++++++++++++++++ .../Expected.json | 33 +++++++ .../InputFileForIssues.ts | 4 + 4 files changed, 128 insertions(+) create mode 100644 src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml create mode 100644 src/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff.php create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/Expected.json create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml new file mode 100644 index 0000000..33fa3d1 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml @@ -0,0 +1,5 @@ +# Breaking changes in 7.0: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Index.html#breaking-changes +'7.0': + styles.insertContent: + replacement: 'Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html' diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff.php new file mode 100644 index 0000000..d3c6db8 --- /dev/null +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff.php @@ -0,0 +1,86 @@ + + */ + public function register() + { + return [ + TokenInterface::TYPE_OBJECT_IDENTIFIER, + ]; + } + + /** + * Check whether the current token is removed. + * + * @param PhpCsFile $phpcsFile + * @param int $stackPtr + * @return bool + */ + protected function isRemoved(PhpCsFile $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $token = $tokens[$stackPtr]; + $objectIdentifier = $token['content']; + + if (isset($this->configured[$objectIdentifier])) { + $this->removed = [ + $this->configured[$objectIdentifier] + ]; + return true; + } + + return false; + } + + /** + * Identifier for configuring this specific error / warning through PHPCS. + * + * @param array $config + * + * @return string + */ + protected function getIdentifier(array $config) + { + return str_replace('.', '-', $config['name']); + } + + /** + * The original call, to allow user to check matches. + * + * As we match the name, that can be provided by multiple classes, you + * should provide an example, so users can check that this is the legacy + * one. + * + * @param array $config + * + * @return string + */ + protected function getOldUsage(array $config) + { + return $config['name']; + } + + /** + * Return file names containing removed configurations. + * + * @return array + */ + protected function getRemovedConfigFiles() + { + return Options::getRemovedTypoScriptObjectIdentifierConfigFiles(); + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/Expected.json new file mode 100644 index 0000000..f5f9a91 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/Expected.json @@ -0,0 +1,33 @@ +{ + "files": { + "InputFileForIssues.ts": { + "errors": 0, + "messages": [ + { + "column": 10, + "fixable": false, + "line": 2, + "message": "Legacy calls are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScriptObjectIdentifier.styles-insertContent", + "type": "WARNING" + }, + { + "column": 11, + "fixable": false, + "line": 3, + "message": "Legacy calls are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScriptObjectIdentifier.styles-insertContent", + "type": "WARNING" + } + ], + "warnings": 2 + } + }, + "totals": { + "errors": 0, + "fixable": 0, + "warnings": 2 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts new file mode 100644 index 0000000..660a53c --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts @@ -0,0 +1,4 @@ +page { + 10 < styles.insertContent + 10 =< styles.insertContent +} From 154fe435828355bda25a8c5d7269bb77a5be57bb Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 13:39:08 +0200 Subject: [PATCH 027/100] FEATURE: Allow multiple files to be used as insert for tests * Detect file for php and TS out of the box. * Keep old handling to configure file name. * Also detect file format, e.g. TypoScript, and configure phpcs tokenizer accordingly. Relates: #54 --- tests/SniffsTest.php | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/tests/SniffsTest.php b/tests/SniffsTest.php index 2560f1a..a82bebd 100644 --- a/tests/SniffsTest.php +++ b/tests/SniffsTest.php @@ -114,6 +114,12 @@ class SniffsTest extends TestCase */ protected function executeSniff(\SplFileInfo $folder, array $arguments = []) { + $fileName = ''; + if (isset($arguments['inputFileName'])) { + $fileName = $arguments['inputFileName']; + unset($arguments['inputFileName']); + } + $internalArguments = array_merge_recursive([ 'standard' => 'Typo3Update', 'runtime-set' => [ @@ -123,14 +129,11 @@ class SniffsTest extends TestCase ], 'report' => 'json', 'sniffs' => $this->getSniffByFolder($folder), - 'inputFile' => $folder->getRealPath() . DIRECTORY_SEPARATOR . 'InputFileForIssues.php', + 'inputFile' => $this->getInputFile($folder, $fileName), ], $arguments); - if (isset($internalArguments['inputFileName'])) { - $internalArguments['inputFile'] = $folder->getRealPath() - . DIRECTORY_SEPARATOR - . $internalArguments['inputFileName']; - unset($internalArguments['inputFileName']); + if (strpos($internalArguments['inputFile'], '.ts') !== false) { + $internalArguments['extensions'] = 'ts/TypoScript'; } $this->assertEquals( @@ -229,6 +232,35 @@ class SniffsTest extends TestCase return $folder->getRealPath() . DIRECTORY_SEPARATOR . 'Arguments.php'; } + /** + * Get absolute file path to file to use for testing. + * + * @param \SplFileInfo $folder + * @param string $fileName + * @return string + */ + protected function getInputFile(\SplFileInfo $folder, $fileName = '') + { + $folderPath = $folder->getRealPath() . DIRECTORY_SEPARATOR; + $file = $folderPath . $fileName; + + if (!is_file($file)) { + $file = $folderPath . $fileName; + } + if (!is_file($file)) { + $file = $folderPath . 'InputFileForIssues.php'; + } + if (!is_file($file)) { + $file = $folderPath . 'InputFileForIssues.ts'; + } + + if (!is_file($file)) { + throw new \Exception('message', 1492083289); + } + + return $file; + } + /** * Build cli call for phpcs. * From 920c923ed7d9f3e3ab7f7dbe04b865230ec345e4 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 13:40:04 +0200 Subject: [PATCH 028/100] FEATURE: Add missing method to make tests pass. * Retrieve yaml files for removed typoscript object identifier. Relates: #54 --- src/Standards/Typo3Update/Sniffs/Options.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Standards/Typo3Update/Sniffs/Options.php b/src/Standards/Typo3Update/Sniffs/Options.php index c6b5ba7..bae8ef0 100644 --- a/src/Standards/Typo3Update/Sniffs/Options.php +++ b/src/Standards/Typo3Update/Sniffs/Options.php @@ -81,6 +81,19 @@ class Options ); } + /** + * Returns an array of absolute file names containing removed typoscript object identifier configurations. + * + * @return array + */ + public static function getRemovedTypoScriptObjectIdentifierConfigFiles() + { + return static::getOptionFileNames( + 'removedTypoScriptObjectIdentifier', + __DIR__ . '/../Configuration/Removed/TypoScript/ObjectIdentifier/*.yaml' + ); + } + /** * Get the option by optionName, if not defined, use default. * From b394cff3d2429d6542e274da442fd7f160812532 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 13:48:01 +0200 Subject: [PATCH 029/100] TASK: Add new configuration option to docs Relates: #54 --- Documentation/source/configuration.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst index 6209816..df98fb8 100644 --- a/Documentation/source/configuration.rst +++ b/Documentation/source/configuration.rst @@ -156,3 +156,25 @@ Example: .. code:: bash --runtime-set removedConstantConfigFiles "/Some/Absolute/Path/*.yaml" + +.. _configuration-removedTypoScriptObjectIdentifierConfigFiles: + +removedTypoScriptObjectIdentifierConfigFiles +-------------------------------------------- + +Configure where to look for configuration files defining the removed TypoScript object identifiers. +Default is ``Configuration/Removed/TypoScript/ObjectIdentifier/*.yaml`` inside the standard itself. +We already try to deliver as much as possible. Globing is used, so placeholders like ``*`` are +possible, see https://secure.php.net/manual/en/function.glob.php + +Using :file:`ruleset.xml`: + +.. code:: xml + + + +Example: + +.. code:: bash + + --runtime-set removedTypoScriptObjectIdentifierConfigFiles "/Some/Absolute/Path/*.yaml" From e1b3f31c780bfe91490ef97b9df7a2b265f72e63 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 14:20:36 +0200 Subject: [PATCH 030/100] FEATURE: Add second TypoScript check * Extend test to show what's possible and covered and what is not covered yet. Relates: #54 --- .../TypoScript/ObjectIdentifier/7.0.yaml | 3 +++ .../Expected.json | 22 +++++++++++++++++-- .../InputFileForIssues.ts | 15 +++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml index 33fa3d1..505ace8 100644 --- a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml +++ b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml @@ -3,3 +3,6 @@ styles.insertContent: replacement: 'Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html' + mod.web_list.alternateBgColors: + replacement: 'Removed without substitution' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-53658-RemoveAlternateBgColorsOption.html' diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/Expected.json index f5f9a91..e40c7dd 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/Expected.json @@ -20,14 +20,32 @@ "severity": 5, "source": "Typo3Update.Removed.TypoScriptObjectIdentifier.styles-insertContent", "type": "WARNING" + }, + { + "column": 1, + "fixable": false, + "line": 6, + "message": "Legacy calls are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScriptObjectIdentifier.styles-insertContent", + "type": "WARNING" + }, + { + "column": 1, + "fixable": false, + "line": 13, + "message": "Legacy calls are not allowed; found mod.web_list.alternateBgColors. Removed in 7.0. Removed without substitution. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-53658-RemoveAlternateBgColorsOption.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScriptObjectIdentifier.mod-web_list-alternateBgColors", + "type": "WARNING" } ], - "warnings": 2 + "warnings": 4 } }, "totals": { "errors": 0, "fixable": 0, - "warnings": 2 + "warnings": 4 } } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts index 660a53c..3696fb7 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts @@ -2,3 +2,18 @@ page { 10 < styles.insertContent 10 =< styles.insertContent } + +styles.insertContent { + select { + where = colPos=1 + } +} + +# already covered +mod.web_list.alternateBgColors = 1 +# Not covered yet +mod { + web_list { + alternateBgColors = 1 + } +} From 2e7f155b8d7c3d9f35967d16dccdf61bf22edeca Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 14:57:33 +0200 Subject: [PATCH 031/100] TASK: Configure all 7.0 breaking changed for ObjectIdentifier Relates: #54 --- .../TypoScript/ObjectIdentifier/7.0.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml index 505ace8..ad72f4c 100644 --- a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml +++ b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml @@ -6,3 +6,21 @@ mod.web_list.alternateBgColors: replacement: 'Removed without substitution' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-53658-RemoveAlternateBgColorsOption.html' + acronym: + replacement: 'User TSconfig must be modified to refer to "abbreviation" instead of "acronym"' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-54409-RteAcronymButtonRenamedAbbreviation.html' + features.rewrittenPropertyMapper: + replacement: 'it is no longer possible to deactivate the feature. If configured with 1, just remove, otherwise adjust your code.' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + config.notification_email_charset: + replacement: ~ + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62793-RemoveConfigNotification.html' + config.notification_email_encoding: + replacement: ~ + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62793-RemoveConfigNotification.html' + config.notification_email_urlmode: + replacement: ~ + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62793-RemoveConfigNotification.html' + config.uniqueLinkVars: + replacement: 'The setting config.uniqueLinkVars has been removed as the behaviour is now always used' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62888-RemoveUniqueLinkVars.html' From 12fcc704dcaa9bdaac4a6475146b8dbe41f6cd33 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 15:21:59 +0200 Subject: [PATCH 032/100] TASK: Fix php syntax issue * It's not even a warning, but still wrong --- .../Typo3Update/Sniffs/Removed/AbstractGenericUsage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php index 87e5caf..6094bdc 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php @@ -101,7 +101,7 @@ abstract class AbstractGenericUsage implements PhpCsSniff )[0]; $newStructure[$removed]['name'] = $split[1]; } - }; + } } return $newStructure; From ca4d687155081cda0dd4ca82b4ee3e54a09eb0fe Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 15:22:38 +0200 Subject: [PATCH 033/100] FEATURE: Also check TypoScript objects * Not only check paths, but also objects like cObjects. * Update test input for verification. * Add further breaking changes for 7.1 --- .../TypoScript/ObjectIdentifier/7.1.yaml | 26 +++++++++++++++ .../TypoScriptObjectIdentifierSniff.php | 33 ++++++++++++++++++- .../InputFileForIssues.ts | 12 +++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.1.yaml diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.1.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.1.yaml new file mode 100644 index 0000000..183d76b --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.1.yaml @@ -0,0 +1,26 @@ +# Breaking changes in 8.0: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Index.html#breaking-changes +'7.1': + lib.parseFunc_RTE.externalBlocks.blockquote.callRecursive.tagStdWrap.HTMLparser: + replacement: 'It is recommended to fix the margins inside your website CSS. Alternatively, you can re-add the above TypoScript lines to your website TypoScript template (not recommended)' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-44879-CSSStyledContentTypoScriptBlockQuoteInlineStylesRemoved.html' + lib.parseFunc_RTE.externalBlocks.blockquote.callRecursive.tagStdWrap.HTMLparser.tags.blockquote.overrideAttribs: + replacement: 'It is recommended to fix the margins inside your website CSS. Alternatively, you can re-add the above TypoScript lines to your website TypoScript template (not recommended)' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-44879-CSSStyledContentTypoScriptBlockQuoteInlineStylesRemoved.html' + config.meaningfulTempFilePrefix: + replacement: 'All files will always have their original filename fully prepended when stored in the folder typo3temp/GB/. Just remove the setting' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-62886-RemoveMeaningfulTempFilePrefix.html' + new CLEARGIF: + replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content.' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html' + new COLUMNS: + replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content.' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html' + new CTABLE: + replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content.' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html' + new OTABLE: + replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content.' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html' + new HRULER: + replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content.' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html' diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff.php index d3c6db8..0bc61f4 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff.php @@ -19,10 +19,41 @@ class Typo3Update_Sniffs_Removed_TypoScriptObjectIdentifierSniff extends Abstrac public function register() { return [ + TokenInterface::TYPE_OBJECT_CONSTRUCTOR, TokenInterface::TYPE_OBJECT_IDENTIFIER, ]; } + /** + * Prepares structure from config for later usage. + * + * @param array $typo3Versions + * @return array + */ + protected function prepareStructure(array $typo3Versions) + { + $newStructure = []; + + foreach ($typo3Versions as $typo3Version => $removals) { + foreach ($removals as $removed => $config) { + + $config['type'] = TokenInterface::TYPE_OBJECT_IDENTIFIER; + // If starting with new, it's a constructor, meaning content object or other Object. + if (strtolower(substr($removed, 0, 4)) === 'new ') { + $config['type'] = TokenInterface::TYPE_OBJECT_CONSTRUCTOR; + $removed = substr($removed, 4); + } + + $config['name'] = $removed; + $config['version_removed'] = $typo3Version; + + $newStructure[$removed] = $config; + } + } + + return $newStructure; + } + /** * Check whether the current token is removed. * @@ -36,7 +67,7 @@ class Typo3Update_Sniffs_Removed_TypoScriptObjectIdentifierSniff extends Abstrac $token = $tokens[$stackPtr]; $objectIdentifier = $token['content']; - if (isset($this->configured[$objectIdentifier])) { + if (isset($this->configured[$objectIdentifier]) && $token['type'] === $this->configured[$objectIdentifier]['type']) { $this->removed = [ $this->configured[$objectIdentifier] ]; diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts index 3696fb7..3f9b94c 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts @@ -17,3 +17,15 @@ mod { alternateBgColors = 1 } } + +page { + CLEARGIF { + value = test + } + + 10 = CLEARGIF + 11 = COLUMNS + 12 = CTABLE + 13 = OTABLE + 14 = HRULER +} From 3e9d8c01c8a994de145ce16cfa2b545e73d99ae4 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 15:27:25 +0200 Subject: [PATCH 034/100] TASK: Rename TypoScript sniff * As we not only check ObjectIdentifier's anymore, but also further parts, renamce sniff to be more generic. * Also rename configuration and tests accordingly. Relates: #54 --- Documentation/source/configuration.rst | 12 ++++++------ .../TypoScript/{ObjectIdentifier => }/7.0.yaml | 0 .../TypoScript/{ObjectIdentifier => }/7.1.yaml | 0 src/Standards/Typo3Update/Sniffs/Options.php | 8 ++++---- ...ObjectIdentifierSniff.php => TypoScriptSniff.php} | 4 ++-- .../Expected.json | 0 .../InputFileForIssues.ts | 0 7 files changed, 12 insertions(+), 12 deletions(-) rename src/Standards/Typo3Update/Configuration/Removed/TypoScript/{ObjectIdentifier => }/7.0.yaml (100%) rename src/Standards/Typo3Update/Configuration/Removed/TypoScript/{ObjectIdentifier => }/7.1.yaml (100%) rename src/Standards/Typo3Update/Sniffs/Removed/{TypoScriptObjectIdentifierSniff.php => TypoScriptSniff.php} (94%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/{TypoScriptObjectIdentifierSniff => TypoScriptSniff}/Expected.json (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/{TypoScriptObjectIdentifierSniff => TypoScriptSniff}/InputFileForIssues.ts (100%) diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst index df98fb8..cd2812d 100644 --- a/Documentation/source/configuration.rst +++ b/Documentation/source/configuration.rst @@ -157,13 +157,13 @@ Example: --runtime-set removedConstantConfigFiles "/Some/Absolute/Path/*.yaml" -.. _configuration-removedTypoScriptObjectIdentifierConfigFiles: +.. _configuration-removedTypoScriptConfigFiles: -removedTypoScriptObjectIdentifierConfigFiles --------------------------------------------- +removedTypoScriptConfigFiles +---------------------------- Configure where to look for configuration files defining the removed TypoScript object identifiers. -Default is ``Configuration/Removed/TypoScript/ObjectIdentifier/*.yaml`` inside the standard itself. +Default is ``Configuration/Removed/TypoScript/*.yaml`` inside the standard itself. We already try to deliver as much as possible. Globing is used, so placeholders like ``*`` are possible, see https://secure.php.net/manual/en/function.glob.php @@ -171,10 +171,10 @@ Using :file:`ruleset.xml`: .. code:: xml - + Example: .. code:: bash - --runtime-set removedTypoScriptObjectIdentifierConfigFiles "/Some/Absolute/Path/*.yaml" + --runtime-set removedTypoScriptConfigFiles "/Some/Absolute/Path/*.yaml" diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.0.yaml similarity index 100% rename from src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.0.yaml rename to src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.0.yaml diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.1.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml similarity index 100% rename from src/Standards/Typo3Update/Configuration/Removed/TypoScript/ObjectIdentifier/7.1.yaml rename to src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml diff --git a/src/Standards/Typo3Update/Sniffs/Options.php b/src/Standards/Typo3Update/Sniffs/Options.php index bae8ef0..cc79f7b 100644 --- a/src/Standards/Typo3Update/Sniffs/Options.php +++ b/src/Standards/Typo3Update/Sniffs/Options.php @@ -82,15 +82,15 @@ class Options } /** - * Returns an array of absolute file names containing removed typoscript object identifier configurations. + * Returns an array of absolute file names containing removed typoscript. * * @return array */ - public static function getRemovedTypoScriptObjectIdentifierConfigFiles() + public static function getRemovedTypoScriptConfigFiles() { return static::getOptionFileNames( - 'removedTypoScriptObjectIdentifier', - __DIR__ . '/../Configuration/Removed/TypoScript/ObjectIdentifier/*.yaml' + 'removedTypoScript', + __DIR__ . '/../Configuration/Removed/TypoScript/*.yaml' ); } diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php similarity index 94% rename from src/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff.php rename to src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php index 0bc61f4..f812edb 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php @@ -5,7 +5,7 @@ use PHP_CodeSniffer_File as PhpCsFile; use Typo3Update\Sniffs\Options; use Typo3Update\Sniffs\Removed\AbstractGenericUsage; -class Typo3Update_Sniffs_Removed_TypoScriptObjectIdentifierSniff extends AbstractGenericUsage +class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage { public $supportedTokenizers = [ 'TYPOSCRIPT', @@ -112,6 +112,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptObjectIdentifierSniff extends Abstrac */ protected function getRemovedConfigFiles() { - return Options::getRemovedTypoScriptObjectIdentifierConfigFiles(); + return Options::getRemovedTypoScriptConfigFiles(); } } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/InputFileForIssues.ts similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptObjectIdentifierSniff/InputFileForIssues.ts rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/InputFileForIssues.ts From 7c5d95d0e0a0cd40a6f9fbcc0fa56bbf2d804627 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 15:30:42 +0200 Subject: [PATCH 035/100] TASK: Update test * Make sure test is running again with new additions of cObjects. * Also fix description containing dot at the end. Relates: #54 --- .../Configuration/Removed/TypoScript/7.1.yaml | 10 ++-- .../Removed/TypoScriptSniff/Expected.json | 57 +++++++++++++++++-- 2 files changed, 56 insertions(+), 11 deletions(-) diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml index 183d76b..4433df2 100644 --- a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml +++ b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml @@ -10,17 +10,17 @@ replacement: 'All files will always have their original filename fully prepended when stored in the folder typo3temp/GB/. Just remove the setting' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-62886-RemoveMeaningfulTempFilePrefix.html' new CLEARGIF: - replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content.' + replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html' new COLUMNS: - replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content.' + replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html' new CTABLE: - replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content.' + replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html' new OTABLE: - replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content.' + replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html' new HRULER: - replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content.' + replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html' diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json index e40c7dd..ff6e6bd 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json @@ -9,7 +9,7 @@ "line": 2, "message": "Legacy calls are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html", "severity": 5, - "source": "Typo3Update.Removed.TypoScriptObjectIdentifier.styles-insertContent", + "source": "Typo3Update.Removed.TypoScript.styles-insertContent", "type": "WARNING" }, { @@ -18,7 +18,7 @@ "line": 3, "message": "Legacy calls are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html", "severity": 5, - "source": "Typo3Update.Removed.TypoScriptObjectIdentifier.styles-insertContent", + "source": "Typo3Update.Removed.TypoScript.styles-insertContent", "type": "WARNING" }, { @@ -27,7 +27,7 @@ "line": 6, "message": "Legacy calls are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html", "severity": 5, - "source": "Typo3Update.Removed.TypoScriptObjectIdentifier.styles-insertContent", + "source": "Typo3Update.Removed.TypoScript.styles-insertContent", "type": "WARNING" }, { @@ -36,16 +36,61 @@ "line": 13, "message": "Legacy calls are not allowed; found mod.web_list.alternateBgColors. Removed in 7.0. Removed without substitution. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-53658-RemoveAlternateBgColorsOption.html", "severity": 5, - "source": "Typo3Update.Removed.TypoScriptObjectIdentifier.mod-web_list-alternateBgColors", + "source": "Typo3Update.Removed.TypoScript.mod-web_list-alternateBgColors", + "type": "WARNING" + }, + { + "column": 10, + "fixable": false, + "line": 26, + "message": "Legacy calls are not allowed; found CLEARGIF. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScript.CLEARGIF", + "type": "WARNING" + }, + { + "column": 10, + "fixable": false, + "line": 27, + "message": "Legacy calls are not allowed; found COLUMNS. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScript.COLUMNS", + "type": "WARNING" + }, + { + "column": 10, + "fixable": false, + "line": 28, + "message": "Legacy calls are not allowed; found CTABLE. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScript.CTABLE", + "type": "WARNING" + }, + { + "column": 10, + "fixable": false, + "line": 29, + "message": "Legacy calls are not allowed; found OTABLE. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScript.OTABLE", + "type": "WARNING" + }, + { + "column": 10, + "fixable": false, + "line": 30, + "message": "Legacy calls are not allowed; found HRULER. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScript.HRULER", "type": "WARNING" } ], - "warnings": 4 + "warnings": 9 } }, "totals": { "errors": 0, "fixable": 0, - "warnings": 4 + "warnings": 9 } } From 74eb4dde20fe47813a93b089c657559cba8223b1 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 15:44:52 +0200 Subject: [PATCH 036/100] TASK: Document yaml structure * To ease contributions and modifications Relates: #54 --- Documentation/source/configuration.rst | 103 +++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 7 deletions(-) diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst index cd2812d..106ee94 100644 --- a/Documentation/source/configuration.rst +++ b/Documentation/source/configuration.rst @@ -1,3 +1,4 @@ +.. _highlight: yaml .. _configuration: Configuration @@ -7,6 +8,13 @@ Configuration is done through PHPCS Standards, e.g. provide a custom :file:`rule project using a :file:`phpcs.xml.dist`. As this is just a PHPCS-Standard, the official documentation applies. +Also some configuration is done through yaml files, see :ref:`configuration-yaml-files`. + +.. _configuration-options: + +Options +------- + All options available in :file:`ruleset.xml` are also available in your :file:`phpcs.xml` files, as already documented by phpcs itself. Therefore this documentation will just mention :file:`ruleset.xml`. @@ -22,7 +30,7 @@ The following configuration options are available: .. _configuration-legacyExtensions: legacyExtensions ----------------- +^^^^^^^^^^^^^^^^ Configures which extension names are legacy. Used to provide further checks and warnings about possible legacy code. All class usages starting with ``Tx_`` where ExtensionName is @@ -44,7 +52,7 @@ Example: .. _configuration-allowedTags: allowedTags ------------ +^^^^^^^^^^^ Only used inside Sniff ``Typo3Update.LegacyClassnames.DocComment``. @@ -66,7 +74,7 @@ Example: .. _configuration-mappingFile: mappingFile ------------ +^^^^^^^^^^^ For auto migrating usages of old class names, a PHP file with a mapping is required. The file has to be in the composer structure :file:`autoload_classaliasmap.php`. @@ -91,7 +99,7 @@ Using ``runtime-set``: .. _configuration-vendor: vendor ------- +^^^^^^ Used while adding namespaces to legacy class definitions and updating plugin and module registrations. Default is ``YourCompany`` to enable you to search and replace afterwards. @@ -115,7 +123,7 @@ Example: .. _configuration-removedFunctionConfigFiles: removedFunctionConfigFiles --------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^ Configure where to look for configuration files defining the removed functions and methods. Default is ``Configuration/Removed/Functions/*.yaml`` inside the standard itself. We already try to deliver @@ -138,7 +146,7 @@ Example: .. _configuration-removedConstantConfigFiles: removedConstantConfigFiles --------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^ Configure where to look for configuration files defining the removed constants. Default is ``Configuration/Removed/Functions/*.yaml`` inside the standard itself. We already try to deliver as @@ -160,7 +168,7 @@ Example: .. _configuration-removedTypoScriptConfigFiles: removedTypoScriptConfigFiles ----------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Configure where to look for configuration files defining the removed TypoScript object identifiers. Default is ``Configuration/Removed/TypoScript/*.yaml`` inside the standard itself. @@ -178,3 +186,84 @@ Example: .. code:: bash --runtime-set removedTypoScriptConfigFiles "/Some/Absolute/Path/*.yaml" + +.. _configuration-yaml-files: + +YAML Files +---------- + +YAML files are used to configure removed constants, function / methods and TypoScript. We decided to +go with yaml files here, to ease adding stuff in the future. It's a simple format and everyone can +contribute. + +You can configure the paths to look up the files through the specific options, documented above. + +This section will cover the structure of the various yaml files. + +General structure +^^^^^^^^^^^^^^^^^ + +The basic structure is the same for all parts. Inside a file you have to provide an array for each +TYPO3 version:: + + '7.0': + styles.insertContent: + replacement: 'Either remove usage of styles.insertContent or a...' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0...' + '7.1': + \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->includeTCA: + replacement: 'Full TCA is always loaded during bootstrap in ...' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7...' + +In above example the TypoScript ``styles.insertContent`` was removed in TYPO3 version *7.0*. +Below a TYPO3 version each entry is a removed function or TypoScript part of TYPO3. The key is used +to lookup matchings in the source code. Specific parsing is documented below. + +All entries consists of a ``replacement`` and ``docsUrl`` entry. + +The ``replacement`` can either be ``null`` or a string. If it's null we will show that this part is +removed without any replacement. +If you provide a string, this will be displayed to help during migrations. + +The ``docsUrl`` is displayed in addition, so everyone can take a deeper look at the change, the +effects and how to migrate. + +Also the TYPO3 core team references the forge issues in each change, where you can find the pull +requests. + +Constants and Functions +^^^^^^^^^^^^^^^^^^^^^^^ + +Special parsing is done for the keys identifying removed constants and functions. + +Always provide the fully qualified class namespace. Seperate the constant or method by ``::`` if +it's possible to access it static, otherwise use ``->`` to indicate it's an instance method. + +This is used to check only matching calls. + +Two examples:: + + '7.0': + \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA: + replacement: null + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Ch...' + \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->includeTCA: + replacement: 'Full TCA is always loaded during bootstrap in FE, th...' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Change...' + +TypoScript +^^^^^^^^^^ + +Use ``new`` in front of, to declare the entry as OBJECT, e.g. a cObject. +Only matching types will be checked in source code. + +Two examples:: + + '7.0': + styles.insertContent: + replacement: 'Either remove usage of styles.insertContent or add a sni...' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog...' + '7.1': + new HRULER: + replacement: 'Any installation should migrate to alternatives such as F...' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog...' From 5387e553c57ea7bb208f826a2fb5b45a88277d8f Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 15:51:01 +0200 Subject: [PATCH 037/100] TASK: Add remaining TypoScript changes for 7.1 Relates: #54 --- .../Configuration/Removed/TypoScript/7.1.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml index 4433df2..a0079d5 100644 --- a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml +++ b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml @@ -24,3 +24,12 @@ new HRULER: replacement: 'Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html' + new FORM: + replacement: 'For TYPO3 CMS 7, installing EXT:compatibility6 brings back the existing functionality. For the long term the affected installations should migrate to a different, better suited solution for sending mails and building forms' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64668-MailformMovedToLegacyExtension.html' + new IMGTEXT: + replacement: 'Any installation should migrate to alternatives such as CSS Styled Content without a table-based rendering for text w/ image elements to customize the output of content' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64671-ContentObjectImgTextMovedToLegacyExtension.html' + new SEARCHRESULTS: + replacement: 'For TYPO3 CMS 7, installing EXT:compatibility6 brings back the existing functionality. For the long term the affected installations should be migrate to a better suited solution for searching' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64696-MoveSearchCTypeToLegacyExtension.html' From 6e602cf5f5e148f987de36e70d6de1b58efcb753 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 16:02:40 +0200 Subject: [PATCH 038/100] TASK: Add all remaining TypoScripts Resolves: #54 --- .../Configuration/Removed/TypoScript/7.1.yaml | 2 +- .../Configuration/Removed/TypoScript/7.2.yaml | 23 +++++++++++++++++++ .../Configuration/Removed/TypoScript/7.4.yaml | 14 +++++++++++ .../Configuration/Removed/TypoScript/7.6.yaml | 5 ++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.2.yaml create mode 100644 src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.4.yaml create mode 100644 src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.6.yaml diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml index a0079d5..18d7192 100644 --- a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml +++ b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.1.yaml @@ -1,4 +1,4 @@ -# Breaking changes in 8.0: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Index.html#breaking-changes +# Breaking changes in 7.1: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Index.html#breaking-changes '7.1': lib.parseFunc_RTE.externalBlocks.blockquote.callRecursive.tagStdWrap.HTMLparser: replacement: 'It is recommended to fix the margins inside your website CSS. Alternatively, you can re-add the above TypoScript lines to your website TypoScript template (not recommended)' diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.2.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.2.yaml new file mode 100644 index 0000000..f1afb7b --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.2.yaml @@ -0,0 +1,23 @@ +# Breaking changes in 7.2: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Index.html#breaking-changes +'7.2': + mod.web_info.menu.function.tx_cms_webinfo_page: + replacement: 'Renamed to mod.web_info.menu.function.TYPO3\CMS\Frontend\Controller\PageInformationController' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-66286-PageTSconfigOptionsToHideWebInfoModulesRenamed.html' + mod.web_info.menu.function.tx_cms_webinfo_lang: + replacement: 'Renamed to mod.web_info.menu.function.TYPO3\CMS\Frontend\Controller\TranslationStatusController' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-66286-PageTSconfigOptionsToHideWebInfoModulesRenamed.html' + mod.web_info.menu.function.tx_belog_webinfo: + replacement: 'Renamed to mod.web_info.menu.function.TYPO3\CMS\Belog\Module\BackendLogModuleBootstrap' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-66286-PageTSconfigOptionsToHideWebInfoModulesRenamed.html' + mod.web_info.menu.function.tx_infopagetsconfig_webinfo: + replacement: 'Renamed to mod.web_info.menu.function.TYPO3\CMS\InfoPagetsconfig\Controller\InfoPageTyposcriptConfigController' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-66286-PageTSconfigOptionsToHideWebInfoModulesRenamed.html' + mod.web_info.menu.function.tx_linkvalidator_ModFuncReport: + replacement: 'Renamed to mod.web_info.menu.function.TYPO3\CMS\Linkvalidator\Report\LinkValidatorReport' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-66286-PageTSconfigOptionsToHideWebInfoModulesRenamed.html' + mod.web_info.menu.function.tx_indexedsearch_modfunc1: + replacement: 'removed, indexed_search has its own module' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-66286-PageTSconfigOptionsToHideWebInfoModulesRenamed.html' + mod.web_info.menu.function.tx_indexedsearch_modfunc2: + replacement: 'removed, indexed_search has its own module' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-66286-PageTSconfigOptionsToHideWebInfoModulesRenamed.html' diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.4.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.4.yaml new file mode 100644 index 0000000..a879ace --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.4.yaml @@ -0,0 +1,14 @@ +# Breaking changes in 7.4: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Index.html#breaking-changes +'7.4': + page.javascriptLibs.Prototype: + replacement: ~ + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-39721-PrototypejsAndScriptaculousRemoved.html' + page.javascriptLibs.Scriptaculous: + replacement: ~ + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-39721-PrototypejsAndScriptaculousRemoved.html' + page.javascriptLibs.Scriptaculous.modules: + replacement: ~ + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-39721-PrototypejsAndScriptaculousRemoved.html' + RTE.userLinks: + replacement: 'Use the newly added Tabbing API to add your custom link selection tab' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-68116-DropRTEuserLinksFunctionality.html' diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.6.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.6.yaml new file mode 100644 index 0000000..3396b79 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/TypoScript/7.6.yaml @@ -0,0 +1,5 @@ +# Breaking changes in 7.6: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Index.html#breaking-changes +'7.6': + plugin.tx_indexedsearch.settings.showRules: + replacement: 'Use to plugin.tx_indexedsearch.settings.displayRules = 0 instead' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-51099-StreamlineSettingsConditions.html' From 498e00c6f065ecebb4ff3f949fe2bbe35750ffa1 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 16:05:34 +0200 Subject: [PATCH 039/100] TASK: Add missing phpdoc --- .../Typo3Update/Sniffs/Removed/TypoScriptSniff.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php index f812edb..663ed95 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php @@ -5,8 +5,15 @@ use PHP_CodeSniffer_File as PhpCsFile; use Typo3Update\Sniffs\Options; use Typo3Update\Sniffs\Removed\AbstractGenericUsage; +/** + * Check usage of removed or breaking changed TypoScript. + */ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage { + /** + * Register sniff only for TypoScript. + * @var array + */ public $supportedTokenizers = [ 'TYPOSCRIPT', ]; From aabb7a50590ce9b1c29db023459b9ca527aa955a Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 16:11:04 +0200 Subject: [PATCH 040/100] TASK: Generate multiple reports * As no further calls are made once a call failed. * Therefore call all reports in a single command. --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 70cce9b..ef77fbd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,8 +30,7 @@ lint:coding-guideline: image: php:7.0-alpine stage: test script: - - ./vendor/bin/phpcs -s -n - - ./vendor/bin/phpcs -s -n > result/phpcs-summary.txt + - ./vendor/bin/phpcs -s -n --report-full=result/phpcs-full.txt --report-diff=result/phpcs-diff.txt --report-summary=result/phpcs-summary.txt artifacts: when: on_failure paths: From 7ed37db05ff0a1597e60d7e6c2ff5ab4d244071e Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 16:12:46 +0200 Subject: [PATCH 041/100] TASK: Only generate one report * As second report is not necessary and won't be generated since the first call will return exit > 0 --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef77fbd..b32aa5b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,7 +41,6 @@ lint:php-mass-detection: stage: test script: - ./vendor/bin/phpmd src text phpmd.xml > result/phpmd.txt - - ./vendor/bin/phpmd src html phpmd.xml > result/phpmd.html artifacts: when: on_failure paths: From af43a99bfded63868ebaf64590ea136963566d9e Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 16:13:16 +0200 Subject: [PATCH 042/100] TASK: Use yaml references * Don't repeat yourself. * Make file shorter and easier to read. * Also make it easier to change something. --- .gitlab-ci.yml | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b32aa5b..88d1918 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,7 +26,7 @@ sync:github: - cd mirror - git push --mirror ${MIRROR_GIT_URL} -lint:coding-guideline: +lint:coding-guideline: &PHP-LINTING image: php:7.0-alpine stage: test script: @@ -37,34 +37,25 @@ lint:coding-guideline: - result lint:php-mass-detection: - image: php:7.0-alpine - stage: test + <<: *PHP-LINTING script: - ./vendor/bin/phpmd src text phpmd.xml > result/phpmd.txt - artifacts: - when: on_failure - paths: - - result -test:5.6: +test:5.6: &PHP-UNITTESTING image: php:5.6-alpine stage: test script: - ./vendor/bin/phpunit test:7.0: + <<: *PHP-UNITTESTING image: php:7.0-alpine - stage: test - script: - - ./vendor/bin/phpunit test:latest: + <<: *PHP-UNITTESTING image: php:7-alpine - stage: test - script: - - ./vendor/bin/phpunit -test:documentation:syntax: +test:documentation:syntax: &SPHINX-DOCS image: 'danielsiepmann/sphinx:latest' stage: test before_script: @@ -73,18 +64,13 @@ test:documentation:syntax: - make dummy test:documentation:external-links: - image: 'danielsiepmann/sphinx:latest' - stage: test - before_script: - - cd Documentation + <<: *SPHINX-DOCS script: - make linkcheck render:documentation: - image: 'danielsiepmann/sphinx:latest' + <<: *SPHINX-DOCS stage: render - before_script: - - cd Documentation script: - make html artifacts: From 42e04617bcca3c5656ec1c64a68a72d9b116916f Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 16:14:56 +0200 Subject: [PATCH 043/100] BUGFIX: CGL issue * Follow CGL and fix issue. --- src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php index 663ed95..cbf034a 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php @@ -43,7 +43,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage foreach ($typo3Versions as $typo3Version => $removals) { foreach ($removals as $removed => $config) { - $config['type'] = TokenInterface::TYPE_OBJECT_IDENTIFIER; // If starting with new, it's a constructor, meaning content object or other Object. if (strtolower(substr($removed, 0, 4)) === 'new ') { From 0b7828e6c5d4aa6b906d3a03a5a9cc7616bd990c Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 13 Apr 2017 19:06:30 +0200 Subject: [PATCH 044/100] TASK: Remove no longer used .scrutinizer.yml * As we don't use Scrutinizer any longer, but our own CI on gitlab. --- .scrutinizer.yml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .scrutinizer.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 6635d55..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,13 +0,0 @@ -build: - tests: - before: - - make install - environment: - php: - version: 5.6 - ini: - 'date.timezone': 'Europe/Berlin' - -filter: - excluded_paths: - - "tests/Fixtures/" From b502e5292097cea9df3d9bc1d6e1c7eacec9e414 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 08:20:08 +0200 Subject: [PATCH 045/100] TASK: Add missing license * Add license to file. --- .../Sniffs/Removed/TypoScriptSniff.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php index cbf034a..257d5c2 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php @@ -1,5 +1,24 @@ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + use Helmich\TypoScriptParser\Tokenizer\TokenInterface; use PHP_CodeSniffer_File as PhpCsFile; use Typo3Update\Sniffs\Options; From 2f6dc2304a40e918f992c8d461d51eced75c9663 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 12:58:19 +0200 Subject: [PATCH 046/100] WIP: Refactor code to new architecture * Migrate class names. * Add new architecture of "Features". * Configure old assignments for new features. * Rename necessary parts. Relates: #72 --- .../Features/LegacyClassnames.yaml | 15 +++ .../LegacyClassnameFeature.php} | 95 ++++++------------- .../LegacyClassnameMapping.php} | 8 +- .../Typo3Update/FeatureInterface.php | 40 ++++++++ src/Standards/Typo3Update/Features.php | 69 ++++++++++++++ src/Standards/Typo3Update/FeaturesSupport.php | 53 +++++++++++ .../Typo3Update/{Sniffs => }/Options.php | 27 +++++- .../Classname/AbstractClassnameChecker.php | 77 +++++++++++++++ .../InheritanceSniff.php | 7 +- .../InlineCommentSniff.php | 6 +- .../InstanceofSniff.php | 4 +- .../InstantiationWithMakeInstanceSniff.php | 6 +- .../InstantiationWithNewSniff.php | 4 +- .../InstantiationWithObjectManagerSniff.php | 20 +--- .../IsACallSniff.php | 20 +--- .../MissingNamespaceSniff.php | 9 +- .../PhpDocCommentSniff.php} | 41 ++------ .../StaticCallSniff.php | 4 +- .../TypeHintCatchExceptionSniff.php | 4 +- .../TypeHintSniff.php | 6 +- .../UseSniff.php | 23 +---- ...MissingVendorForPluginsAndModulesSniff.php | 4 +- .../Sniffs/Removed/AbstractGenericUsage.php | 2 +- .../Removed/GenericConstantUsageSniff.php | 2 +- .../Removed/GenericFunctionCallSniff.php | 2 +- src/Standards/Typo3Update/ruleset.xml | 6 +- .../InheritanceSniff/Expected.diff | 0 .../InheritanceSniff/Expected.json | 12 +-- .../InheritanceSniff/InputFileForIssues.php | 0 .../InlineCommentSniff/Expected.diff | 0 .../InlineCommentSniff/Expected.json | 8 +- .../InlineCommentSniff/InputFileForIssues.php | 0 .../InstanceofSniff/Expected.diff | 0 .../InstanceofSniff/Expected.json | 2 +- .../InstanceofSniff/InputFileForIssues.php | 0 .../Expected.diff | 0 .../Expected.json | 2 +- .../InputFileForIssues.php | 0 .../InstantiationWithNewSniff/Expected.diff | 0 .../InstantiationWithNewSniff/Expected.json | 12 +-- .../InputFileForIssues.php | 0 .../Expected.diff | 0 .../Expected.json | 8 +- .../InputFileForIssues.php | 0 .../IsACallSniff/Expected.diff | 0 .../IsACallSniff/Expected.json | 4 +- .../IsACallSniff/InputFileForIssues.php | 0 .../MissingNamespaceSniff/Arguments.php | 0 .../customVendor/Expected.diff | 0 .../customVendor}/Expected.json | 2 +- .../customVendor/InputFileForIssues.php | 0 .../defaultVendor/Expected.diff | 0 .../defaultVendor}/Expected.json | 2 +- .../defaultVendor/InputFileForIssues.php | 0 .../PhpDocCommentSniff}/Expected.diff | 2 +- .../PhpDocCommentSniff}/Expected.json | 8 +- .../InputFileForIssues.php | 0 .../StaticCallSniff/Expected.diff | 0 .../StaticCallSniff/Expected.json | 12 +-- .../StaticCallSniff/InputFileForIssues.php | 0 .../TypeHintCatchExceptionSniff/Expected.diff | 0 .../TypeHintCatchExceptionSniff/Expected.json | 4 +- .../InputFileForIssues.php | 0 .../TypeHintSniff/Expected.diff | 0 .../TypeHintSniff/Expected.json | 12 +-- .../TypeHintSniff/InputFileForIssues.php | 0 .../UseSniff/Expected.diff | 0 .../UseSniff/Expected.json | 4 +- .../UseSniff/InputFileForIssues.php | 0 .../Arguments.php | 0 .../customVendor/Expected.diff | 0 .../customVendor/Expected.json | 12 +-- .../customVendor/InputFileForIssues.php | 0 .../defaultVendor/Expected.diff | 0 .../defaultVendor/Expected.json | 12 +-- .../defaultVendor/InputFileForIssues.php | 0 76 files changed, 419 insertions(+), 253 deletions(-) create mode 100644 src/Standards/Typo3Update/Configuration/Features/LegacyClassnames.yaml rename src/Standards/Typo3Update/{Sniffs/LegacyClassnames/AbstractClassnameChecker.php => Feature/LegacyClassnameFeature.php} (77%) rename src/Standards/Typo3Update/{Sniffs/LegacyClassnames/Mapping.php => Feature/LegacyClassnameMapping.php} (95%) create mode 100644 src/Standards/Typo3Update/FeatureInterface.php create mode 100644 src/Standards/Typo3Update/Features.php create mode 100644 src/Standards/Typo3Update/FeaturesSupport.php rename src/Standards/Typo3Update/{Sniffs => }/Options.php (82%) create mode 100644 src/Standards/Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InheritanceSniff.php (92%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InlineCommentSniff.php (92%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstanceofSniff.php (87%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstantiationWithMakeInstanceSniff.php (91%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstantiationWithNewSniff.php (86%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstantiationWithObjectManagerSniff.php (77%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/IsACallSniff.php (75%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/MissingNamespaceSniff.php (93%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames/DocCommentSniff.php => Classname/PhpDocCommentSniff.php} (64%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/StaticCallSniff.php (89%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/TypeHintCatchExceptionSniff.php (86%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/TypeHintSniff.php (89%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/UseSniff.php (60%) rename src/Standards/Typo3Update/Sniffs/{LegacyClassnames => LegacyClassname}/MissingVendorForPluginsAndModulesSniff.php (96%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InheritanceSniff/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InheritanceSniff/Expected.json (82%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InheritanceSniff/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InlineCommentSniff/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InlineCommentSniff/Expected.json (83%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InlineCommentSniff/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstanceofSniff/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstanceofSniff/Expected.json (87%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstanceofSniff/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstantiationWithMakeInstanceSniff/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstantiationWithMakeInstanceSniff/Expected.json (85%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstantiationWithMakeInstanceSniff/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstantiationWithNewSniff/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstantiationWithNewSniff/Expected.json (81%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstantiationWithNewSniff/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstantiationWithObjectManagerSniff/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstantiationWithObjectManagerSniff/Expected.json (80%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/InstantiationWithObjectManagerSniff/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/IsACallSniff/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/IsACallSniff/Expected.json (84%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/IsACallSniff/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/MissingNamespaceSniff/Arguments.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/MissingNamespaceSniff/customVendor/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames/MissingNamespaceSniff/defaultVendor => Classname/MissingNamespaceSniff/customVendor}/Expected.json (86%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/MissingNamespaceSniff/customVendor/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/MissingNamespaceSniff/defaultVendor/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames/MissingNamespaceSniff/customVendor => Classname/MissingNamespaceSniff/defaultVendor}/Expected.json (86%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/MissingNamespaceSniff/defaultVendor/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames/DocCommentSniff => Classname/PhpDocCommentSniff}/Expected.diff (89%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames/DocCommentSniff => Classname/PhpDocCommentSniff}/Expected.json (83%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames/DocCommentSniff => Classname/PhpDocCommentSniff}/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/StaticCallSniff/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/StaticCallSniff/Expected.json (82%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/StaticCallSniff/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/TypeHintCatchExceptionSniff/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/TypeHintCatchExceptionSniff/Expected.json (82%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/TypeHintCatchExceptionSniff/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/TypeHintSniff/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/TypeHintSniff/Expected.json (83%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/TypeHintSniff/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/UseSniff/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/UseSniff/Expected.json (86%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => Classname}/UseSniff/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => LegacyClassname}/MissingVendorForPluginsAndModulesSniff/Arguments.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => LegacyClassname}/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => LegacyClassname}/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.json (79%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => LegacyClassname}/MissingVendorForPluginsAndModulesSniff/customVendor/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => LegacyClassname}/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.diff (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => LegacyClassname}/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.json (79%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{LegacyClassnames => LegacyClassname}/MissingVendorForPluginsAndModulesSniff/defaultVendor/InputFileForIssues.php (100%) diff --git a/src/Standards/Typo3Update/Configuration/Features/LegacyClassnames.yaml b/src/Standards/Typo3Update/Configuration/Features/LegacyClassnames.yaml new file mode 100644 index 0000000..c510db2 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Features/LegacyClassnames.yaml @@ -0,0 +1,15 @@ +Typo3Update\Feature\LegacyClassnameFeature: + - Typo3Update_Sniffs_Classname_InheritanceSniff + - Typo3Update_Sniffs_Classname_InlineCommentSniff + - Typo3Update_Sniffs_Classname_InstanceofSniff + - Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff + - Typo3Update_Sniffs_Classname_InstantiationWithNewSniff + - Typo3Update_Sniffs_Classname_InstantiationWithObjectManagerSniff + - Typo3Update_Sniffs_Classname_IsACallSniff + - Typo3Update_Sniffs_Classname_MissingNamespaceSniff + - Typo3Update_Sniffs_Classname_MissingVendorForPluginsAndModulesSniff + - Typo3Update_Sniffs_Classname_PhpDocCommentSniff + - Typo3Update_Sniffs_Classname_StaticCallSniff + - Typo3Update_Sniffs_Classname_TypeHintCatchExceptionSniff + - Typo3Update_Sniffs_Classname_TypeHintSniff + - Typo3Update_Sniffs_Classname_UseSniff diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/AbstractClassnameChecker.php b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php similarity index 77% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/AbstractClassnameChecker.php rename to src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php index 76c3cfe..70b5cf5 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/AbstractClassnameChecker.php +++ b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php @@ -1,5 +1,5 @@ @@ -23,12 +23,13 @@ namespace Typo3Update\Sniffs\LegacyClassnames; use PHP_CodeSniffer as PhpCs; use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Sniff as PhpCsSniff; -use Typo3Update\Sniffs\LegacyClassnames\Mapping; +use Typo3Update\FeatureInterface; +use Typo3Update\Feature\LegacyClassnameMapping; /** - * Provide common uses for all sniffs, regarding class name checks. + * */ -abstract class AbstractClassnameChecker implements PhpCsSniff +class LegacyClassnameFeature implements FeatureInterface { /** * A list of extension names that might contain legacy class names. @@ -41,7 +42,7 @@ abstract class AbstractClassnameChecker implements PhpCsSniff public $legacyExtensions = ['Extbase', 'Fluid']; /** - * @var Mapping + * @var LegacyClassnameMapping */ protected $legacyMapping; @@ -56,51 +57,37 @@ abstract class AbstractClassnameChecker implements PhpCsSniff public function __construct() { - $this->legacyMapping = Mapping::getInstance(); + $this->legacyMapping = LegacyClassnameMapping::getInstance(); } /** - * Define whether the T_STRING default behaviour should be checked before - * or after the $stackPtr. + * Process like a PHPCS Sniff. * - * @return bool - */ - protected function shouldLookBefore() - { - return false; - } - - /** - * Processes the tokens that this sniff is interested in. - * - * This is the default implementation, as most of the time next T_STRING is - * the class name. This way only the register method has to be registered - * in default cases. - * - * @param PhpCsFile $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. + * @param PhpCsFile $phpcsFile + * @param int $classnamePosition + * @param string $classname * * @return void - * - * @SuppressWarnings(PHPMD.ElseExpression) This is for performance reason. */ - public function process(PhpCsFile $phpcsFile, $stackPtr) + public function process(PhpCsFile $phpcsFile, $classnamePosition, $classname) { - $tokens = $phpcsFile->getTokens(); + $classname = trim($classname, '\\\'"'); // Remove trailing slash, and quotes. + $this->addMaybeWarning($phpcsFile, $classnamePosition, $classname); - if ($this->shouldLookBefore()) { - $classnamePosition = $phpcsFile->findPrevious(T_STRING, $stackPtr); - } else { - $classnamePosition = $phpcsFile->findNext(T_STRING, $stackPtr); - } - - if ($classnamePosition === false) { + if ($this->isLegacyClassname($classname) === false) { return; } - $classname = $tokens[$classnamePosition]['content']; - $this->addFixableError($phpcsFile, $classnamePosition, $classname); + $fix = $phpcsFile->addFixableError( + 'Legacy classes are not allowed; found "%s", use "%s" instead', + $classnamePosition, + 'legacyClassname', + [$classname, $this->getNewClassname($classname)] + ); + + if ($fix === true) { + $this->replaceLegacyClassname($phpcsFile, $classnamePosition, $classname); + } } /** @@ -122,7 +109,7 @@ abstract class AbstractClassnameChecker implements PhpCsSniff * @param string $classname * @return bool */ - private function isMaybeLegacyClassname($classname) + protected function isMaybeLegacyClassname($classname) { if (strpos($classname, 'Tx_') === false) { return false; @@ -163,34 +150,6 @@ abstract class AbstractClassnameChecker implements PhpCsSniff $this->legacyMapping->addLegacyClassname($legacyClassname, $newClassname); } - /** - * Add an fixable error if given $classname is legacy. - * - * @param PhpCsFile $phpcsFile - * @param int $classnamePosition - * @param string $classname - */ - public function addFixableError(PhpCsFile $phpcsFile, $classnamePosition, $classname) - { - $classname = trim($classname, '\\\'"'); // Remove trailing slash, and quotes. - $this->addMaybeWarning($phpcsFile, $classnamePosition, $classname); - - if ($this->isLegacyClassname($classname) === false) { - return; - } - - $fix = $phpcsFile->addFixableError( - 'Legacy classes are not allowed; found "%s", use "%s" instead', - $classnamePosition, - 'legacyClassname', - [$classname, $this->getNewClassname($classname)] - ); - - if ($fix === true) { - $this->replaceLegacyClassname($phpcsFile, $classnamePosition, $classname); - } - } - /** * Add an warning if given $classname is maybe legacy. * @@ -198,7 +157,7 @@ abstract class AbstractClassnameChecker implements PhpCsSniff * @param int $classnamePosition * @param string $classname */ - private function addMaybeWarning(PhpCsFile $phpcsFile, $classnamePosition, $classname) + protected function addMaybeWarning(PhpCsFile $phpcsFile, $classnamePosition, $classname) { if ($this->isLegacyClassname($classname) || $this->isMaybeLegacyClassname($classname) === false) { return; diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/Mapping.php b/src/Standards/Typo3Update/Feature/LegacyClassnameMapping.php similarity index 95% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/Mapping.php rename to src/Standards/Typo3Update/Feature/LegacyClassnameMapping.php index 685dec6..a2eacf6 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/Mapping.php +++ b/src/Standards/Typo3Update/Feature/LegacyClassnameMapping.php @@ -1,5 +1,5 @@ @@ -20,7 +20,7 @@ namespace Typo3Update\Sniffs\LegacyClassnames; * 02110-1301, USA. */ -use Typo3Update\Sniffs\Options; +use Typo3Update\Options; /** * Singleton wrapper for mappings. @@ -28,7 +28,7 @@ use Typo3Update\Sniffs\Options; * Will check the configured file for whether a class is legacy and provides further methods. * Also can update to add new migrated class names. */ -final class Mapping +final class LegacyClassnameMapping { // Singleton implementation - Start static protected $instance = null; @@ -40,7 +40,7 @@ final class Mapping public static function getInstance() { if (static::$instance === null) { - static::$instance = new Mapping(); + static::$instance = new LegacyClassnameMapping(); } return static::$instance; diff --git a/src/Standards/Typo3Update/FeatureInterface.php b/src/Standards/Typo3Update/FeatureInterface.php new file mode 100644 index 0000000..ed73e55 --- /dev/null +++ b/src/Standards/Typo3Update/FeatureInterface.php @@ -0,0 +1,40 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use PHP_CodeSniffer_File as PhpCsFile; + +/** + * + */ +interface FeatureInterface +{ + /** + * Process like a PHPCS Sniff. + * + * @param PhpCsFile $phpcsFile The current PhpCsFile working with. + * @param int $stackPtr The current stack pointer. + * @param string $content The content detected to work with. + * + * @return void + */ + public function process(PhpCsFile $phpcsFile, $stackPtr, $content); +} diff --git a/src/Standards/Typo3Update/Features.php b/src/Standards/Typo3Update/Features.php new file mode 100644 index 0000000..1927ffc --- /dev/null +++ b/src/Standards/Typo3Update/Features.php @@ -0,0 +1,69 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use PHP_CodeSniffer_Sniff as PhpCsSniff; + +/** + * + */ +class Features implements \Iterator +{ + protected $index = 0; + protected $features = []; + + public function __construct(PhpCsSniff $sniff) + { + foreach (Options::getFeaturesConfiguration() as $featureName => $sniffs) { + if (in_array(get_class($sniff), $sniffs)) { + if (!class_implements($featureName, FeatureInterface::class)) { + throw new \Exception( + 'Configured Feature "' . $featureName . '" does not implement "' . FeatureInterface::class . '".', + 1493115488 + ); + } + $this->features[] = $featureName; + } + } + } + + // implement Iterator interface: + public function current() + { + return $this->features[$this->index]; + } + public function key() + { + return $this->index; + } + public function next() + { + ++$this->index; + } + public function rewind() + { + $this->index = 0; + } + public function valid() + { + return isset($this->features[$this->index]); + } +} diff --git a/src/Standards/Typo3Update/FeaturesSupport.php b/src/Standards/Typo3Update/FeaturesSupport.php new file mode 100644 index 0000000..183f017 --- /dev/null +++ b/src/Standards/Typo3Update/FeaturesSupport.php @@ -0,0 +1,53 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use PHP_CodeSniffer_File as PhpCsFile; +use Typo3Update\Features; + +/** + * Provides "feature" support for sniff. + */ +trait FeaturesSupport +{ + /** + * @var Features + */ + protected $features; + + public function __construct() + { + $this->features = new Features($this); + } + + public function processFeatures(PhpCsFile $phpcsFile, $stackPtr, $content) + { + foreach ($this->features as $featureClassName) { + $feature = $this->createFeature($featureClassName); + $feature->process($phpcsFile, $stackPtr, $content); + } + } + + protected function createFeature($featureClassname) + { + return new $featureClassname($this); + } +} diff --git a/src/Standards/Typo3Update/Sniffs/Options.php b/src/Standards/Typo3Update/Options.php similarity index 82% rename from src/Standards/Typo3Update/Sniffs/Options.php rename to src/Standards/Typo3Update/Options.php index c6b5ba7..6aba777 100644 --- a/src/Standards/Typo3Update/Sniffs/Options.php +++ b/src/Standards/Typo3Update/Options.php @@ -1,5 +1,5 @@ @@ -21,6 +21,7 @@ namespace Typo3Update\Sniffs; */ use PHP_CodeSniffer as PhpCs; +use Symfony\Component\Yaml\Yaml; /** * Wrapper to retrieve options from PhpCs with defaults. @@ -51,7 +52,7 @@ class Options { return (string) static::getOptionWithDefault( 'mappingFile', - __DIR__ . '/../../../../LegacyClassnames.php' + __DIR__ . '/../../../LegacyClassnames.php' ); } @@ -64,7 +65,7 @@ class Options { return static::getOptionFileNames( 'removedFunctionConfigFiles', - __DIR__ . '/../Configuration/Removed/Functions/*.yaml' + __DIR__ . '/Configuration/Removed/Functions/*.yaml' ); } @@ -77,7 +78,7 @@ class Options { return static::getOptionFileNames( 'removedConstantConfigFiles', - __DIR__ . '/../Configuration/Removed/Constants/*.yaml' + __DIR__ . '/Configuration/Removed/Constants/*.yaml' ); } @@ -99,6 +100,24 @@ class Options return $option; } + public static function getFeaturesConfiguration() + { + $option = []; + $fileNames = static::getOptionFileNames( + 'features', + __DIR__ . '/Configuration/Features/*.yaml' + ); + + foreach ($fileNames as $file) { + $option = array_merge( + $option, + Yaml::parse(file_get_contents((string) $file)) + ); + } + + return $option; + } + /** * Get file names defined by option using optionName, if not defined, use default. * diff --git a/src/Standards/Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php b/src/Standards/Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php new file mode 100644 index 0000000..7bc96b2 --- /dev/null +++ b/src/Standards/Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php @@ -0,0 +1,77 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use PHP_CodeSniffer_File as PhpCsFile; +use PHP_CodeSniffer_Sniff as PhpCsSniff; +use Typo3Update\FeaturesSupport; + +/** + * Provide common uses for all sniffs, regarding class name checks. + */ +abstract class AbstractClassnameChecker implements PhpCsSniff +{ + use FeaturesSupport; + + /** + * Define whether the T_STRING default behaviour should be checked before + * or after the $stackPtr. + * + * @return bool + */ + protected function shouldLookBefore() + { + return false; + } + + /** + * Processes the tokens that this sniff is interested in. + * + * This is the default implementation, as most of the time next T_STRING is + * the class name. This way only the register method has to be registered + * in default cases. + * + * @param PhpCsFile $phpcsFile The file where the token was found. + * @param int $stackPtr The position in the stack where + * the token was found. + * + * @return void + * + * @SuppressWarnings(PHPMD.ElseExpression) This is for performance reason. + */ + public function process(PhpCsFile $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + + if ($this->shouldLookBefore()) { + $classnamePosition = $phpcsFile->findPrevious(T_STRING, $stackPtr); + } else { + $classnamePosition = $phpcsFile->findNext(T_STRING, $stackPtr); + } + + if ($classnamePosition === false) { + return; + } + + $classname = $tokens[$classnamePosition]['content']; + $this->processFeatures($phpcsFile, $classnamePosition, $classname); + } +} diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff.php similarity index 92% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff.php index 59c9dd3..aa5f134 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff.php @@ -20,12 +20,12 @@ */ use PHP_CodeSniffer_File as PhpCsFile; -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; +use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Detect and migrate extend and implement of old legacy classnames. */ -class Typo3Update_Sniffs_LegacyClassnames_InheritanceSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_InheritanceSniff extends AbstractClassnameChecker { /** * Returns the token types that this sniff is interested in. @@ -79,6 +79,7 @@ class Typo3Update_Sniffs_LegacyClassnames_InheritanceSniff extends AbstractClass } foreach ($interfaces as $interface) { + // TODO: Migrate if (! $this->isLegacyClassname($interface)) { continue; } @@ -88,7 +89,7 @@ class Typo3Update_Sniffs_LegacyClassnames_InheritanceSniff extends AbstractClass continue; } - $this->addFixableError($phpcsFile, $position, $interface); + $this->processFeatures($phpcsFile, $position, $interface); } } } diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff.php similarity index 92% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff.php index 0877989..7f1b58c 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff.php @@ -20,12 +20,12 @@ */ use PHP_CodeSniffer_File as PhpCsFile; -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; +use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Migrate PHP inline comments, e.g. for IDEs. */ -class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_InlineCommentSniff extends AbstractClassnameChecker { /** * Returns the token types that this sniff is interested in. @@ -59,7 +59,7 @@ class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff extends AbstractCla return; } - $this->addFixableError($phpcsFile, $stackPtr, $commentParts[$this->getClassnamePosition($commentParts)]); + $this->processFeatures($phpcsFile, $stackPtr, $commentParts[$this->getClassnamePosition($commentParts)]); } /** diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff.php similarity index 87% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff.php index b261922..07fd90a 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff.php @@ -19,12 +19,12 @@ * 02110-1301, USA. */ -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; +use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Detect and migrate instanceof checks of old legacy classnames. */ -class Typo3Update_Sniffs_LegacyClassnames_InstanceofSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_InstanceofSniff extends AbstractClassnameChecker { /** * Returns the token types that this sniff is interested in. diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff.php similarity index 91% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff.php index bcb33d5..ee71469 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff.php @@ -21,12 +21,12 @@ use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Tokens as Tokens; -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; +use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Detect and migrate instantiations of old legacy classnames using "makeInstance". */ -class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithMakeInstanceSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff extends AbstractClassnameChecker { use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; @@ -67,7 +67,7 @@ class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithMakeInstanceSniff ext $classname = $tokens[$classnamePosition]['content']; $this->originalTokenContent = $tokens[$classnamePosition]['content']; - $this->addFixableError($phpcsFile, $classnamePosition, $classname); + $this->processFeatures($phpcsFile, $classnamePosition, $classname); } /** diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff.php similarity index 86% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff.php index 9a1758e..be836f5 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff.php @@ -19,12 +19,12 @@ * 02110-1301, USA. */ -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; +use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Detect and migrate old legacy classnames instantiations using phps "new". */ -class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithNewSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_InstantiationWithNewSniff extends AbstractClassnameChecker { /** * Returns the token types that this sniff is interested in. diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff.php similarity index 77% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff.php index aa1d055..14afa1e 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff.php @@ -21,12 +21,12 @@ use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Tokens as Tokens; -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; +use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Detect and migrate old legacy classname instantiations using objectmanager create and get. */ -class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithObjectManagerSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_InstantiationWithObjectManagerSniff extends AbstractClassnameChecker { use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; @@ -80,20 +80,6 @@ class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithObjectManagerSniff ex } $classname = $tokens[$classnamePosition]['content']; - $this->originalTokenContent = $tokens[$classnamePosition]['content']; - $this->addFixableError($phpcsFile, $classnamePosition, $classname); - } - - /** - * As token contains more then just class name, we have to build new content ourself. - * - * @param string $newClassname - * @param string $originalClassname - * @param PhpCsFile $phpcsFile - * @return string - */ - protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile) - { - return $this->getTokenReplacementForString($newClassname); + $this->processFeatures($phpcsFile, $classnamePosition, $classname); } } diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/IsACallSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/IsACallSniff.php similarity index 75% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/IsACallSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/IsACallSniff.php index 62e90a9..06ac05c 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/IsACallSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/IsACallSniff.php @@ -20,12 +20,12 @@ */ use PHP_CodeSniffer_File as PhpcsFile; -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; +use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Detect and migrate instantiations of old legacy classnames using "makeInstance". */ -class Typo3Update_Sniffs_LegacyClassnames_IsACallSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_IsACallSniff extends AbstractClassnameChecker { use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; @@ -69,20 +69,6 @@ class Typo3Update_Sniffs_LegacyClassnames_IsACallSniff extends AbstractClassname } $classname = $tokens[$classnamePosition]['content']; - $this->originalTokenContent = $tokens[$classnamePosition]['content']; - $this->addFixableError($phpcsFile, $classnamePosition, $classname); - } - - /** - * As token contains more then just class name, we have to build new content ourself. - * - * @param string $newClassname - * @param string $originalClassname - * @param PhpCsFile $phpcsFile - * @return string - */ - protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile) - { - return $this->getTokenReplacementForString($newClassname); + $this->processFeatures($phpcsFile, $classnamePosition, $classname); } } diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff.php similarity index 93% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff.php index 8e97c45..1c18232 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff.php @@ -20,13 +20,13 @@ */ use PHP_CodeSniffer_File as PhpCsFile; -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; -use Typo3Update\Sniffs\Options; +use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; +use Typo3Update\Options; /** * Detect missing namespaces for class definitions. */ -class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_MissingNamespaceSniff extends AbstractClassnameChecker { /** * Returns the token types that this sniff is interested in. @@ -66,7 +66,8 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract } $classname = $tokens[$classnamePosition]['content']; - $this->addFixableError($phpcsFile, $classnamePosition, $classname); + // TODO: Migrate class, use custom feature as some parts are different! + // $this->addFixableError($phpcsFile, $classnamePosition, $classname); } /** diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff.php similarity index 64% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff.php index 14efb72..80a9818 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff.php @@ -20,15 +20,20 @@ */ use PHP_CodeSniffer_File as PhpCsFile; -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; +use PHP_CodeSniffer_Sniff as PhpCsSniff; +use Typo3Update\FeaturesSupport; /** - * Migrate PHP Doc comments. + * Handle PHP Doc comments. * * E.g. annotations like @param or @return, see $allowedTags. + * + * Will do nothing itself, but call features. */ -class Typo3Update_Sniffs_LegacyClassnames_DocCommentSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_PhpDocCommentSniff implements PhpCsSniff { + use FeaturesSupport; + /** * The configured tags will be processed. * @var array @@ -42,9 +47,7 @@ class Typo3Update_Sniffs_LegacyClassnames_DocCommentSniff extends AbstractClassn */ public function register() { - return [ - T_DOC_COMMENT_TAG, - ]; + return [T_DOC_COMMENT_TAG]; } /** @@ -68,32 +71,8 @@ class Typo3Update_Sniffs_LegacyClassnames_DocCommentSniff extends AbstractClassn } $classnames = explode('|', explode(' ', $tokens[$classnamePosition]['content'])[0]); - $this->originalTokenContent = $tokens[$classnamePosition]['content']; foreach ($classnames as $classname) { - $this->addFixableError($phpcsFile, $classnamePosition, $classname); + $this->processFeatures($phpcsFile, $classnamePosition, $classname); } } - - /** - * As token contains more then just class name, we have to build new content ourself. - * - * @param string $newClassname - * @param string $originalClassname - * @param PhpCsFile $phpcsFile - * @return string - */ - protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile) - { - $token = explode(' ', $this->originalTokenContent); - - $classNames = explode('|', $token[0]); - foreach ($classNames as $position => $classname) { - if ($classname === $originalClassname) { - $classNames[$position] = $newClassname; - } - } - $token[0] = implode('|', $classNames); - - return implode(' ', $token); - } } diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/StaticCallSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff.php similarity index 89% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/StaticCallSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff.php index 1be8982..7e99447 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/StaticCallSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff.php @@ -19,12 +19,12 @@ * 02110-1301, USA. */ -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; +use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Detect and migrate static calls to old legacy classnames. */ -class Typo3Update_Sniffs_LegacyClassnames_StaticCallSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_StaticCallSniff extends AbstractClassnameChecker { /** * Define whether the T_STRING default behaviour should be checked before diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintCatchExceptionSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff.php similarity index 86% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintCatchExceptionSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff.php index 876aec8..1313616 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintCatchExceptionSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff.php @@ -19,12 +19,12 @@ * 02110-1301, USA. */ -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; +use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Migrate Typehints in catch statements. */ -class Typo3Update_Sniffs_LegacyClassnames_TypehintCatchExceptionSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_TypehintCatchExceptionSniff extends AbstractClassnameChecker { /** * Returns the token types that this sniff is interested in. diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff.php similarity index 89% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff.php index 3901309..224554c 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff.php @@ -20,12 +20,12 @@ */ use PHP_CodeSniffer_File as PhpCsFile; -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; +use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Migrate Typehints in function / method definitions. */ -class Typo3Update_Sniffs_LegacyClassnames_TypehintSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_TypehintSniff extends AbstractClassnameChecker { /** * Returns the token types that this sniff is interested in. @@ -58,7 +58,7 @@ class Typo3Update_Sniffs_LegacyClassnames_TypehintSniff extends AbstractClassnam if ($position === false) { continue; } - $this->addFixableError($phpcsFile, $position, $parameter['type_hint']); + $this->processFeatures($phpcsFile, $position, $parameter['type_hint']); } } } diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/UseSniff.php similarity index 60% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff.php rename to src/Standards/Typo3Update/Sniffs/Classname/UseSniff.php index bed18bc..60e49ff 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/UseSniff.php @@ -20,14 +20,14 @@ */ use PHP_CodeSniffer_File as PhpCsFile; -use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker; +use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Detect and migrate use statements with legacy classnames.. * * According to PSR-2, only one class per use statement is expected. */ -class Typo3Update_Sniffs_LegacyClassnames_UseSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_UseSniff extends AbstractClassnameChecker { /** * Returns the token types that this sniff is interested in. @@ -38,23 +38,4 @@ class Typo3Update_Sniffs_LegacyClassnames_UseSniff extends AbstractClassnameChec { return [T_USE]; } - - /** - * Overwrite to remove prefix. - * - * @param PhpCsFile $phpcsFile - * @param int $classnamePosition - * @param string $classname - * @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out. - * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) - */ - protected function replaceLegacyClassname( - PhpCsFile $phpcsFile, - $classnamePosition, - $classname, - $forceEmptyPrefix = true - ) { - return parent::replaceLegacyClassname($phpcsFile, $classnamePosition, $classname, $forceEmptyPrefix); - } } diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff.php b/src/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff.php similarity index 96% rename from src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff.php rename to src/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff.php index 7df07fc..057f197 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff.php +++ b/src/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff.php @@ -22,12 +22,12 @@ use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Sniff as PhpCsSniff; use PHP_CodeSniffer_Tokens as Tokens; -use Typo3Update\Sniffs\Options; +use Typo3Update\Options; /** * Detect whether vendor is missing for plugins and modules registrations and configurations. */ -class Typo3Update_Sniffs_LegacyClassnames_MissingVendorForPluginsAndModulesSniff implements PhpCsSniff +class Typo3Update_Sniffs_LegacyClassname_MissingVendorForPluginsAndModulesSniff implements PhpCsSniff { use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php index 13697f0..53f28a5 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php @@ -24,7 +24,7 @@ use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Sniff as PhpCsSniff; use PHP_CodeSniffer_Tokens as Tokens; use Symfony\Component\Yaml\Yaml; -use Typo3Update\Sniffs\Options; +use Typo3Update\Options; /** * Contains common functionality for removed code like constants or functions. diff --git a/src/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff.php index e99a226..1ee46b1 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff.php @@ -21,7 +21,7 @@ use PHP_CodeSniffer_File as PhpCsFile; use Typo3Update\Sniffs\Removed\AbstractGenericUsage; -use Typo3Update\Sniffs\Options; +use Typo3Update\Options; /** * Sniff that handles all calls to removed constants. diff --git a/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php index 7f8b730..4124eb2 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php @@ -22,7 +22,7 @@ use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Tokens as Tokens; use Typo3Update\Sniffs\Removed\AbstractGenericUsage; -use Typo3Update\Sniffs\Options; +use Typo3Update\Options; /** * Sniff that handles all calls to removed functions. diff --git a/src/Standards/Typo3Update/ruleset.xml b/src/Standards/Typo3Update/ruleset.xml index 260cadb..2cc04d2 100644 --- a/src/Standards/Typo3Update/ruleset.xml +++ b/src/Standards/Typo3Update/ruleset.xml @@ -2,18 +2,18 @@ Provides sniffs and fixes for TYPO3 Updates. - + - + - + Legacy class definitions are not allowed; found "%s". Wrap your class inside a namespace. diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/Expected.json similarity index 82% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/Expected.json index 9b17ce4..e441162 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/Expected.json @@ -9,7 +9,7 @@ "line": 22, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Configuration_Configurationmanager\", use \"TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.Inheritance.legacyClassname", + "source": "Typo3Update.Classname.Inheritance.legacyClassname", "type": "ERROR" }, { @@ -18,7 +18,7 @@ "line": 22, "message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.Inheritance.legacyClassname", + "source": "Typo3Update.Classname.Inheritance.legacyClassname", "type": "ERROR" }, { @@ -27,7 +27,7 @@ "line": 22, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Core_BootstrapInterface\", use \"TYPO3\\CMS\\Extbase\\Core\\BootstrapInterface\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.Inheritance.legacyClassname", + "source": "Typo3Update.Classname.Inheritance.legacyClassname", "type": "ERROR" }, { @@ -36,7 +36,7 @@ "line": 27, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Configuration_Configurationmanager\", use \"TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.Inheritance.legacyClassname", + "source": "Typo3Update.Classname.Inheritance.legacyClassname", "type": "ERROR" }, { @@ -45,7 +45,7 @@ "line": 28, "message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.Inheritance.legacyClassname", + "source": "Typo3Update.Classname.Inheritance.legacyClassname", "type": "ERROR" }, { @@ -54,7 +54,7 @@ "line": 29, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Core_BootstrapInterface\", use \"TYPO3\\CMS\\Extbase\\Core\\BootstrapInterface\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.Inheritance.legacyClassname", + "source": "Typo3Update.Classname.Inheritance.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/Expected.json similarity index 83% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/Expected.json index b1c0d31..2a6f3ab 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/Expected.json @@ -9,7 +9,7 @@ "line": 26, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InlineComment.legacyClassname", + "source": "Typo3Update.Classname.InlineComment.legacyClassname", "type": "ERROR" }, { @@ -18,7 +18,7 @@ "line": 29, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InlineComment.legacyClassname", + "source": "Typo3Update.Classname.InlineComment.legacyClassname", "type": "ERROR" }, { @@ -27,7 +27,7 @@ "line": 32, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InlineComment.legacyClassname", + "source": "Typo3Update.Classname.InlineComment.legacyClassname", "type": "ERROR" }, { @@ -36,7 +36,7 @@ "line": 35, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InlineComment.legacyClassname", + "source": "Typo3Update.Classname.InlineComment.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/Expected.json similarity index 87% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/Expected.json index 33aca48..2cb2586 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/Expected.json @@ -9,7 +9,7 @@ "line": 22, "message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.Instanceof.legacyClassname", + "source": "Typo3Update.Classname.Instanceof.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.json similarity index 85% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.json index d7f166c..b0f764e 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.json @@ -9,7 +9,7 @@ "line": 22, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InstantiationWithMakeInstance.legacyClassname", + "source": "Typo3Update.Classname.InstantiationWithMakeInstance.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/Expected.json similarity index 81% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/Expected.json index 0183bc5..d06ec76 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/Expected.json @@ -9,7 +9,7 @@ "line": 22, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname", + "source": "Typo3Update.Classname.InstantiationWithNew.legacyClassname", "type": "ERROR" }, { @@ -18,7 +18,7 @@ "line": 23, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname", + "source": "Typo3Update.Classname.InstantiationWithNew.legacyClassname", "type": "ERROR" }, { @@ -27,7 +27,7 @@ "line": 24, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname", + "source": "Typo3Update.Classname.InstantiationWithNew.legacyClassname", "type": "ERROR" }, { @@ -36,7 +36,7 @@ "line": 27, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname", + "source": "Typo3Update.Classname.InstantiationWithNew.legacyClassname", "type": "ERROR" }, { @@ -45,7 +45,7 @@ "line": 28, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname", + "source": "Typo3Update.Classname.InstantiationWithNew.legacyClassname", "type": "ERROR" }, { @@ -54,7 +54,7 @@ "line": 29, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname", + "source": "Typo3Update.Classname.InstantiationWithNew.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/Expected.json similarity index 80% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/Expected.json index 2ebb599..273b495 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/Expected.json @@ -9,7 +9,7 @@ "line": 24, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname", + "source": "Typo3Update.Classname.InstantiationWithObjectManager.legacyClassname", "type": "ERROR" }, { @@ -18,7 +18,7 @@ "line": 25, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname", + "source": "Typo3Update.Classname.InstantiationWithObjectManager.legacyClassname", "type": "ERROR" }, { @@ -27,7 +27,7 @@ "line": 31, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname", + "source": "Typo3Update.Classname.InstantiationWithObjectManager.legacyClassname", "type": "ERROR" }, { @@ -36,7 +36,7 @@ "line": 33, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname", + "source": "Typo3Update.Classname.InstantiationWithObjectManager.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/IsACallSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/IsACallSniff/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/IsACallSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.json similarity index 84% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/IsACallSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.json index d754658..6ec4608 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/IsACallSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.json @@ -9,7 +9,7 @@ "line": 26, "message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.IsACall.legacyClassname", + "source": "Typo3Update.Classname.IsACall.legacyClassname", "type": "ERROR" }, { @@ -18,7 +18,7 @@ "line": 29, "message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.IsACall.legacyClassname", + "source": "Typo3Update.Classname.IsACall.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/IsACallSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/IsACallSniff/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/Arguments.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/Arguments.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/Arguments.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/Arguments.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/customVendor/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/customVendor/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/defaultVendor/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/Expected.json similarity index 86% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/defaultVendor/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/Expected.json index a720806..3126302 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/defaultVendor/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/Expected.json @@ -9,7 +9,7 @@ "line": 24, "message": "Legacy class definitions are not allowed; found \"Tx_ExtName_Controller_Frontendcontroller\". Wrap your class inside a namespace.", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingNamespace.legacyClassname", + "source": "Typo3Update.Classname.MissingNamespace.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/customVendor/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/customVendor/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/defaultVendor/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/defaultVendor/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/defaultVendor/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/defaultVendor/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/customVendor/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/defaultVendor/Expected.json similarity index 86% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/customVendor/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/defaultVendor/Expected.json index a720806..3126302 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/customVendor/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/defaultVendor/Expected.json @@ -9,7 +9,7 @@ "line": 24, "message": "Legacy class definitions are not allowed; found \"Tx_ExtName_Controller_Frontendcontroller\". Wrap your class inside a namespace.", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingNamespace.legacyClassname", + "source": "Typo3Update.Classname.MissingNamespace.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/defaultVendor/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/defaultVendor/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/defaultVendor/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/defaultVendor/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.diff similarity index 89% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.diff index f6d97a5..807e03e 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php +++ PHP_CodeSniffer @@ -22,19 +22,19 @@ class InputFileForIssues diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json similarity index 83% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json index 6df46f0..dc72038 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json @@ -9,7 +9,7 @@ "line": 25, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Repository_CategoryRepository\", use \"TYPO3\\CMS\\Extbase\\Domain\\Repository\\CategoryRepository\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.DocComment.legacyClassname", + "source": "Typo3Update.Classname.PhpDocComment.legacyClassname", "type": "ERROR" }, { @@ -18,7 +18,7 @@ "line": 31, "message": "Legacy classes are not allowed; found \"t3lib_div\", use \"TYPO3\\CMS\\Core\\Utility\\GeneralUtility\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.DocComment.legacyClassname", + "source": "Typo3Update.Classname.PhpDocComment.legacyClassname", "type": "ERROR" }, { @@ -27,7 +27,7 @@ "line": 33, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Configuration_Configurationmanager\", use \"TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.DocComment.legacyClassname", + "source": "Typo3Update.Classname.PhpDocComment.legacyClassname", "type": "ERROR" }, { @@ -36,7 +36,7 @@ "line": 37, "message": "Legacy classes are not allowed; found \"t3lib_div\", use \"TYPO3\\CMS\\Core\\Utility\\GeneralUtility\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.DocComment.legacyClassname", + "source": "Typo3Update.Classname.PhpDocComment.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/StaticCallSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/StaticCallSniff/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/StaticCallSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff/Expected.json similarity index 82% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/StaticCallSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff/Expected.json index f2e2a54..124198b 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/StaticCallSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff/Expected.json @@ -9,7 +9,7 @@ "line": 22, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Utility_Extension\", use \"TYPO3\\CMS\\Extbase\\Utility\\ExtensionUtility\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.StaticCall.legacyClassname", + "source": "Typo3Update.Classname.StaticCall.legacyClassname", "type": "ERROR" }, { @@ -18,7 +18,7 @@ "line": 27, "message": "Legacy classes are not allowed; found \"t3lib_div\", use \"TYPO3\\CMS\\Core\\Utility\\GeneralUtility\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.StaticCall.legacyClassname", + "source": "Typo3Update.Classname.StaticCall.legacyClassname", "type": "ERROR" }, { @@ -27,7 +27,7 @@ "line": 27, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.StaticCall.legacyClassname", + "source": "Typo3Update.Classname.StaticCall.legacyClassname", "type": "ERROR" }, { @@ -36,7 +36,7 @@ "line": 28, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.StaticCall.legacyClassname", + "source": "Typo3Update.Classname.StaticCall.legacyClassname", "type": "ERROR" }, { @@ -45,7 +45,7 @@ "line": 30, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.StaticCall.legacyClassname", + "source": "Typo3Update.Classname.StaticCall.legacyClassname", "type": "ERROR" }, { @@ -54,7 +54,7 @@ "line": 31, "message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.StaticCall.legacyClassname", + "source": "Typo3Update.Classname.StaticCall.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/StaticCallSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/StaticCallSniff/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintCatchExceptionSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintCatchExceptionSniff/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintCatchExceptionSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff/Expected.json similarity index 82% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintCatchExceptionSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff/Expected.json index ae6d240..59701dd 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintCatchExceptionSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff/Expected.json @@ -9,7 +9,7 @@ "line": 24, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Exception\", use \"TYPO3\\CMS\\Extbase\\Exception\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.TypeHintCatchException.legacyClassname", + "source": "Typo3Update.Classname.TypeHintCatchException.legacyClassname", "type": "ERROR" }, { @@ -18,7 +18,7 @@ "line": 30, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Exception\", use \"TYPO3\\CMS\\Extbase\\Exception\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.TypeHintCatchException.legacyClassname", + "source": "Typo3Update.Classname.TypeHintCatchException.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintCatchExceptionSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintCatchExceptionSniff/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintSniff/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/Expected.json similarity index 83% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/Expected.json index 9b45649..9fde95c 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/Expected.json @@ -9,7 +9,7 @@ "line": 28, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.TypeHint.legacyClassname", + "source": "Typo3Update.Classname.TypeHint.legacyClassname", "type": "ERROR" }, { @@ -18,7 +18,7 @@ "line": 31, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.TypeHint.legacyClassname", + "source": "Typo3Update.Classname.TypeHint.legacyClassname", "type": "ERROR" }, { @@ -27,7 +27,7 @@ "line": 43, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.TypeHint.legacyClassname", + "source": "Typo3Update.Classname.TypeHint.legacyClassname", "type": "ERROR" }, { @@ -36,7 +36,7 @@ "line": 46, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.TypeHint.legacyClassname", + "source": "Typo3Update.Classname.TypeHint.legacyClassname", "type": "ERROR" }, { @@ -45,7 +45,7 @@ "line": 56, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.TypeHint.legacyClassname", + "source": "Typo3Update.Classname.TypeHint.legacyClassname", "type": "ERROR" }, { @@ -54,7 +54,7 @@ "line": 59, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.TypeHint.legacyClassname", + "source": "Typo3Update.Classname.TypeHint.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintSniff/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/Expected.json similarity index 86% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/Expected.json index 6b30360..63816bd 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/Expected.json @@ -9,7 +9,7 @@ "line": 22, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.Use.legacyClassname", + "source": "Typo3Update.Classname.Use.legacyClassname", "type": "ERROR" }, { @@ -18,7 +18,7 @@ "line": 23, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead", "severity": 5, - "source": "Typo3Update.LegacyClassnames.Use.legacyClassname", + "source": "Typo3Update.Classname.Use.legacyClassname", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/Arguments.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/Arguments.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/Arguments.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/Arguments.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.json similarity index 79% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.json index c46162f..e2b6a38 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.json @@ -9,7 +9,7 @@ "line": 23, "message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor", + "source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor", "type": "ERROR" }, { @@ -18,7 +18,7 @@ "line": 31, "message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor", + "source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor", "type": "ERROR" }, { @@ -27,7 +27,7 @@ "line": 39, "message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor", + "source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor", "type": "ERROR" }, { @@ -36,7 +36,7 @@ "line": 45, "message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor", + "source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor", "type": "ERROR" }, { @@ -45,7 +45,7 @@ "line": 51, "message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor", + "source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor", "type": "ERROR" }, { @@ -54,7 +54,7 @@ "line": 61, "message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor", + "source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/customVendor/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/customVendor/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.diff similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.diff diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.json similarity index 79% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.json rename to tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.json index 8f4511c..c05e3c9 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.json @@ -9,7 +9,7 @@ "line": 23, "message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"YourCompany.\" . $_EXTKEY", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor", + "source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor", "type": "ERROR" }, { @@ -18,7 +18,7 @@ "line": 31, "message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"YourCompany.\" . $_EXTKEY", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor", + "source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor", "type": "ERROR" }, { @@ -27,7 +27,7 @@ "line": 39, "message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"YourCompany.\" . $_EXTKEY", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor", + "source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor", "type": "ERROR" }, { @@ -36,7 +36,7 @@ "line": 45, "message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"YourCompany.\" . $_EXTKEY", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor", + "source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor", "type": "ERROR" }, { @@ -45,7 +45,7 @@ "line": 51, "message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"YourCompany.\" . $_EXTKEY", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor", + "source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor", "type": "ERROR" }, { @@ -54,7 +54,7 @@ "line": 61, "message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"YourCompany.\" . $_EXTKEY", "severity": 5, - "source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor", + "source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor", "type": "ERROR" } ], diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/defaultVendor/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/InputFileForIssues.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/defaultVendor/InputFileForIssues.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/InputFileForIssues.php From cc0be4a5b42641811caf76b75df8c88391cc60b3 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 13:03:36 +0200 Subject: [PATCH 047/100] WIP: Move features to own namespace * Have all feature related classes in a single namespace. Relates: #72 --- src/Standards/Typo3Update/{ => Feature}/FeatureInterface.php | 2 +- src/Standards/Typo3Update/{ => Feature}/Features.php | 3 ++- src/Standards/Typo3Update/{ => Feature}/FeaturesSupport.php | 3 +-- src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php | 2 -- .../Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php | 2 +- .../Typo3Update/Sniffs/Classname/PhpDocCommentSniff.php | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) rename src/Standards/Typo3Update/{ => Feature}/FeatureInterface.php (97%) rename src/Standards/Typo3Update/{ => Feature}/Features.php (97%) rename src/Standards/Typo3Update/{ => Feature}/FeaturesSupport.php (96%) diff --git a/src/Standards/Typo3Update/FeatureInterface.php b/src/Standards/Typo3Update/Feature/FeatureInterface.php similarity index 97% rename from src/Standards/Typo3Update/FeatureInterface.php rename to src/Standards/Typo3Update/Feature/FeatureInterface.php index ed73e55..36d63c7 100644 --- a/src/Standards/Typo3Update/FeatureInterface.php +++ b/src/Standards/Typo3Update/Feature/FeatureInterface.php @@ -1,5 +1,5 @@ diff --git a/src/Standards/Typo3Update/Features.php b/src/Standards/Typo3Update/Feature/Features.php similarity index 97% rename from src/Standards/Typo3Update/Features.php rename to src/Standards/Typo3Update/Feature/Features.php index 1927ffc..996f012 100644 --- a/src/Standards/Typo3Update/Features.php +++ b/src/Standards/Typo3Update/Feature/Features.php @@ -1,5 +1,5 @@ @@ -21,6 +21,7 @@ namespace Typo3Update; */ use PHP_CodeSniffer_Sniff as PhpCsSniff; +use Typo3Update\Options; /** * diff --git a/src/Standards/Typo3Update/FeaturesSupport.php b/src/Standards/Typo3Update/Feature/FeaturesSupport.php similarity index 96% rename from src/Standards/Typo3Update/FeaturesSupport.php rename to src/Standards/Typo3Update/Feature/FeaturesSupport.php index 183f017..fa71785 100644 --- a/src/Standards/Typo3Update/FeaturesSupport.php +++ b/src/Standards/Typo3Update/Feature/FeaturesSupport.php @@ -1,5 +1,5 @@ @@ -21,7 +21,6 @@ namespace Typo3Update; */ use PHP_CodeSniffer_File as PhpCsFile; -use Typo3Update\Features; /** * Provides "feature" support for sniff. diff --git a/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php index 70b5cf5..a052abf 100644 --- a/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php +++ b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php @@ -23,8 +23,6 @@ namespace Typo3Update\Feature; use PHP_CodeSniffer as PhpCs; use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Sniff as PhpCsSniff; -use Typo3Update\FeatureInterface; -use Typo3Update\Feature\LegacyClassnameMapping; /** * diff --git a/src/Standards/Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php b/src/Standards/Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php index 7bc96b2..dbc60b2 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php @@ -22,7 +22,7 @@ namespace Typo3Update\Sniffs\Classname; use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Sniff as PhpCsSniff; -use Typo3Update\FeaturesSupport; +use Typo3Update\Feature\FeaturesSupport; /** * Provide common uses for all sniffs, regarding class name checks. diff --git a/src/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff.php index 80a9818..d1f7f78 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff.php @@ -21,7 +21,7 @@ use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Sniff as PhpCsSniff; -use Typo3Update\FeaturesSupport; +use Typo3Update\Feature\FeaturesSupport; /** * Handle PHP Doc comments. From 2b1a1a0f1995ce43947c8926ee65621e480d39e4 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 13:05:48 +0200 Subject: [PATCH 048/100] WIP: Fix broken MissingVendorForPluginsAndModulesSniff tests Relates: #72 --- .../customVendor/Expected.diff | 2 +- .../defaultVendor/Expected.diff | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.diff index 22d4fa8..9fcdb32 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/customVendor/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/InputFileForIssues.php +++ PHP_CodeSniffer @@ -20,7 +20,7 @@ */ diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.diff index 2faa023..a8fa872 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/defaultVendor/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/InputFileForIssues.php +++ PHP_CodeSniffer @@ -20,7 +20,7 @@ */ From 94df1f2ad13a541497120cab594443da2ae05362 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 13:16:58 +0200 Subject: [PATCH 049/100] WIP: Fix use sniff * Make use sniff tests pass again. Relates: #72 --- .../Feature/LegacyClassnameFeature.php | 30 ++++++++++++++----- .../Typo3Update/Sniffs/Classname/UseSniff.php | 5 ---- .../Sniffs/Classname/UseSniff/Expected.diff | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php index a052abf..72edd35 100644 --- a/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php +++ b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php @@ -44,6 +44,11 @@ class LegacyClassnameFeature implements FeatureInterface */ protected $legacyMapping; + /** + * @var PhpCsSniff + */ + protected $sniff; + /** * Used by some sniffs to keep original token for replacement. * @@ -53,8 +58,9 @@ class LegacyClassnameFeature implements FeatureInterface */ protected $originalTokenContent = ''; - public function __construct() + public function __construct(PhpCsSniff $sniff) { + $this->sniff = $sniff; $this->legacyMapping = LegacyClassnameMapping::getInstance(); } @@ -175,18 +181,14 @@ class LegacyClassnameFeature implements FeatureInterface * @param PhpCsFile $phpcsFile * @param int $classnamePosition * @param string $classname - * @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out. - * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ protected function replaceLegacyClassname( PhpCsFile $phpcsFile, $classnamePosition, - $classname, - $forceEmptyPrefix = false + $classname ) { $prefix = '\\'; - if ($forceEmptyPrefix || $phpcsFile->getTokens()[$classnamePosition -1]['code'] === T_NS_SEPARATOR) { + if ($this->forceEmptyPrefix() || $phpcsFile->getTokens()[$classnamePosition -1]['code'] === T_NS_SEPARATOR) { $prefix = ''; } @@ -233,4 +235,18 @@ class LegacyClassnameFeature implements FeatureInterface return implode($stringSign, $token); } + + /** + * Check whether new class name for replacment should not contain the "\" as prefix. + * + * @return bool + */ + protected function forceEmptyPrefix() + { + if (get_class($this->sniff) === \Typo3Update_Sniffs_Classname_UseSniff::class) { + return true; + } + + return false; + } } diff --git a/src/Standards/Typo3Update/Sniffs/Classname/UseSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/UseSniff.php index 60e49ff..67c00e6 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/UseSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/UseSniff.php @@ -22,11 +22,6 @@ use PHP_CodeSniffer_File as PhpCsFile; use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; -/** - * Detect and migrate use statements with legacy classnames.. - * - * According to PSR-2, only one class per use statement is expected. - */ class Typo3Update_Sniffs_Classname_UseSniff extends AbstractClassnameChecker { /** diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/Expected.diff index 919696a..ff0098d 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/InputFileForIssues.php +++ PHP_CodeSniffer @@ -19,8 +19,8 @@ * 02110-1301, USA. From c4c8faacd2b30ad8f8305cefdda4bfe6e472850b Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 13:25:48 +0200 Subject: [PATCH 050/100] WIP: Fix TypeHintSniff * Make TypeHintSniff tests pass again. * Fix typo in class name preventing new feature mechanism from matching. Relates: #72 --- src/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff.php | 2 +- .../Typo3Update/Sniffs/Classname/TypeHintSniff/Expected.diff | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff.php index 224554c..7d08f16 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff.php @@ -25,7 +25,7 @@ use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Migrate Typehints in function / method definitions. */ -class Typo3Update_Sniffs_Classname_TypehintSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_TypeHintSniff extends AbstractClassnameChecker { /** * Returns the token types that this sniff is interested in. diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/Expected.diff index bceab5a..54ec8ea 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintSniff/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/InputFileForIssues.php +++ PHP_CodeSniffer @@ -25,10 +25,10 @@ function something(\TYPO3\CMS\Extbase\Domain\Model\BackendUser $user) From 0c6bb133a1538f37e660dbd6e8d80d2d9291d3cb Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 13:28:09 +0200 Subject: [PATCH 051/100] TASK: Make some tests pass again * All tests where only file name in diff was wrong are working again. Relates: #72 --- .../Typo3Update/Sniffs/Classname/InheritanceSniff/Expected.diff | 2 +- .../Sniffs/Classname/InlineCommentSniff/Expected.diff | 2 +- .../Typo3Update/Sniffs/Classname/InstanceofSniff/Expected.diff | 2 +- .../Classname/InstantiationWithMakeInstanceSniff/Expected.diff | 2 +- .../Sniffs/Classname/InstantiationWithNewSniff/Expected.diff | 2 +- .../Classname/InstantiationWithObjectManagerSniff/Expected.diff | 2 +- .../Typo3Update/Sniffs/Classname/IsACallSniff/Expected.diff | 2 +- .../Classname/MissingNamespaceSniff/customVendor/Expected.diff | 2 +- .../Classname/MissingNamespaceSniff/defaultVendor/Expected.diff | 2 +- .../Typo3Update/Sniffs/Classname/StaticCallSniff/Expected.diff | 2 +- .../Sniffs/Classname/TypeHintCatchExceptionSniff/Expected.diff | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/Expected.diff index 410f7f9..fc75d37 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/InputFileForIssues.php +++ PHP_CodeSniffer @@ -19,14 +19,14 @@ * 02110-1301, USA. diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/Expected.diff index 6674872..5f59195 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/InputFileForIssues.php +++ PHP_CodeSniffer @@ -23,16 +23,16 @@ { diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/Expected.diff index 9a5a9e1..49e34a3 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/InputFileForIssues.php +++ PHP_CodeSniffer @@ -19,6 +19,6 @@ * 02110-1301, USA. diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff index 46b2b0c..41f28ef 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php +++ PHP_CodeSniffer @@ -19,6 +19,6 @@ * 02110-1301, USA. diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/Expected.diff index 7fe1f38..3e4f8b5 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/InputFileForIssues.php +++ PHP_CodeSniffer @@ -19,13 +19,13 @@ * 02110-1301, USA. diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/Expected.diff index 03ae814..873ee97 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/InputFileForIssues.php +++ PHP_CodeSniffer @@ -21,13 +21,13 @@ diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.diff index 64f197e..8e2e341 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/IsACallSniff/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/InputFileForIssues.php +++ PHP_CodeSniffer @@ -23,9 +23,9 @@ if (is_a($a, t3lib_Singleton::class)) { diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/Expected.diff index bba47b8..fa266ab 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/customVendor/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/InputFileForIssues.php +++ PHP_CodeSniffer @@ -1,4 +1,5 @@ Date: Tue, 25 Apr 2017 13:33:56 +0200 Subject: [PATCH 052/100] TASK: Make TypeHintCatchExceptionSniff work again * Fix wrong class name, to allow features to match. Relates: #72 --- .../Sniffs/Classname/TypeHintCatchExceptionSniff.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff.php index 1313616..2242e6b 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff.php @@ -24,7 +24,7 @@ use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; /** * Migrate Typehints in catch statements. */ -class Typo3Update_Sniffs_Classname_TypehintCatchExceptionSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_Classname_TypeHintCatchExceptionSniff extends AbstractClassnameChecker { /** * Returns the token types that this sniff is interested in. From 8572740fd181cbbfdc069f60fe306e9bd6e7dc9a Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 13:41:36 +0200 Subject: [PATCH 053/100] TASK: Shorten test output * Remove unnecessary information to shorten output. * This should make it easier to get the actual issue. --- tests/SniffsTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/SniffsTest.php b/tests/SniffsTest.php index 2560f1a..4ed294b 100644 --- a/tests/SniffsTest.php +++ b/tests/SniffsTest.php @@ -137,8 +137,7 @@ class SniffsTest extends TestCase $this->getExpectedJsonOutput($folder), $this->getOutput($internalArguments)['output'], 'Checking Sniff "' . $this->getSniffByFolder($folder) . '"' - . ' did not produce expected output for input file ' - . $internalArguments['inputFile'] + . ' did not produce expected output,' . ' called: ' . $this->getPhpcsCall($internalArguments) ); From d3b612790ce26e5f49ee7c668b2166510ab707a4 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 13:45:46 +0200 Subject: [PATCH 054/100] TASK: Make inline replacements work again * As sometimes not the whole token should be replaces, but only the classname within the token, we replace them always this way. * Before the refactoring, that was done in the concrete sniffs. * Affected are e.g. php doc comments. Relates: #72 --- .../Feature/LegacyClassnameFeature.php | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php index 72edd35..c5d27f5 100644 --- a/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php +++ b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php @@ -194,26 +194,14 @@ class LegacyClassnameFeature implements FeatureInterface $phpcsFile->fixer->replaceToken( $classnamePosition, - $this->getTokenForReplacement($prefix . $this->getNewClassname($classname), $classname, $phpcsFile) + str_replace( + $classname, + $prefix . $this->getNewClassname($classname), + $phpcsFile->getTokens()[$classnamePosition]['content'] + ) ); } - /** - * String to use for replacing / fixing the token. - * Default is class name itself, can be overwritten in sniff for special behaviour. - * - * @param string $newClassname - * @param string $originalClassname - * @param PhpCsFile $phpcsFile - * @return string - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) We need to match the signature. - */ - protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile) - { - return $newClassname; - } - /** * Use this inside your getTokenForReplacement if $classname is inside a string. * Strings will be converted to single quotes. From efd5d9114faa6d7e2d99aaab68b95dd16eab4e19 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 14:11:40 +0200 Subject: [PATCH 055/100] TASK: Migrate MissingNamespaceSniff * Make MissingNamespaceSniff work again. * Move to old namespace as it's a custom sniff, not a general one. * Do not use new feature here, implement logic internal. * Remove message from ruleset, use it directly. Relates: #72 --- .../Features/LegacyClassnames.yaml | 2 +- .../MissingNamespaceSniff.php | 60 +++++++++---------- src/Standards/Typo3Update/ruleset.xml | 4 -- .../MissingNamespaceSniff/Arguments.php | 0 .../customVendor/Expected.diff | 2 +- .../customVendor/Expected.json | 2 +- .../customVendor/InputFileForIssues.php | 0 .../defaultVendor/Expected.diff | 2 +- .../defaultVendor/Expected.json | 2 +- .../defaultVendor/InputFileForIssues.php | 0 10 files changed, 33 insertions(+), 41 deletions(-) rename src/Standards/Typo3Update/Sniffs/{Classname => LegacyClassname}/MissingNamespaceSniff.php (81%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{Classname => LegacyClassname}/MissingNamespaceSniff/Arguments.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{Classname => LegacyClassname}/MissingNamespaceSniff/customVendor/Expected.diff (77%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{Classname => LegacyClassname}/MissingNamespaceSniff/customVendor/Expected.json (86%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{Classname => LegacyClassname}/MissingNamespaceSniff/customVendor/InputFileForIssues.php (100%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{Classname => LegacyClassname}/MissingNamespaceSniff/defaultVendor/Expected.diff (76%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{Classname => LegacyClassname}/MissingNamespaceSniff/defaultVendor/Expected.json (86%) rename tests/Fixtures/Standards/Typo3Update/Sniffs/{Classname => LegacyClassname}/MissingNamespaceSniff/defaultVendor/InputFileForIssues.php (100%) diff --git a/src/Standards/Typo3Update/Configuration/Features/LegacyClassnames.yaml b/src/Standards/Typo3Update/Configuration/Features/LegacyClassnames.yaml index c510db2..44e6556 100644 --- a/src/Standards/Typo3Update/Configuration/Features/LegacyClassnames.yaml +++ b/src/Standards/Typo3Update/Configuration/Features/LegacyClassnames.yaml @@ -6,10 +6,10 @@ Typo3Update\Feature\LegacyClassnameFeature: - Typo3Update_Sniffs_Classname_InstantiationWithNewSniff - Typo3Update_Sniffs_Classname_InstantiationWithObjectManagerSniff - Typo3Update_Sniffs_Classname_IsACallSniff - - Typo3Update_Sniffs_Classname_MissingNamespaceSniff - Typo3Update_Sniffs_Classname_MissingVendorForPluginsAndModulesSniff - Typo3Update_Sniffs_Classname_PhpDocCommentSniff - Typo3Update_Sniffs_Classname_StaticCallSniff - Typo3Update_Sniffs_Classname_TypeHintCatchExceptionSniff - Typo3Update_Sniffs_Classname_TypeHintSniff - Typo3Update_Sniffs_Classname_UseSniff + - Typo3Update_Sniffs_LegacyClassname_MissingNamespaceSniff diff --git a/src/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff.php b/src/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff.php similarity index 81% rename from src/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff.php rename to src/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff.php index 1c18232..9296d88 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff.php +++ b/src/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff.php @@ -20,13 +20,14 @@ */ use PHP_CodeSniffer_File as PhpCsFile; -use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; +use PHP_CodeSniffer_Sniff as PhpCsSniff; +use Typo3Update\Feature\LegacyClassnameMapping; use Typo3Update\Options; /** * Detect missing namespaces for class definitions. */ -class Typo3Update_Sniffs_Classname_MissingNamespaceSniff extends AbstractClassnameChecker +class Typo3Update_Sniffs_LegacyClassname_MissingNamespaceSniff implements PhpCsSniff { /** * Returns the token types that this sniff is interested in. @@ -66,28 +67,16 @@ class Typo3Update_Sniffs_Classname_MissingNamespaceSniff extends AbstractClassna } $classname = $tokens[$classnamePosition]['content']; - // TODO: Migrate class, use custom feature as some parts are different! - // $this->addFixableError($phpcsFile, $classnamePosition, $classname); - } - - /** - * Overwrite as we don't look up the classname, but check whether the style is legacy. - * - * @param string $classname - * @return bool - */ - protected function isLegacyClassname($classname) - { - return strpos($classname, 'Tx_') === 0; - } - - /** - * @param string $classname - * @return string - */ - protected function getNewClassname($classname) - { - return substr($classname, strrpos($classname, '_') + 1); + $fix = $phpcsFile->addFixableError( + 'Legacy class definitions are not allowed; found "%s".' + . ' Wrap your class inside a namespace.', + $classnamePosition, + 'legacyClassname', + [$classname] + ); + if ($fix === true) { + $this->replaceLegacyClassname($phpcsFile, $classnamePosition, $classname); + } } /** @@ -95,18 +84,12 @@ class Typo3Update_Sniffs_Classname_MissingNamespaceSniff extends AbstractClassna * @param PhpCsFile $phpcsFile * @param int $classnamePosition * @param string $classname - * @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out. - * - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ protected function replaceLegacyClassname( PhpCsFile $phpcsFile, $classnamePosition, - $classname, - $forceEmptyPrefix = true + $classname ) { - parent::replaceLegacyClassname($phpcsFile, $classnamePosition, $classname, $forceEmptyPrefix); - $tokens = $phpcsFile->getTokens(); $lineEndings = PhpCsFile::detectLineEndings($phpcsFile->getFilename()); $suffix = $lineEndings; @@ -115,16 +98,29 @@ class Typo3Update_Sniffs_Classname_MissingNamespaceSniff extends AbstractClassna $suffix .= $lineEndings; } + $phpcsFile->fixer->replaceToken( + $classnamePosition, + substr($classname, strrpos($classname, '_') + 1) + ); $phpcsFile->fixer->replaceToken( $this->getNamespacePosition($phpcsFile), 'getNamespaceDefinition($classname) . $suffix ); - $this->addLegacyClassname( + LegacyClassnameMapping::getInstance()->addLegacyClassname( $classname, $this->getNamespace($classname) . '\\' . $this->getNewClassname($classname) ); } + /** + * @param string $classname + * @return string + */ + protected function getNewClassname($classname) + { + return substr($classname, strrpos($classname, '_') + 1); + } + /** * @param PhpCsFile $phpcsFile * @return int|false diff --git a/src/Standards/Typo3Update/ruleset.xml b/src/Standards/Typo3Update/ruleset.xml index 2cc04d2..f9e1580 100644 --- a/src/Standards/Typo3Update/ruleset.xml +++ b/src/Standards/Typo3Update/ruleset.xml @@ -12,8 +12,4 @@ - - - Legacy class definitions are not allowed; found "%s". Wrap your class inside a namespace. - diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/Arguments.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/Arguments.php similarity index 100% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/Arguments.php rename to tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/Arguments.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/customVendor/Expected.diff similarity index 77% rename from tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/Expected.diff rename to tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/customVendor/Expected.diff index fa266ab..9f60b88 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/customVendor/Expected.diff @@ -1,4 +1,4 @@ ---- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/MissingNamespaceSniff/customVendor/InputFileForIssues.php +--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/customVendor/InputFileForIssues.php +++ PHP_CodeSniffer @@ -1,4 +1,5 @@ Date: Tue, 25 Apr 2017 14:16:59 +0200 Subject: [PATCH 056/100] TASK: Streamline test output on error --- tests/SniffsTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/SniffsTest.php b/tests/SniffsTest.php index 4ed294b..f7e5b16 100644 --- a/tests/SniffsTest.php +++ b/tests/SniffsTest.php @@ -147,8 +147,7 @@ class SniffsTest extends TestCase $this->getExpectedDiffOutput($folder), $this->getOutput($internalArguments)['output'], 'Fixing Sniff "' . $this->getSniffByFolder($folder) . '"' - . ' did not produce expected diff for input file ' - . $internalArguments['inputFile'] + . ' did not produce expected diff,' . ' called: ' . $this->getPhpcsCall($internalArguments) ); } catch (FileNotFoundException $e) { From 14c82e4a10453e1308b9509cffa17bc8059d16a8 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 14:23:49 +0200 Subject: [PATCH 057/100] TASK: Migrate IsACallSniff * Add further tests with quotes. * Handle prefix in strings. * Remove old originalTokenContent which is no longer in use, as we use str_replace, introduced in earlier commit. Relates: #72 --- .../Feature/LegacyClassnameFeature.php | 58 +++++++------------ .../Classname/IsACallSniff/Expected.diff | 10 +++- .../Classname/IsACallSniff/Expected.json | 24 +++++++- .../IsACallSniff/InputFileForIssues.php | 6 ++ 4 files changed, 57 insertions(+), 41 deletions(-) diff --git a/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php index c5d27f5..269650c 100644 --- a/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php +++ b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php @@ -49,15 +49,6 @@ class LegacyClassnameFeature implements FeatureInterface */ protected $sniff; - /** - * Used by some sniffs to keep original token for replacement. - * - * E.g. when Token itself is a whole inline comment, and we just want to replace the classname within. - * - * @var string - */ - protected $originalTokenContent = ''; - public function __construct(PhpCsSniff $sniff) { $this->sniff = $sniff; @@ -188,40 +179,22 @@ class LegacyClassnameFeature implements FeatureInterface $classname ) { $prefix = '\\'; - if ($this->forceEmptyPrefix() || $phpcsFile->getTokens()[$classnamePosition -1]['code'] === T_NS_SEPARATOR) { + if ($this->useEmptyPrefix($phpcsFile, $classnamePosition)) { $prefix = ''; } - $phpcsFile->fixer->replaceToken( - $classnamePosition, - str_replace( - $classname, - $prefix . $this->getNewClassname($classname), - $phpcsFile->getTokens()[$classnamePosition]['content'] - ) + $newClassname = str_replace( + $classname, + $prefix . $this->getNewClassname($classname), + $phpcsFile->getTokens()[$classnamePosition]['content'] ); - } - /** - * Use this inside your getTokenForReplacement if $classname is inside a string. - * Strings will be converted to single quotes. - * - * @param string $classname - * @return string - */ - protected function getTokenReplacementForString($classname) - { - $stringSign = $this->originalTokenContent[0]; - $token = explode($stringSign, $this->originalTokenContent); - $token[1] = $classname; - - // Migrate double quote to single quote. - // This way no escaping of backslashes in class names is necessary. - if ($stringSign === '"') { - $stringSign = "'"; + // Handle double quotes, with special escaping. + if ($newClassname[0] === '"') { + $newClassname = '"\\\\' . str_replace('\\', '\\\\', ltrim(substr($newClassname, 1), '\\')); } - return implode($stringSign, $token); + $phpcsFile->fixer->replaceToken($classnamePosition, $newClassname); } /** @@ -229,11 +202,22 @@ class LegacyClassnameFeature implements FeatureInterface * * @return bool */ - protected function forceEmptyPrefix() + protected function useEmptyPrefix(PhpCsFile $phpcsFile, $classnamePosition) { + // Use statements don't start with T_NS_SEPARATOR. if (get_class($this->sniff) === \Typo3Update_Sniffs_Classname_UseSniff::class) { return true; } + // If T_NS_SEPARATOR is already present before, don't add again. + if ($phpcsFile->getTokens()[$classnamePosition -1]['code'] === T_NS_SEPARATOR) { + return true; + } + // If inside string starting with T_NS_SEPARATOR don't add again. + if (isset($phpcsFile->getTokens()[$classnamePosition]['content'][1]) + && $phpcsFile->getTokens()[$classnamePosition]['content'][1] === '\\' + ) { + return true; + } return false; } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.diff index 8e2e341..d099979 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.diff @@ -1,6 +1,6 @@ --- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/InputFileForIssues.php +++ PHP_CodeSniffer -@@ -23,9 +23,9 @@ +@@ -23,15 +23,15 @@ if (is_a($a, t3lib_Singleton::class)) { // do something } @@ -12,3 +12,11 @@ +if (is_a($a, '\TYPO3\CMS\Core\SingletonInterface')) { // do something } +-if (is_a($a, "t3lib_Singleton")) { ++if (is_a($a, "\\TYPO3\\CMS\\Core\\SingletonInterface")) { + // do something + } +-if (is_a($a, "\\t3lib_Singleton")) { ++if (is_a($a, "\\TYPO3\\CMS\\Core\\SingletonInterface")) { + // do something + } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.json index 6ec4608..6795e14 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/Expected.json @@ -1,7 +1,7 @@ { "files": { "InputFileForIssues.php": { - "errors": 2, + "errors": 4, "messages": [ { "column": 14, @@ -20,14 +20,32 @@ "severity": 5, "source": "Typo3Update.Classname.IsACall.legacyClassname", "type": "ERROR" + }, + { + "column": 14, + "fixable": true, + "line": 32, + "message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead", + "severity": 5, + "source": "Typo3Update.Classname.IsACall.legacyClassname", + "type": "ERROR" + }, + { + "column": 14, + "fixable": true, + "line": 35, + "message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead", + "severity": 5, + "source": "Typo3Update.Classname.IsACall.legacyClassname", + "type": "ERROR" } ], "warnings": 0 } }, "totals": { - "errors": 2, - "fixable": 2, + "errors": 4, + "fixable": 4, "warnings": 0 } } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/InputFileForIssues.php index 4265076..53a8a7b 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/InputFileForIssues.php +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/InputFileForIssues.php @@ -29,3 +29,9 @@ if (is_a($a, 't3lib_Singleton')) { if (is_a($a, '\t3lib_Singleton')) { // do something } +if (is_a($a, "t3lib_Singleton")) { + // do something +} +if (is_a($a, "\\t3lib_Singleton")) { + // do something +} From 21cf62b94934af51e6e00522e3e9ee7d64de03ef Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 15:09:32 +0200 Subject: [PATCH 058/100] TASK: migrate InheritanceSniff Relates: #72 --- .../Typo3Update/Sniffs/Classname/InheritanceSniff.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff.php index aa5f134..d9096f1 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff.php @@ -79,11 +79,6 @@ class Typo3Update_Sniffs_Classname_InheritanceSniff extends AbstractClassnameChe } foreach ($interfaces as $interface) { - // TODO: Migrate - if (! $this->isLegacyClassname($interface)) { - continue; - } - $position = $phpcsFile->findNext(T_STRING, $stackPtr, null, false, $interface); if ($position === false) { continue; From 2cc21fdafaae0d6071132d7577140eafb8d89811 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 15:20:35 +0200 Subject: [PATCH 059/100] TASK: Cleanup code * Remove unnecessary documentation. * Remove unused code. * Add missing documentation. Relates: #72 --- .../Typo3Update/Feature/FeatureInterface.php | 2 +- .../Typo3Update/Feature/Features.php | 5 +++- .../Typo3Update/Feature/FeaturesSupport.php | 15 +++++++++- .../Feature/LegacyClassnameFeature.php | 16 ++--------- .../Classname/AbstractClassnameChecker.php | 3 ++ .../Sniffs/Classname/InheritanceSniff.php | 8 +----- .../Sniffs/Classname/InlineCommentSniff.php | 28 +------------------ .../Sniffs/Classname/InstanceofSniff.php | 7 +---- .../InstantiationWithMakeInstanceSniff.php | 16 ----------- .../Classname/InstantiationWithNewSniff.php | 3 -- .../InstantiationWithObjectManagerSniff.php | 3 -- .../Sniffs/Classname/IsACallSniff.php | 3 -- .../Sniffs/Classname/StaticCallSniff.php | 3 -- .../Classname/TypeHintCatchExceptionSniff.php | 3 -- .../Sniffs/Classname/TypeHintSniff.php | 3 -- 15 files changed, 27 insertions(+), 91 deletions(-) diff --git a/src/Standards/Typo3Update/Feature/FeatureInterface.php b/src/Standards/Typo3Update/Feature/FeatureInterface.php index 36d63c7..39de10c 100644 --- a/src/Standards/Typo3Update/Feature/FeatureInterface.php +++ b/src/Standards/Typo3Update/Feature/FeatureInterface.php @@ -23,7 +23,7 @@ namespace Typo3Update\Feature; use PHP_CodeSniffer_File as PhpCsFile; /** - * + * See "Features" in documentation. */ interface FeatureInterface { diff --git a/src/Standards/Typo3Update/Feature/Features.php b/src/Standards/Typo3Update/Feature/Features.php index 996f012..ac6ee42 100644 --- a/src/Standards/Typo3Update/Feature/Features.php +++ b/src/Standards/Typo3Update/Feature/Features.php @@ -24,13 +24,16 @@ use PHP_CodeSniffer_Sniff as PhpCsSniff; use Typo3Update\Options; /** - * + * Contains all configured features for a single sniff. */ class Features implements \Iterator { protected $index = 0; protected $features = []; + /** + * @param PhpCsSniff $sniff The sniff to collect features for. + */ public function __construct(PhpCsSniff $sniff) { foreach (Options::getFeaturesConfiguration() as $featureName => $sniffs) { diff --git a/src/Standards/Typo3Update/Feature/FeaturesSupport.php b/src/Standards/Typo3Update/Feature/FeaturesSupport.php index fa71785..2f84bc7 100644 --- a/src/Standards/Typo3Update/Feature/FeaturesSupport.php +++ b/src/Standards/Typo3Update/Feature/FeaturesSupport.php @@ -23,7 +23,7 @@ namespace Typo3Update\Feature; use PHP_CodeSniffer_File as PhpCsFile; /** - * Provides "feature" support for sniff. + * Provides "feature" support for sniffs. */ trait FeaturesSupport { @@ -37,6 +37,13 @@ trait FeaturesSupport $this->features = new Features($this); } + /** + * Processes all features for the sniff. + * + * @param PhpCsFile $phpcsFile + * @param int $stackPtr + * @param string $content + */ public function processFeatures(PhpCsFile $phpcsFile, $stackPtr, $content) { foreach ($this->features as $featureClassName) { @@ -45,6 +52,12 @@ trait FeaturesSupport } } + /** + * Create a new instance of the given feature. + * + * @param string $featureClassname + * @return FeatureInterface + */ protected function createFeature($featureClassname) { return new $featureClassname($this); diff --git a/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php index 269650c..4612e6d 100644 --- a/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php +++ b/src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php @@ -25,7 +25,9 @@ use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Sniff as PhpCsSniff; /** + * This feature will add fixable errors for old legacy classnames. * + * Can be attached to sniffs returning classnames. */ class LegacyClassnameFeature implements FeatureInterface { @@ -131,20 +133,6 @@ class LegacyClassnameFeature implements FeatureInterface return $this->legacyMapping->getNewClassname($classname); } - /** - * Use to add new mappings found during parsing. - * E.g. in MissingNamespaceSniff old class definitions are fixed and a new mapping exists afterwards. - * - * @param string $legacyClassname - * @param string $newClassname - * - * @return void - */ - protected function addLegacyClassname($legacyClassname, $newClassname) - { - $this->legacyMapping->addLegacyClassname($legacyClassname, $newClassname); - } - /** * Add an warning if given $classname is maybe legacy. * diff --git a/src/Standards/Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php b/src/Standards/Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php index dbc60b2..e405fdc 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/AbstractClassnameChecker.php @@ -26,6 +26,9 @@ use Typo3Update\Feature\FeaturesSupport; /** * Provide common uses for all sniffs, regarding class name checks. + * + * Will do nothing but calling configured features, allowing new extending + * sniffs to find further class names. */ abstract class AbstractClassnameChecker implements PhpCsSniff { diff --git a/src/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff.php index d9096f1..2ce6d36 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff.php @@ -22,9 +22,6 @@ use PHP_CodeSniffer_File as PhpCsFile; use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; -/** - * Detect and migrate extend and implement of old legacy classnames. - */ class Typo3Update_Sniffs_Classname_InheritanceSniff extends AbstractClassnameChecker { /** @@ -34,10 +31,7 @@ class Typo3Update_Sniffs_Classname_InheritanceSniff extends AbstractClassnameChe */ public function register() { - return [ - T_EXTENDS, - T_IMPLEMENTS, - ]; + return [T_EXTENDS, T_IMPLEMENTS]; } /** diff --git a/src/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff.php index 7f1b58c..676dad9 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff.php @@ -22,9 +22,6 @@ use PHP_CodeSniffer_File as PhpCsFile; use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; -/** - * Migrate PHP inline comments, e.g. for IDEs. - */ class Typo3Update_Sniffs_Classname_InlineCommentSniff extends AbstractClassnameChecker { /** @@ -34,9 +31,7 @@ class Typo3Update_Sniffs_Classname_InlineCommentSniff extends AbstractClassnameC */ public function register() { - return [ - T_COMMENT, - ]; + return [T_COMMENT]; } /** @@ -77,25 +72,4 @@ class Typo3Update_Sniffs_Classname_InlineCommentSniff extends AbstractClassnameC return 3; } - - /** - * As token contains more then just class name, we have to build new content ourself. - * - * @param string $newClassname - * @param string $originalClassname - * @param PhpCsFile $phpcsFile - * @return string - */ - protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile) - { - $token = preg_split('/\s+/', $this->originalTokenContent); - $token[$this->getClassnamePosition($token)] = $newClassname; - - // Keep line ending, removed by preg_split - if ($token[0] === '//') { - $token[count($token)] = $phpcsFile->eolChar; - } - - return implode(' ', $token); - } } diff --git a/src/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff.php index 07fd90a..b6a4640 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff.php @@ -21,9 +21,6 @@ use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; -/** - * Detect and migrate instanceof checks of old legacy classnames. - */ class Typo3Update_Sniffs_Classname_InstanceofSniff extends AbstractClassnameChecker { /** @@ -33,8 +30,6 @@ class Typo3Update_Sniffs_Classname_InstanceofSniff extends AbstractClassnameChec */ public function register() { - return [ - T_INSTANCEOF, - ]; + return [T_INSTANCEOF]; } } diff --git a/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff.php index ee71469..070162a 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff.php @@ -23,9 +23,6 @@ use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Tokens as Tokens; use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; -/** - * Detect and migrate instantiations of old legacy classnames using "makeInstance". - */ class Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff extends AbstractClassnameChecker { use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; @@ -69,17 +66,4 @@ class Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff extends Ab $this->originalTokenContent = $tokens[$classnamePosition]['content']; $this->processFeatures($phpcsFile, $classnamePosition, $classname); } - - /** - * As token contains more then just class name, we have to build new content ourself. - * - * @param string $newClassname - * @param string $originalClassname - * @param PhpCsFile $phpcsFile - * @return string - */ - protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile) - { - return $this->getTokenReplacementForString($newClassname); - } } diff --git a/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff.php index be836f5..37313c7 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff.php @@ -21,9 +21,6 @@ use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; -/** - * Detect and migrate old legacy classnames instantiations using phps "new". - */ class Typo3Update_Sniffs_Classname_InstantiationWithNewSniff extends AbstractClassnameChecker { /** diff --git a/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff.php index 14afa1e..7843243 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff.php @@ -23,9 +23,6 @@ use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Tokens as Tokens; use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; -/** - * Detect and migrate old legacy classname instantiations using objectmanager create and get. - */ class Typo3Update_Sniffs_Classname_InstantiationWithObjectManagerSniff extends AbstractClassnameChecker { use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; diff --git a/src/Standards/Typo3Update/Sniffs/Classname/IsACallSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/IsACallSniff.php index 06ac05c..7888d01 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/IsACallSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/IsACallSniff.php @@ -22,9 +22,6 @@ use PHP_CodeSniffer_File as PhpcsFile; use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; -/** - * Detect and migrate instantiations of old legacy classnames using "makeInstance". - */ class Typo3Update_Sniffs_Classname_IsACallSniff extends AbstractClassnameChecker { use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; diff --git a/src/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff.php index 7e99447..ded2b6d 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff.php @@ -21,9 +21,6 @@ use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; -/** - * Detect and migrate static calls to old legacy classnames. - */ class Typo3Update_Sniffs_Classname_StaticCallSniff extends AbstractClassnameChecker { /** diff --git a/src/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff.php index 2242e6b..231b676 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff.php @@ -21,9 +21,6 @@ use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; -/** - * Migrate Typehints in catch statements. - */ class Typo3Update_Sniffs_Classname_TypeHintCatchExceptionSniff extends AbstractClassnameChecker { /** diff --git a/src/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff.php b/src/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff.php index 7d08f16..05f49c1 100644 --- a/src/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff.php @@ -22,9 +22,6 @@ use PHP_CodeSniffer_File as PhpCsFile; use Typo3Update\Sniffs\Classname\AbstractClassnameChecker; -/** - * Migrate Typehints in function / method definitions. - */ class Typo3Update_Sniffs_Classname_TypeHintSniff extends AbstractClassnameChecker { /** From 22d50486cf51bf8cda82eedc2d9cc2925b36be2c Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 15:35:24 +0200 Subject: [PATCH 060/100] TASK: Remove unused intersphinx * As long as we don't make use of intersphinx disable it to speed up rendering of documentation. --- Documentation/source/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/source/conf.py b/Documentation/source/conf.py index 406a886..0e40853 100644 --- a/Documentation/source/conf.py +++ b/Documentation/source/conf.py @@ -29,7 +29,7 @@ import os # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.intersphinx', + # 'sphinx.ext.intersphinx', 'sphinx.ext.todo', ] @@ -310,4 +310,4 @@ texinfo_documents = [ # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/': None} +# intersphinx_mapping = {'https://docs.python.org/': None} From 28329844b880f31a5dc81ebb8552c48d34ba75b5 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 15:36:20 +0200 Subject: [PATCH 061/100] TASK: Update docs * To keep naming in sync with code, to make examples work. --- Documentation/source/configuration.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst index 6209816..49a00ba 100644 --- a/Documentation/source/configuration.rst +++ b/Documentation/source/configuration.rst @@ -28,13 +28,13 @@ Configures which extension names are legacy. Used to provide further checks and possible legacy code. All class usages starting with ``Tx_`` where ExtensionName is defined in this array, will produce a warning, until the class is already found to be deprecaed. -Can and have to be configured for each sniff, e.g. ``Instanceof`` and ``DocComment``. +Can and have to be configured for each sniff, e.g. ``Instanceof`` and ``PhpDocComment``. Example: .. code:: xml - + @@ -46,7 +46,7 @@ Example: allowedTags ----------- -Only used inside Sniff ``Typo3Update.LegacyClassnames.DocComment``. +Only used inside Sniff ``Typo3Update.Classname.PhpDocComment``. Configures which tags are checked for legacy class names. @@ -57,7 +57,7 @@ Example: .. code:: xml - + From 5428b3805fd3b8ce50ca44e76565ca0d64e1d765 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 15:36:47 +0200 Subject: [PATCH 062/100] TASK: Document new feature in docs --- Documentation/source/configuration.rst | 21 +++++++++++++++++++++ Documentation/source/extending.rst | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst index 49a00ba..94c1d55 100644 --- a/Documentation/source/configuration.rst +++ b/Documentation/source/configuration.rst @@ -156,3 +156,24 @@ Example: .. code:: bash --runtime-set removedConstantConfigFiles "/Some/Absolute/Path/*.yaml" + +.. _configuration-features: + +features +-------- + +Configure where to look for configuration files defining the feature mappings. Default is +``Configuration/Features/*.yaml`` inside the standard itself. Globing is used, so placeholders like +``*`` are possible, see https://secure.php.net/manual/en/function.glob.php + +Using :file:`ruleset.xml`: + +.. code:: xml + + + +Example: + +.. code:: bash + + --runtime-set features "/Some/Absolute/Path/*.yaml" diff --git a/Documentation/source/extending.rst b/Documentation/source/extending.rst index 05748bb..8ae8d32 100644 --- a/Documentation/source/extending.rst +++ b/Documentation/source/extending.rst @@ -24,6 +24,24 @@ The following resources might be helpful during working with ``phpcs``: - :file:`CodeSniffer/File.php` +.. _extending-features: + +Features +-------- + +Sniffs do not always add errors or warnings in our standard, instead for more flexibility, we use +them to find specific "tokens", e.g. class names. We then attach so called *Features* to sniffs to +work on that token. + +E.g. we deliver the Feature ``LegacyClassnameFeature`` which will check whether a given class name +is legacy and should be replaced. As class names may occur in many places like type hints or php doc +blocks, the sniffs will detect the class names and the feature will work on them. + +Features can be attached to the sniffs. A feature has to implement the ``FeatureInterface`` and will +work on tokens found by sniffs. + +To attach a Feature to Sniffs, provide a yaml-configuration, see :ref:`configuration-features`. + .. _extending-tests: Tests From add747d0bed5e3aa1ed7f625656b415a74c4d9d7 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 15:37:01 +0200 Subject: [PATCH 063/100] TASK: Fix type of headline in docs --- Documentation/source/extending.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/source/extending.rst b/Documentation/source/extending.rst index 8ae8d32..cf899ba 100644 --- a/Documentation/source/extending.rst +++ b/Documentation/source/extending.rst @@ -58,7 +58,7 @@ has to exist: :file:`tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname .. _extending-tests-single: Single test per sniff ---------------------- +^^^^^^^^^^^^^^^^^^^^^ Inside of the folder at least a file :file:`InputFileForIssues.php` has to exist, containing PHP code to use for the test. Also a file :file:`Expected.json` has to exist, with the json result of @@ -72,7 +72,7 @@ If your sniff also implements fixable errors or warnings, you can further provid .. _extending-tests-multiple: Multiple tests per sniff ------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^ Also it's possible to provide multiple tests for a single sniff, e.g. with different cli arguments like options for the sniff. In that case you have to place a :file:`Arguments.php` in the folder. @@ -99,7 +99,7 @@ Also you can provide further cli arguments on a key -> value base. Where ``runti as it contains a sub array to provide multiple runtime sets. How sniff tests are implemented -------------------------------- +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ We just find all folders below :file:`tests/Fixtures/Standards/Typo3Update/Sniffs` ending with ``Sniff`` and check the structure. They are provided to the test itself through a dataprovider in From 27997c8445ec681e185d02be0c921192efed05bc Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 15:37:16 +0200 Subject: [PATCH 064/100] TASK: Link to configuration in docs. --- Documentation/source/features.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/source/features.rst b/Documentation/source/features.rst index a042484..e055e92 100644 --- a/Documentation/source/features.rst +++ b/Documentation/source/features.rst @@ -98,10 +98,10 @@ Also we check for the following deprecated calls: Check for usage of *removed functions* in general. The functions are configured via yaml files. The location of them is configurable, default is inside the standard itself, and we try to deliver all -information. For configuration options see ``removedFunctionConfigFiles``. +information. For configuration options see :ref:`configuration-removedFunctionConfigFiles`. Check for usage of *removed constants*. The constants are configured in same way as removed -functions. For configuration options see ``removedConstantConfigFiles``. +functions. For configuration options see :ref:`configuration-removedConstantConfigFiles`. Further checks From 7f7a7aa38d335a632abd66b5496ad8709e1bcfa7 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 16:35:54 +0200 Subject: [PATCH 065/100] TASK: Add missing docs --- src/Standards/Typo3Update/Feature/Features.php | 9 +++++++++ src/Standards/Typo3Update/Options.php | 5 +++++ .../MissingNamespaceSniff/nothingTodo/Expected.diff | 0 3 files changed, 14 insertions(+) create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/Expected.diff diff --git a/src/Standards/Typo3Update/Feature/Features.php b/src/Standards/Typo3Update/Feature/Features.php index ac6ee42..386b99c 100644 --- a/src/Standards/Typo3Update/Feature/Features.php +++ b/src/Standards/Typo3Update/Feature/Features.php @@ -28,7 +28,16 @@ use Typo3Update\Options; */ class Features implements \Iterator { + /** + * Internal array position for \Iterator implementation. + * @var int + */ protected $index = 0; + + /** + * Internal array + * @var array + */ protected $features = []; /** diff --git a/src/Standards/Typo3Update/Options.php b/src/Standards/Typo3Update/Options.php index 6aba777..c5f8a9d 100644 --- a/src/Standards/Typo3Update/Options.php +++ b/src/Standards/Typo3Update/Options.php @@ -100,6 +100,11 @@ class Options return $option; } + /** + * Get the configured features. + * + * @return array + */ public static function getFeaturesConfiguration() { $option = []; diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/Expected.diff new file mode 100644 index 0000000..e69de29 From 370015e7c057afb306978b0f95a2ff685d2b1600 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 16:36:12 +0200 Subject: [PATCH 066/100] TASK: Refactor code * Reduce indentation. * Provide internal API to add new feature with necessary checks. --- .../Typo3Update/Feature/Features.php | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Standards/Typo3Update/Feature/Features.php b/src/Standards/Typo3Update/Feature/Features.php index 386b99c..4db9e97 100644 --- a/src/Standards/Typo3Update/Feature/Features.php +++ b/src/Standards/Typo3Update/Feature/Features.php @@ -47,17 +47,29 @@ class Features implements \Iterator { foreach (Options::getFeaturesConfiguration() as $featureName => $sniffs) { if (in_array(get_class($sniff), $sniffs)) { - if (!class_implements($featureName, FeatureInterface::class)) { - throw new \Exception( - 'Configured Feature "' . $featureName . '" does not implement "' . FeatureInterface::class . '".', - 1493115488 - ); - } - $this->features[] = $featureName; + $this->addFeature($featureName); } } } + /** + * Add the given feature. + * + * @param string $featureName + * @return void + */ + protected function addFeature($featureName) + { + if (!class_implements($featureName, FeatureInterface::class)) { + throw new \Exception( + 'Configured Feature "' . $featureName . '" does not implement "' . FeatureInterface::class . '".', + 1493115488 + ); + } + + $this->features[] = $featureName; + } + // implement Iterator interface: public function current() { From e4f26abe71bb6d692e92ab17fe71bf07b3a1501e Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 16:36:41 +0200 Subject: [PATCH 067/100] TASK: Add test case * Also test that we don't modify working parts --- .../MissingNamespaceSniff/Arguments.php | 1 + .../nothingTodo/Expected.json | 14 ++++++++++ .../nothingTodo/InputFileForIssues.php | 28 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/Expected.json create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/InputFileForIssues.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/Arguments.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/Arguments.php index de034c3..1cba12b 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/Arguments.php +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/Arguments.php @@ -20,6 +20,7 @@ */ return [ + 'nothingTodo' => [], 'defaultVendor' => [], 'customVendor' => [ 'runtime-set' => [ diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/Expected.json new file mode 100644 index 0000000..b703ca7 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/Expected.json @@ -0,0 +1,14 @@ +{ + "files": { + "InputFileForIssues.php": { + "errors": 0, + "messages": [], + "warnings": 0 + } + }, + "totals": { + "errors": 0, + "fixable": 0, + "warnings": 0 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/InputFileForIssues.php new file mode 100644 index 0000000..8f90a27 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/nothingTodo/InputFileForIssues.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Tx_Extbase_Mvc_Controller_ActionController; + +class Frontendcontroller extends Tx_Extbase_Mvc_Controller_ActionController +{ +} From cecfe983e06d5ee39fe30e19cfdbc5f7a4a71020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 27 Apr 2017 10:17:05 +0200 Subject: [PATCH 068/100] TASK: Simplfy feature support trait --- src/Standards/Typo3Update/Feature/FeaturesSupport.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Standards/Typo3Update/Feature/FeaturesSupport.php b/src/Standards/Typo3Update/Feature/FeaturesSupport.php index 2f84bc7..26975c5 100644 --- a/src/Standards/Typo3Update/Feature/FeaturesSupport.php +++ b/src/Standards/Typo3Update/Feature/FeaturesSupport.php @@ -28,13 +28,11 @@ use PHP_CodeSniffer_File as PhpCsFile; trait FeaturesSupport { /** - * @var Features + * @return Features */ - protected $features; - - public function __construct() + protected function getFeatures() { - $this->features = new Features($this); + return new Features($this); } /** @@ -46,7 +44,7 @@ trait FeaturesSupport */ public function processFeatures(PhpCsFile $phpcsFile, $stackPtr, $content) { - foreach ($this->features as $featureClassName) { + foreach ($this->getFeatures() as $featureClassName) { $feature = $this->createFeature($featureClassName); $feature->process($phpcsFile, $stackPtr, $content); } From 7398caa099da59fd0ef43ed3b8316e1b5decaca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 27 Apr 2017 10:23:02 +0200 Subject: [PATCH 069/100] =?UTF-8?q?TASK:=20Simplfy=20=E2=80=9Cfeatures"=20?= =?UTF-8?q?iterator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Standards/Typo3Update/Feature/Features.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Standards/Typo3Update/Feature/Features.php b/src/Standards/Typo3Update/Feature/Features.php index 4db9e97..befea8f 100644 --- a/src/Standards/Typo3Update/Feature/Features.php +++ b/src/Standards/Typo3Update/Feature/Features.php @@ -28,12 +28,6 @@ use Typo3Update\Options; */ class Features implements \Iterator { - /** - * Internal array position for \Iterator implementation. - * @var int - */ - protected $index = 0; - /** * Internal array * @var array @@ -73,22 +67,22 @@ class Features implements \Iterator // implement Iterator interface: public function current() { - return $this->features[$this->index]; + return current($this->features); } public function key() { - return $this->index; + return key($this->features); } public function next() { - ++$this->index; + next($this->features); } public function rewind() { - $this->index = 0; + reset($this->features); } public function valid() { - return isset($this->features[$this->index]); + return current($this->features) !== false; } } From f972533e04e3e5c65cb8ad5c054351bd358768c1 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 25 Apr 2017 09:22:50 +0200 Subject: [PATCH 070/100] WIP|FEATURE: Check for removed php classes. * Add feature to existing code base and logic, see #72 . * Add first removed classes for TYPO3 7.0 as example. * Adjust first test to make sure basic implementation works. Relates: #41 --- .../Configuration/Features/RemovedClass.yaml | 14 + .../Configuration/Removed/Classes/7.0.yaml | 11 + .../Feature/RemovedByYamlConfiguration.php | 294 ++++++++++++++++++ .../Feature/RemovedClassFeature.php | 56 ++++ src/Standards/Typo3Update/Options.php | 13 + .../PhpDocCommentSniff/Expected.diff | 3 +- .../PhpDocCommentSniff/Expected.json | 17 +- .../PhpDocCommentSniff/InputFileForIssues.php | 1 + 8 files changed, 404 insertions(+), 5 deletions(-) create mode 100644 src/Standards/Typo3Update/Configuration/Features/RemovedClass.yaml create mode 100644 src/Standards/Typo3Update/Configuration/Removed/Classes/7.0.yaml create mode 100644 src/Standards/Typo3Update/Feature/RemovedByYamlConfiguration.php create mode 100644 src/Standards/Typo3Update/Feature/RemovedClassFeature.php diff --git a/src/Standards/Typo3Update/Configuration/Features/RemovedClass.yaml b/src/Standards/Typo3Update/Configuration/Features/RemovedClass.yaml new file mode 100644 index 0000000..1b7974f --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Features/RemovedClass.yaml @@ -0,0 +1,14 @@ +Typo3Update\Feature\RemovedClassFeature: + - Typo3Update_Sniffs_Classname_InheritanceSniff + - Typo3Update_Sniffs_Classname_InlineCommentSniff + - Typo3Update_Sniffs_Classname_InstanceofSniff + - Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff + - Typo3Update_Sniffs_Classname_InstantiationWithNewSniff + - Typo3Update_Sniffs_Classname_InstantiationWithObjectManagerSniff + - Typo3Update_Sniffs_Classname_IsACallSniff + - Typo3Update_Sniffs_Classname_MissingVendorForPluginsAndModulesSniff + - Typo3Update_Sniffs_Classname_PhpDocCommentSniff + - Typo3Update_Sniffs_Classname_StaticCallSniff + - Typo3Update_Sniffs_Classname_TypeHintCatchExceptionSniff + - Typo3Update_Sniffs_Classname_TypeHintSniff + - Typo3Update_Sniffs_Classname_UseSniff diff --git a/src/Standards/Typo3Update/Configuration/Removed/Classes/7.0.yaml b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.0.yaml new file mode 100644 index 0000000..2341204 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.0.yaml @@ -0,0 +1,11 @@ +# Breaking changes in 7.0: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Index.html#breaking-changes +'7.0': + \TYPO3\CMS\Backend\Template\MediumDocumentTemplate: + replacement: 'Use \TYPO3\CMS\Backend\Template\DocumentTemplate instead' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61782-DeprecatedDocumentTemplateClassesRemoved.html' + \TYPO3\CMS\Backend\Template\SmallDocumentTemplate: + replacement: 'Use \TYPO3\CMS\Backend\Template\DocumentTemplate instead' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61782-DeprecatedDocumentTemplateClassesRemoved.html' + \TYPO3\CMS\Backend\Template\StandardDocumentTemplate: + replacement: 'Use \TYPO3\CMS\Backend\Template\DocumentTemplate instead' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61782-DeprecatedDocumentTemplateClassesRemoved.html' diff --git a/src/Standards/Typo3Update/Feature/RemovedByYamlConfiguration.php b/src/Standards/Typo3Update/Feature/RemovedByYamlConfiguration.php new file mode 100644 index 0000000..53f28a5 --- /dev/null +++ b/src/Standards/Typo3Update/Feature/RemovedByYamlConfiguration.php @@ -0,0 +1,294 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use PHP_CodeSniffer_File as PhpCsFile; +use PHP_CodeSniffer_Sniff as PhpCsSniff; +use PHP_CodeSniffer_Tokens as Tokens; +use Symfony\Component\Yaml\Yaml; +use Typo3Update\Options; + +/** + * Contains common functionality for removed code like constants or functions. + * + * Removed parts are configured using YAML-Files, for examples see + * src/Standards/Typo3Update/Configuration/Removed/Constants/7.0.yaml Also + * check out the configuration options in Readme.rst. + */ +abstract class AbstractGenericUsage implements PhpCsSniff +{ + use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; + + /** + * Configuration to define removed code. + * + * @var array + */ + protected $configured = []; + + /** + * Constant for the current sniff instance. + * @var array + */ + protected $removed = []; + + public function __construct() + { + if ($this->configured === []) { + foreach ($this->getRemovedConfigFiles() as $file) { + $this->configured = array_merge( + $this->configured, + $this->prepareStructure(Yaml::parse(file_get_contents((string) $file))) + ); + } + } + } + + /** + * Return file names containing removed configurations. + * + * @return array + */ + abstract protected function getRemovedConfigFiles(); + + /** + * Prepares structure from config for later usage. + * + * @param array $typo3Versions + * @return array + */ + protected function prepareStructure(array $typo3Versions) + { + $newStructure = []; + + foreach ($typo3Versions as $typo3Version => $removals) { + foreach ($removals as $removed => $config) { + // Split static methods and methods. + $split = preg_split('/::|->/', $removed); + + $newStructure[$removed] = $config; + + $newStructure[$removed]['static'] = strpos($removed, '::') !== false; + $newStructure[$removed]['fqcn'] = null; + $newStructure[$removed]['class'] = null; + $newStructure[$removed]['name'] = $split[0]; + $newStructure[$removed]['version_removed'] = $typo3Version; + + // If split contains two parts, it's a class + if (isset($split[1])) { + $newStructure[$removed]['fqcn'] = $split[0]; + $newStructure[$removed]['class'] = array_slice( + explode('\\', $newStructure[$removed]['fqcn']), + -1 + )[0]; + $newStructure[$removed]['name'] = $split[1]; + } + }; + } + + return $newStructure; + } + + /** + * Processes the tokens that this sniff is interested in. + * + * This is the default implementation, as most of the time next T_STRING is + * the class name. This way only the register method has to be registered + * in default cases. + * + * @param PhpCsFile $phpcsFile The file where the token was found. + * @param int $stackPtr The position in the stack where + * the token was found. + * + * @return void + */ + public function process(PhpCsFile $phpcsFile, $stackPtr) + { + if (!$this->isRemoved($phpcsFile, $stackPtr)) { + return; + } + + $this->addMessage($phpcsFile, $stackPtr); + } + + /** + * Check whether the current token is removed. + * + * @param PhpCsFile $phpcsFile + * @param int $stackPtr + * @return bool + */ + protected function isRemoved(PhpCsFile $phpcsFile, $stackPtr) + { + $tokens = $phpcsFile->getTokens(); + $staticPosition = $phpcsFile->findPrevious(T_WHITESPACE, $stackPtr - 1, null, true, null, true); + + $name = $tokens[$stackPtr]['content']; + $isStatic = false; + $class = false; + + if ($staticPosition !== false) { + $isStatic = $tokens[$staticPosition]['code'] === T_DOUBLE_COLON; + } + + if ($isStatic) { + $class = $phpcsFile->findPrevious(T_STRING, $staticPosition, null, false, null, true); + if ($class !== false) { + $class = $tokens[$class]['content']; + } + } + + $this->removed = $this->getMatchingRemoved($name, $class, $isStatic); + return $this->removed !== []; + } + + /** + * Returns all matching removed functions for given arguments. + * + * @param string $name + * @param string $className The last part of the class name, splitted by namespaces. + * @param bool $isStatic + * + * @return array + */ + protected function getMatchingRemoved($name, $className, $isStatic) + { + // We will not match any static calls, without the class name, at least for now. + if ($isStatic === true && $className === false) { + return []; + } + + return array_filter( + $this->configured, + function ($config) use ($name, $isStatic, $className) { + return $name === $config['name'] + && $isStatic === $config['static'] + && ( + $className === $config['class'] + || $className === false + ) + ; + } + ); + } + + /** + * Add message for the given token position. + * + * Default is a warning, non fixable. Just overwrite in concrete sniff, if + * something different suites better. + * + * @param PhpCsFile $phpcsFile + * @param int $tokenPosition + * + * @return void + */ + protected function addMessage(PhpCsFile $phpcsFile, $tokenPosition) + { + foreach ($this->removed as $constant) { + $phpcsFile->addWarning( + 'Legacy calls are not allowed; found %s. Removed in %s. %s. See: %s', + $tokenPosition, + $this->getIdentifier($constant), + [ + $this->getOldUsage($constant), + $this->getRemovedVersion($constant), + $this->getReplacement($constant), + $this->getDocsUrl($constant), + ] + ); + } + } + + /** + * Identifier for configuring this specific error / warning through PHPCS. + * + * @param array $config + * + * @return string + */ + protected function getIdentifier(array $config) + { + $name = $config['name']; + if ($config['class']) { + $name = $config['class'] . '.' . $name; + } + + return $name; + } + + /** + * The original call, to allow user to check matches. + * + * As we match the name, that can be provided by multiple classes, you + * should provide an example, so users can check that this is the legacy + * one. + * + * @param array $config + * + * @return string + */ + abstract protected function getOldUsage(array $config); + + /** + * Returns TYPO3 version when the breaking change happened. + * + * To let user decide whether this is important for him. + * + * @param array $config + * + * @return string + */ + protected function getRemovedVersion(array $config) + { + return $config['version_removed']; + } + + /** + * The new call, or information how to migrate. + * + * To provide feedback for user to ease migration. + * + * @param array $config + * + * @return string + */ + protected function getReplacement(array $config) + { + $newCall = $config['replacement']; + if ($newCall !== null) { + return $newCall; + } + return 'There is no replacement, just remove call'; + } + + /** + * Allow user to lookup the official docs related to this deprecation / breaking change. + * + * @param array $config The converted structure for a single constant. + * + * @return string + */ + protected function getDocsUrl(array $config) + { + return $config['docsUrl']; + } +} diff --git a/src/Standards/Typo3Update/Feature/RemovedClassFeature.php b/src/Standards/Typo3Update/Feature/RemovedClassFeature.php new file mode 100644 index 0000000..d81c34d --- /dev/null +++ b/src/Standards/Typo3Update/Feature/RemovedClassFeature.php @@ -0,0 +1,56 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use PHP_CodeSniffer as PhpCs; +use PHP_CodeSniffer_File as PhpCsFile; +use PHP_CodeSniffer_Sniff as PhpCsSniff; + +/** + * This feature will add fixable errors for old legacy classnames. + * + * Can be attached to sniffs returning classnames. + */ +class RemovedClassFeature implements FeatureInterface +{ + /** + * Process like a PHPCS Sniff. + * + * @param PhpCsFile $phpcsFile + * @param int $classnamePosition + * @param string $classname + * + * @return void + */ + public function process(PhpCsFile $phpcsFile, $classnamePosition, $classname) + { + if ($this->isClassnameRemoved($classname) === false) { + return; + } + + $phpcsFile->addError( + 'Removed classes are not allowed; found "%s", use "%s" instead', + $classnamePosition, + 'removedClassname', + [$classname] + ); + } +} diff --git a/src/Standards/Typo3Update/Options.php b/src/Standards/Typo3Update/Options.php index 1ce768c..935da03 100644 --- a/src/Standards/Typo3Update/Options.php +++ b/src/Standards/Typo3Update/Options.php @@ -95,6 +95,19 @@ class Options ); } + /** + * Returns an array of absolute file names containing removed class configurations. + * + * @return array + */ + public static function getRemovedClassConfigFiles() + { + return static::getOptionFileNames( + 'removedClassConfigFiles', + __DIR__ . '/../Configuration/Removed/Classes/*.yaml' + ); + } + /** * Get the option by optionName, if not defined, use default. * diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.diff index 807e03e..36a8cf7 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.diff @@ -1,6 +1,6 @@ --- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php +++ PHP_CodeSniffer -@@ -22,19 +22,19 @@ +@@ -22,20 +22,20 @@ class InputFileForIssues { /** @@ -13,6 +13,7 @@ /** - * @param t3lib_div + * @param \TYPO3\CMS\Core\Utility\GeneralUtility + * @param \TYPO3\CMS\Backend\Template\MediumDocumentTemplate * - * @return Tx_Extbase_Configuration_Configurationmanager + * @return \TYPO3\CMS\Extbase\Configuration\ConfigurationManager diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json index dc72038..c528d04 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json @@ -21,10 +21,19 @@ "source": "Typo3Update.Classname.PhpDocComment.legacyClassname", "type": "ERROR" }, + { + "column": 15, + "fixable": false, + "line": 32, + "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Backend\\Template\\MediumDocumentTemplate. Removed in 7.0. Use \\TYPO3\\CMS\\Backend\\Template\\DocumentTemplate instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61782-DeprecatedDocumentTemplateClassesRemoved.html", + "severity": 5, + "source": "Typo3Update.LegacyClassnames.DocComment.TYPO3_CMS_Backend_Template_MediumDocumentTemplate", + "type": "WARNING" + }, { "column": 16, "fixable": true, - "line": 33, + "line": 34, "message": "Legacy classes are not allowed; found \"Tx_Extbase_Configuration_Configurationmanager\", use \"TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager\" instead", "severity": 5, "source": "Typo3Update.Classname.PhpDocComment.legacyClassname", @@ -33,19 +42,19 @@ { "column": 18, "fixable": true, - "line": 37, + "line": 38, "message": "Legacy classes are not allowed; found \"t3lib_div\", use \"TYPO3\\CMS\\Core\\Utility\\GeneralUtility\" instead", "severity": 5, "source": "Typo3Update.Classname.PhpDocComment.legacyClassname", "type": "ERROR" } ], - "warnings": 0 + "warnings": 1 } }, "totals": { "errors": 4, "fixable": 4, - "warnings": 0 + "warnings": 1 } } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php index 92acefb..7a2de67 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php @@ -29,6 +29,7 @@ class InputFileForIssues /** * @param t3lib_div + * @param \TYPO3\CMS\Backend\Template\MediumDocumentTemplate * * @return Tx_Extbase_Configuration_Configurationmanager */ From fad2a4e498e11026c99a78e17729e17e6a2f5ce2 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 11:48:59 +0200 Subject: [PATCH 071/100] FEATURE: Allow empty feature yaml files * Handle empty yaml files for features in options class. --- src/Standards/Typo3Update/Options.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Standards/Typo3Update/Options.php b/src/Standards/Typo3Update/Options.php index 935da03..6db1bd2 100644 --- a/src/Standards/Typo3Update/Options.php +++ b/src/Standards/Typo3Update/Options.php @@ -140,10 +140,11 @@ class Options ); foreach ($fileNames as $file) { - $option = array_merge( - $option, - Yaml::parse(file_get_contents((string) $file)) - ); + $content = Yaml::parse(file_get_contents((string) $file)); + if ($content === null) { + $content = []; + } + $option = array_merge($option, $content); } return $option; From 2659066e2125c83ed0abe09d5d43716215b6c3eb Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 12:50:10 +0200 Subject: [PATCH 072/100] WIP|TASK: Migrate Typo3Update_Sniffs_Removed_TypoScriptSniff * Refactor yaml based removed check architecture. * Migrate TypoScriptSniff to new architecture. Relates: #71 --- composer.json | 1 + .../Feature/RemovedByYamlConfiguration.php | 294 ------------------ .../RemovedByYamlConfiguration.php | 60 ++++ .../Sniffs/Removed/AbstractGenericUsage.php | 237 ++------------ .../Sniffs/Removed/TypoScriptSniff.php | 47 +-- 5 files changed, 96 insertions(+), 543 deletions(-) delete mode 100644 src/Standards/Typo3Update/Feature/RemovedByYamlConfiguration.php create mode 100644 src/Standards/Typo3Update/RemovedByYamlConfiguration.php diff --git a/composer.json b/composer.json index 6f9a5df..87aab93 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ ] }, "require": { + "php": "~7.1", "helmich/typo3-typoscript-parser": "1.1.*", "squizlabs/php_codesniffer": "2.8.*", "symfony/yaml": "3.2.*", diff --git a/src/Standards/Typo3Update/Feature/RemovedByYamlConfiguration.php b/src/Standards/Typo3Update/Feature/RemovedByYamlConfiguration.php deleted file mode 100644 index 53f28a5..0000000 --- a/src/Standards/Typo3Update/Feature/RemovedByYamlConfiguration.php +++ /dev/null @@ -1,294 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -use PHP_CodeSniffer_File as PhpCsFile; -use PHP_CodeSniffer_Sniff as PhpCsSniff; -use PHP_CodeSniffer_Tokens as Tokens; -use Symfony\Component\Yaml\Yaml; -use Typo3Update\Options; - -/** - * Contains common functionality for removed code like constants or functions. - * - * Removed parts are configured using YAML-Files, for examples see - * src/Standards/Typo3Update/Configuration/Removed/Constants/7.0.yaml Also - * check out the configuration options in Readme.rst. - */ -abstract class AbstractGenericUsage implements PhpCsSniff -{ - use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; - - /** - * Configuration to define removed code. - * - * @var array - */ - protected $configured = []; - - /** - * Constant for the current sniff instance. - * @var array - */ - protected $removed = []; - - public function __construct() - { - if ($this->configured === []) { - foreach ($this->getRemovedConfigFiles() as $file) { - $this->configured = array_merge( - $this->configured, - $this->prepareStructure(Yaml::parse(file_get_contents((string) $file))) - ); - } - } - } - - /** - * Return file names containing removed configurations. - * - * @return array - */ - abstract protected function getRemovedConfigFiles(); - - /** - * Prepares structure from config for later usage. - * - * @param array $typo3Versions - * @return array - */ - protected function prepareStructure(array $typo3Versions) - { - $newStructure = []; - - foreach ($typo3Versions as $typo3Version => $removals) { - foreach ($removals as $removed => $config) { - // Split static methods and methods. - $split = preg_split('/::|->/', $removed); - - $newStructure[$removed] = $config; - - $newStructure[$removed]['static'] = strpos($removed, '::') !== false; - $newStructure[$removed]['fqcn'] = null; - $newStructure[$removed]['class'] = null; - $newStructure[$removed]['name'] = $split[0]; - $newStructure[$removed]['version_removed'] = $typo3Version; - - // If split contains two parts, it's a class - if (isset($split[1])) { - $newStructure[$removed]['fqcn'] = $split[0]; - $newStructure[$removed]['class'] = array_slice( - explode('\\', $newStructure[$removed]['fqcn']), - -1 - )[0]; - $newStructure[$removed]['name'] = $split[1]; - } - }; - } - - return $newStructure; - } - - /** - * Processes the tokens that this sniff is interested in. - * - * This is the default implementation, as most of the time next T_STRING is - * the class name. This way only the register method has to be registered - * in default cases. - * - * @param PhpCsFile $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ - public function process(PhpCsFile $phpcsFile, $stackPtr) - { - if (!$this->isRemoved($phpcsFile, $stackPtr)) { - return; - } - - $this->addMessage($phpcsFile, $stackPtr); - } - - /** - * Check whether the current token is removed. - * - * @param PhpCsFile $phpcsFile - * @param int $stackPtr - * @return bool - */ - protected function isRemoved(PhpCsFile $phpcsFile, $stackPtr) - { - $tokens = $phpcsFile->getTokens(); - $staticPosition = $phpcsFile->findPrevious(T_WHITESPACE, $stackPtr - 1, null, true, null, true); - - $name = $tokens[$stackPtr]['content']; - $isStatic = false; - $class = false; - - if ($staticPosition !== false) { - $isStatic = $tokens[$staticPosition]['code'] === T_DOUBLE_COLON; - } - - if ($isStatic) { - $class = $phpcsFile->findPrevious(T_STRING, $staticPosition, null, false, null, true); - if ($class !== false) { - $class = $tokens[$class]['content']; - } - } - - $this->removed = $this->getMatchingRemoved($name, $class, $isStatic); - return $this->removed !== []; - } - - /** - * Returns all matching removed functions for given arguments. - * - * @param string $name - * @param string $className The last part of the class name, splitted by namespaces. - * @param bool $isStatic - * - * @return array - */ - protected function getMatchingRemoved($name, $className, $isStatic) - { - // We will not match any static calls, without the class name, at least for now. - if ($isStatic === true && $className === false) { - return []; - } - - return array_filter( - $this->configured, - function ($config) use ($name, $isStatic, $className) { - return $name === $config['name'] - && $isStatic === $config['static'] - && ( - $className === $config['class'] - || $className === false - ) - ; - } - ); - } - - /** - * Add message for the given token position. - * - * Default is a warning, non fixable. Just overwrite in concrete sniff, if - * something different suites better. - * - * @param PhpCsFile $phpcsFile - * @param int $tokenPosition - * - * @return void - */ - protected function addMessage(PhpCsFile $phpcsFile, $tokenPosition) - { - foreach ($this->removed as $constant) { - $phpcsFile->addWarning( - 'Legacy calls are not allowed; found %s. Removed in %s. %s. See: %s', - $tokenPosition, - $this->getIdentifier($constant), - [ - $this->getOldUsage($constant), - $this->getRemovedVersion($constant), - $this->getReplacement($constant), - $this->getDocsUrl($constant), - ] - ); - } - } - - /** - * Identifier for configuring this specific error / warning through PHPCS. - * - * @param array $config - * - * @return string - */ - protected function getIdentifier(array $config) - { - $name = $config['name']; - if ($config['class']) { - $name = $config['class'] . '.' . $name; - } - - return $name; - } - - /** - * The original call, to allow user to check matches. - * - * As we match the name, that can be provided by multiple classes, you - * should provide an example, so users can check that this is the legacy - * one. - * - * @param array $config - * - * @return string - */ - abstract protected function getOldUsage(array $config); - - /** - * Returns TYPO3 version when the breaking change happened. - * - * To let user decide whether this is important for him. - * - * @param array $config - * - * @return string - */ - protected function getRemovedVersion(array $config) - { - return $config['version_removed']; - } - - /** - * The new call, or information how to migrate. - * - * To provide feedback for user to ease migration. - * - * @param array $config - * - * @return string - */ - protected function getReplacement(array $config) - { - $newCall = $config['replacement']; - if ($newCall !== null) { - return $newCall; - } - return 'There is no replacement, just remove call'; - } - - /** - * Allow user to lookup the official docs related to this deprecation / breaking change. - * - * @param array $config The converted structure for a single constant. - * - * @return string - */ - protected function getDocsUrl(array $config) - { - return $config['docsUrl']; - } -} diff --git a/src/Standards/Typo3Update/RemovedByYamlConfiguration.php b/src/Standards/Typo3Update/RemovedByYamlConfiguration.php new file mode 100644 index 0000000..f1ab402 --- /dev/null +++ b/src/Standards/Typo3Update/RemovedByYamlConfiguration.php @@ -0,0 +1,60 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Symfony\Component\Yaml\Yaml; + +class RemovedByYamlConfiguration +{ + /** + * Configuration to define removed code. + * + * @var array + */ + protected $configured = []; + + public function __construct(array $configFiles, $prepareStructure) + { + foreach ($configFiles as $file) { + $this->configured = array_merge( + $this->configured, + $prepareStructure(Yaml::parse(file_get_contents((string) $file))) + ); + } + } + + public function isRemoved($identifier) + { + return isset($this->configured[$identifier]); + } + + public function getRemoved($identifier) + { + if (!$this->isRemoved($identifier)) { + throw new \Exception( + sprintf('Identifier "%s" is not configured to be removed.', $identifier), + 1493289133 + ); + } + + return $this->configured[$identifier]; + } +} diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php index 3cda85a..f8e8e0a 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php @@ -22,9 +22,7 @@ namespace Typo3Update\Sniffs\Removed; use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Sniff as PhpCsSniff; -use PHP_CodeSniffer_Tokens as Tokens; -use Symfony\Component\Yaml\Yaml; -use Typo3Update\Options; +use Typo3Update\RemovedByYamlConfiguration; /** * Contains common functionality for removed code like constants or functions. @@ -35,33 +33,24 @@ use Typo3Update\Options; */ abstract class AbstractGenericUsage implements PhpCsSniff { - use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; - - /** - * Configuration to define removed code. - * - * @var array - */ - protected $configured = []; - - /** - * Entries removed in current sniff. - * @var array - */ - protected $removed = []; + protected $configured; public function __construct() { - if ($this->configured === []) { - foreach ($this->getRemovedConfigFiles() as $file) { - $this->configured = array_merge( - $this->configured, - $this->prepareStructure(Yaml::parse(file_get_contents((string) $file))) - ); - } - } + $this->configured = new RemovedByYamlConfiguration( + $this->getRemovedConfigFiles(), + \Closure::fromCallable([$this, 'prepareStructure']) + ); } + /** + * Prepares structure from config for later usage. + * + * @param array $typo3Versions + * @return array + */ + abstract protected function prepareStructure(array $typo3Versions); + /** * Return file names containing removed configurations. * @@ -69,199 +58,35 @@ abstract class AbstractGenericUsage implements PhpCsSniff */ abstract protected function getRemovedConfigFiles(); - /** - * Prepares structure from config for later usage. - * - * @param array $typo3Versions - * @return array - */ - protected function prepareStructure(array $typo3Versions) - { - $newStructure = []; + abstract protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr); - foreach ($typo3Versions as $typo3Version => $removals) { - foreach ($removals as $removed => $config) { - // Split static methods and methods. - $split = preg_split('/::|->/', $removed); - - $newStructure[$removed] = $config; - - $newStructure[$removed]['static'] = strpos($removed, '::') !== false; - $newStructure[$removed]['fqcn'] = null; - $newStructure[$removed]['class'] = null; - $newStructure[$removed]['name'] = $split[0]; - $newStructure[$removed]['version_removed'] = $typo3Version; - - // If split contains two parts, it's a class - if (isset($split[1])) { - $newStructure[$removed]['fqcn'] = $split[0]; - $newStructure[$removed]['class'] = array_slice( - explode('\\', $newStructure[$removed]['fqcn']), - -1 - )[0]; - $newStructure[$removed]['name'] = $split[1]; - } - } - } - - return $newStructure; - } - - /** - * Processes the tokens that this sniff is interested in. - * - * This is the default implementation, as most of the time next T_STRING is - * the class name. This way only the register method has to be registered - * in default cases. - * - * @param PhpCsFile $phpcsFile The file where the token was found. - * @param int $stackPtr The position in the stack where - * the token was found. - * - * @return void - */ public function process(PhpCsFile $phpcsFile, $stackPtr) { - if (!$this->isRemoved($phpcsFile, $stackPtr)) { + $removed = $this->findRemoved($phpcsFile, $stackPtr); + if ($removed === []) { return; } - $this->addMessage($phpcsFile, $stackPtr); + $this->addMessage($removed); } - /** - * Check whether the current token is removed. - * - * @param PhpCsFile $phpcsFile - * @param int $stackPtr - * @return bool - */ - protected function isRemoved(PhpCsFile $phpcsFile, $stackPtr) + protected function addMessage(array $removed) { - $tokens = $phpcsFile->getTokens(); - $staticPosition = $phpcsFile->findPrevious(T_WHITESPACE, $stackPtr - 1, null, true, null, true); - - $name = $tokens[$stackPtr]['content']; - $isStatic = false; - $class = false; - - if ($staticPosition !== false) { - $isStatic = $tokens[$staticPosition]['code'] === T_DOUBLE_COLON; - } - - if ($isStatic) { - $class = $phpcsFile->findPrevious(T_STRING, $staticPosition, null, false, null, true); - if ($class !== false) { - $class = $tokens[$class]['content']; - } - } - - $this->removed = $this->getMatchingRemoved($name, $class, $isStatic); - return $this->removed !== []; - } - - /** - * Returns all matching removed functions for given arguments. - * - * @param string $name - * @param string $className The last part of the class name, splitted by namespaces. - * @param bool $isStatic - * - * @return array - */ - protected function getMatchingRemoved($name, $className, $isStatic) - { - // We will not match any static calls, without the class name, at least for now. - if ($isStatic === true && $className === false) { - return []; - } - - return array_filter( - $this->configured, - function ($config) use ($name, $isStatic, $className) { - return $name === $config['name'] - && $isStatic === $config['static'] - && ( - $className === $config['class'] - || $className === false - ) - ; - } - ); - } - - /** - * Add message for the given token position. - * - * Default is a warning, non fixable. Just overwrite in concrete sniff, if - * something different suites better. - * - * @param PhpCsFile $phpcsFile - * @param int $tokenPosition - * - * @return void - */ - protected function addMessage(PhpCsFile $phpcsFile, $tokenPosition) - { - foreach ($this->removed as $removed) { + foreach ($removed as $removed) { $phpcsFile->addWarning( - 'Legacy calls are not allowed; found %s. Removed in %s. %s. See: %s', + 'Calls to removed code are not allowed; found %s. Removed in %s. %s. See: %s', $tokenPosition, - $this->getIdentifier($removed), + $removed['identifier'], [ - $this->getOldUsage($removed), - $this->getRemovedVersion($removed), + $removed['oldUsage'], + $removed['versionRemoved'], $this->getReplacement($removed), - $this->getDocsUrl($removed), + $removed['docsUrl'], ] ); } } - /** - * Identifier for configuring this specific error / warning through PHPCS. - * - * @param array $config - * - * @return string - */ - protected function getIdentifier(array $config) - { - $name = $config['name']; - if ($config['class']) { - $name = $config['class'] . '.' . $name; - } - - return $name; - } - - /** - * The original call, to allow user to check matches. - * - * As we match the name, that can be provided by multiple classes, you - * should provide an example, so users can check that this is the legacy - * one. - * - * @param array $config - * - * @return string - */ - abstract protected function getOldUsage(array $config); - - /** - * Returns TYPO3 version when the breaking change happened. - * - * To let user decide whether this is important for him. - * - * @param array $config - * - * @return string - */ - protected function getRemovedVersion(array $config) - { - return $config['version_removed']; - } - /** * The new call, or information how to migrate. * @@ -279,16 +104,4 @@ abstract class AbstractGenericUsage implements PhpCsSniff } return 'There is no replacement, just remove call'; } - - /** - * Allow user to lookup the official docs related to this deprecation / breaking change. - * - * @param array $config - * - * @return string - */ - protected function getDocsUrl(array $config) - { - return $config['docsUrl']; - } } diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php index 98c0cca..739f21a 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php @@ -59,7 +59,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage protected function prepareStructure(array $typo3Versions) { $newStructure = []; - foreach ($typo3Versions as $typo3Version => $removals) { foreach ($removals as $removed => $config) { $config['type'] = TokenInterface::TYPE_OBJECT_IDENTIFIER; @@ -70,7 +69,9 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage } $config['name'] = $removed; - $config['version_removed'] = $typo3Version; + $config['identifier'] = str_replace('.', '-', $removed); + $config['versionRemoved'] = $typo3Version; + $config['oldUsage'] = $removed; $newStructure[$removed] = $config; } @@ -86,48 +87,20 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage * @param int $stackPtr * @return bool */ - protected function isRemoved(PhpCsFile $phpcsFile, $stackPtr) + protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; $objectIdentifier = $token['content']; - if (isset($this->configured[$objectIdentifier]) && $token['type'] === $this->configured[$objectIdentifier]['type']) { - $this->removed = [ - $this->configured[$objectIdentifier] - ]; - return true; + if (!$this->configured->isRemoved($objectIdentifier)) { + return []; } - return false; - } - - /** - * Identifier for configuring this specific error / warning through PHPCS. - * - * @param array $config - * - * @return string - */ - protected function getIdentifier(array $config) - { - return str_replace('.', '-', $config['name']); - } - - /** - * The original call, to allow user to check matches. - * - * As we match the name, that can be provided by multiple classes, you - * should provide an example, so users can check that this is the legacy - * one. - * - * @param array $config - * - * @return string - */ - protected function getOldUsage(array $config) - { - return $config['name']; + $removed = $this->configured->getRemoved($objectIdentifier); + if ($token['type'] === $removed['type']) { + return [$removed]; + } } /** From 5704351d22dd91aac9a57402bb1f9191f18ec9b6 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 12:53:07 +0200 Subject: [PATCH 073/100] TASK: Adjust to PHP 7.1 * As PHP 7.1 is required, document and adjust tests in CI. Relates: #71 --- .gitlab-ci.yml | 10 +++------- Documentation/source/index.rst | 2 ++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 88d1918..202f4e0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,7 @@ sync:github: - git push --mirror ${MIRROR_GIT_URL} lint:coding-guideline: &PHP-LINTING - image: php:7.0-alpine + image: php:7.1-alpine stage: test script: - ./vendor/bin/phpcs -s -n --report-full=result/phpcs-full.txt --report-diff=result/phpcs-diff.txt --report-summary=result/phpcs-summary.txt @@ -41,16 +41,12 @@ lint:php-mass-detection: script: - ./vendor/bin/phpmd src text phpmd.xml > result/phpmd.txt -test:5.6: &PHP-UNITTESTING - image: php:5.6-alpine +test:7.1: &PHP-UNITTESTING + image: php:7.1-alpine stage: test script: - ./vendor/bin/phpunit -test:7.0: - <<: *PHP-UNITTESTING - image: php:7.0-alpine - test:latest: <<: *PHP-UNITTESTING image: php:7-alpine diff --git a/Documentation/source/index.rst b/Documentation/source/index.rst index 93ec3be..709f4ec 100644 --- a/Documentation/source/index.rst +++ b/Documentation/source/index.rst @@ -19,6 +19,8 @@ Requirements To install the project you need ``composer`` to be installed and inside your ``$PATH``. Otherwise run ``make install-composer`` to install composer. +At least PHP 7.1 is required. + Installation ============ From 84dd380a3ce64547f80a71277229ea3a5294db41 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 13:23:51 +0200 Subject: [PATCH 074/100] TASK: Migrate GenericFunctionCallSniff * Migrate GenericFunctionCallSniff to new architecture. * Provide new abstract class for php removed functions and constants. * Fix TypoScriptSniff not always returning array. * Adjust warnings in Expected.json Relates: #71 --- .../RemovedByYamlConfiguration.php | 5 + .../Removed/AbstractGenericPhpUsage.php | 141 ++++++++++++++++++ .../Sniffs/Removed/AbstractGenericUsage.php | 14 +- .../Removed/GenericFunctionCallSniff.php | 59 ++------ .../Sniffs/Removed/TypoScriptSniff.php | 2 + .../GenericConstantUsageSniff/Expected.json | 10 +- .../GenericFunctionCallSniff/Expected.json | 10 +- .../Removed/TypoScriptSniff/Expected.json | 18 +-- 8 files changed, 181 insertions(+), 78 deletions(-) create mode 100644 src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php diff --git a/src/Standards/Typo3Update/RemovedByYamlConfiguration.php b/src/Standards/Typo3Update/RemovedByYamlConfiguration.php index f1ab402..a527e43 100644 --- a/src/Standards/Typo3Update/RemovedByYamlConfiguration.php +++ b/src/Standards/Typo3Update/RemovedByYamlConfiguration.php @@ -46,6 +46,11 @@ class RemovedByYamlConfiguration return isset($this->configured[$identifier]); } + public function getAllRemoved() + { + return $this->configured; + } + public function getRemoved($identifier) { if (!$this->isRemoved($identifier)) { diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php new file mode 100644 index 0000000..d93645f --- /dev/null +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php @@ -0,0 +1,141 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use PHP_CodeSniffer_File as PhpCsFile; +use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; + +abstract class AbstractGenericPhpUsage extends AbstractGenericUsage +{ + use ExtendedPhpCsSupportTrait; + + protected function prepareStructure(array $typo3Versions) + { + $newStructure = []; + + foreach ($typo3Versions as $typo3Version => $removals) { + foreach ($removals as $removed => $config) { + $newStructure[$removed] = $config; + + $newStructure[$removed]['fqcn'] = null; + $newStructure[$removed]['class'] = null; + $newStructure[$removed]['versionRemoved'] = $typo3Version; + + $this->handleStatic($removed, $newStructure[$removed]); + + $newStructure[$removed]['oldUsage'] = $this->getOldUsage($newStructure[$removed]); + $newStructure[$removed]['identifier'] = $this->getIdentifier($newStructure[$removed]); + }; + } + + return $newStructure; + } + + protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) + { + if (!$this->isFunctionCall($phpcsFile, $stackPtr)) { + return []; + } + + $tokens = $phpcsFile->getTokens(); + $staticPosition = $phpcsFile->findPrevious(T_WHITESPACE, $stackPtr - 1, null, true, null, true); + + $name = $tokens[$stackPtr]['content']; + $isStatic = false; + $class = false; + + if ($staticPosition !== false) { + $isStatic = $tokens[$staticPosition]['code'] === T_DOUBLE_COLON; + } + + if ($isStatic) { + $class = $phpcsFile->findPrevious(T_STRING, $staticPosition, null, false, null, true); + if ($class !== false) { + $class = $tokens[$class]['content']; + } + } + + return $this->getMatchingRemoved($name, $class, $isStatic); + } + + /** + * Returns all matching removed functions for given arguments. + * + * @param string $name + * @param string $className The last part of the class name, splitted by namespaces. + * @param bool $isStatic + * + * @return array + */ + protected function getMatchingRemoved($name, $className, $isStatic) + { + // We will not match any static calls, without the class name, at least for now. + if ($isStatic === true && $className === false) { + return []; + } + + return array_filter( + $this->configured->getAllRemoved(), + function ($config) use ($name, $isStatic, $className) { + return $name === $config['name'] + && $isStatic === $config['static'] + && ( + $className === $config['class'] + || $className === false + ) + ; + } + ); + } + + protected function handleStatic($identifier, array &$config) + { + $split = preg_split('/::|->/', $identifier); + + $config['name'] = $split[0]; + $config['static'] = strpos($identifier, '::') !== false; + + if (isset($split[1])) { + $config['fqcn'] = $split[0]; + $config['class'] = array_slice(explode('\\', $config['fqcn']), -1)[0]; + $config['name'] = $split[1]; + } + } + + protected function getOldUsage(array $config) + { + $concat = '->'; + if ($config['static']) { + $concat = '::'; + } + return $config['fqcn'] . $concat . $config['name']; + } + + protected function getIdentifier(array $config) + { + $name = $config['name']; + if ($config['class']) { + $name = $config['class'] . '.' . $name; + } + + return $name; + } +} diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php index f8e8e0a..ff67d4f 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php @@ -62,20 +62,10 @@ abstract class AbstractGenericUsage implements PhpCsSniff public function process(PhpCsFile $phpcsFile, $stackPtr) { - $removed = $this->findRemoved($phpcsFile, $stackPtr); - if ($removed === []) { - return; - } - - $this->addMessage($removed); - } - - protected function addMessage(array $removed) - { - foreach ($removed as $removed) { + foreach ($this->findRemoved($phpcsFile, $stackPtr) as $removed) { $phpcsFile->addWarning( 'Calls to removed code are not allowed; found %s. Removed in %s. %s. See: %s', - $tokenPosition, + $stackPtr, $removed['identifier'], [ $removed['oldUsage'], diff --git a/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php index 4124eb2..7fa8a12 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php @@ -19,16 +19,25 @@ * 02110-1301, USA. */ -use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Tokens as Tokens; -use Typo3Update\Sniffs\Removed\AbstractGenericUsage; +use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage; use Typo3Update\Options; /** * Sniff that handles all calls to removed functions. */ -class Typo3Update_Sniffs_Removed_GenericFunctionCallSniff extends AbstractGenericUsage +class Typo3Update_Sniffs_Removed_GenericFunctionCallSniff extends AbstractGenericPhpUsage { + /** + * Returns the token types that this sniff is interested in. + * + * @return array + */ + public function register() + { + return [T_STRING]; + } + /** * Return file names containing removed configurations. * @@ -38,48 +47,4 @@ class Typo3Update_Sniffs_Removed_GenericFunctionCallSniff extends AbstractGeneri { return Options::getRemovedFunctionConfigFiles(); } - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return Tokens::$functionNameTokens; - } - - /** - * Check whether function at given point is removed. - * - * @return bool - */ - protected function isRemoved(PhpCsFile $phpcsFile, $stackPtr) - { - if (!$this->isFunctionCall($phpcsFile, $stackPtr)) { - return false; - } - - return parent::isRemoved($phpcsFile, $stackPtr); - } - - /** - * The original function call, to allow user to check matches. - * - * As we match the function name, that can be provided by multiple classes, - * you should provide an example, so users can check that this is the - * legacy one. - * - * @param array $config The converted structure for a single function. - * - * @return string - */ - protected function getOldUsage(array $config) - { - $concat = '->'; - if ($config['static']) { - $concat = '::'; - } - return $config['fqcn'] . $concat . $config['name']; - } } diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php index 739f21a..419b55a 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php @@ -101,6 +101,8 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage if ($token['type'] === $removed['type']) { return [$removed]; } + + return []; } /** diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json index e3072f3..6d0f5d6 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff/Expected.json @@ -7,7 +7,7 @@ "column": 9, "fixable": false, "line": 22, - "message": "Legacy calls are not allowed; found constant PATH_tslib. Removed in 7.0. The folder and constant no longer exist. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61459-RemovalTslib.html", + "message": "Calls to removed code are not allowed; found constant PATH_tslib. Removed in 7.0. The folder and constant no longer exist. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61459-RemovalTslib.html", "severity": 5, "source": "Typo3Update.Removed.GenericConstantUsage.PATH_tslib", "type": "WARNING" @@ -16,7 +16,7 @@ "column": 11, "fixable": false, "line": 23, - "message": "Legacy calls are not allowed; found constant TYPO3_MOD_PATH. Removed in 7.4. It is required to route modules through typo3/mod.php from now on in case the module relies on the definition of those constants. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-67987-RemovedEntryScriptHandling.html", + "message": "Calls to removed code are not allowed; found constant TYPO3_MOD_PATH. Removed in 7.4. It is required to route modules through typo3/mod.php from now on in case the module relies on the definition of those constants. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-67987-RemovedEntryScriptHandling.html", "severity": 5, "source": "Typo3Update.Removed.GenericConstantUsage.TYPO3_MOD_PATH", "type": "WARNING" @@ -25,7 +25,7 @@ "column": 75, "fixable": false, "line": 24, - "message": "Legacy calls are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", + "message": "Calls to removed code are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", "severity": 5, "source": "Typo3Update.Removed.GenericConstantUsage.SearchFormController.WILDCARD_LEFT", "type": "WARNING" @@ -34,7 +34,7 @@ "column": 39, "fixable": false, "line": 27, - "message": "Legacy calls are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", + "message": "Calls to removed code are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", "severity": 5, "source": "Typo3Update.Removed.GenericConstantUsage.SearchFormController.WILDCARD_LEFT", "type": "WARNING" @@ -43,7 +43,7 @@ "column": 66, "fixable": false, "line": 29, - "message": "Legacy calls are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", + "message": "Calls to removed code are not allowed; found constant \\TYPO3\\CMS\\IndexedSearch\\Controller\\SearchFormController::WILDCARD_LEFT. Removed in 7.6. Use \\TYPO3\\CMS\\IndexedSearch\\Utility\\LikeWildcard::LEFT instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-69227-StringsForLikeAreNotProperlyEscaped.html", "severity": 5, "source": "Typo3Update.Removed.GenericConstantUsage.SearchFormController.WILDCARD_LEFT", "type": "WARNING" diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json index f2e61ab..a818be1 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff/Expected.json @@ -7,7 +7,7 @@ "column": 41, "fixable": false, "line": 24, - "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", + "message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", "severity": 5, "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", "type": "WARNING" @@ -16,7 +16,7 @@ "column": 17, "fixable": false, "line": 26, - "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", + "message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", "severity": 5, "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", "type": "WARNING" @@ -25,7 +25,7 @@ "column": 44, "fixable": false, "line": 28, - "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", + "message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA. Removed in 7.0. There is no replacement, just remove call. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-LoadTcaFunctionRemoved.html", "severity": 5, "source": "Typo3Update.Removed.GenericFunctionCall.GeneralUtility.loadTCA", "type": "WARNING" @@ -34,7 +34,7 @@ "column": 8, "fixable": false, "line": 31, - "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController->includeTCA. Removed in 7.0. Full TCA is always loaded during bootstrap in FE, the method is obsolete. If an eid script calls this method to load TCA, use \\TYPO3\\CMS\\Frontend\\Utility\\EidUtility::initTCA() instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-FrontendTcaFunctionsRemoved.html", + "message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController->includeTCA. Removed in 7.0. Full TCA is always loaded during bootstrap in FE, the method is obsolete. If an eid script calls this method to load TCA, use \\TYPO3\\CMS\\Frontend\\Utility\\EidUtility::initTCA() instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-FrontendTcaFunctionsRemoved.html", "severity": 5, "source": "Typo3Update.Removed.GenericFunctionCall.TypoScriptFrontendController.includeTCA", "type": "WARNING" @@ -43,7 +43,7 @@ "column": 17, "fixable": false, "line": 35, - "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController->includeTCA. Removed in 7.0. Full TCA is always loaded during bootstrap in FE, the method is obsolete. If an eid script calls this method to load TCA, use \\TYPO3\\CMS\\Frontend\\Utility\\EidUtility::initTCA() instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-FrontendTcaFunctionsRemoved.html", + "message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController->includeTCA. Removed in 7.0. Full TCA is always loaded during bootstrap in FE, the method is obsolete. If an eid script calls this method to load TCA, use \\TYPO3\\CMS\\Frontend\\Utility\\EidUtility::initTCA() instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61785-FrontendTcaFunctionsRemoved.html", "severity": 5, "source": "Typo3Update.Removed.GenericFunctionCall.TypoScriptFrontendController.includeTCA", "type": "WARNING" diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json index ff6e6bd..e66a962 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff/Expected.json @@ -7,7 +7,7 @@ "column": 10, "fixable": false, "line": 2, - "message": "Legacy calls are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html", + "message": "Calls to removed code are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.styles-insertContent", "type": "WARNING" @@ -16,7 +16,7 @@ "column": 11, "fixable": false, "line": 3, - "message": "Legacy calls are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html", + "message": "Calls to removed code are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.styles-insertContent", "type": "WARNING" @@ -25,7 +25,7 @@ "column": 1, "fixable": false, "line": 6, - "message": "Legacy calls are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html", + "message": "Calls to removed code are not allowed; found styles.insertContent. Removed in 7.0. Either remove usage of styles.insertContent or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-42543-DefaultTypoScriptRemoved.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.styles-insertContent", "type": "WARNING" @@ -34,7 +34,7 @@ "column": 1, "fixable": false, "line": 13, - "message": "Legacy calls are not allowed; found mod.web_list.alternateBgColors. Removed in 7.0. Removed without substitution. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-53658-RemoveAlternateBgColorsOption.html", + "message": "Calls to removed code are not allowed; found mod.web_list.alternateBgColors. Removed in 7.0. Removed without substitution. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-53658-RemoveAlternateBgColorsOption.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.mod-web_list-alternateBgColors", "type": "WARNING" @@ -43,7 +43,7 @@ "column": 10, "fixable": false, "line": 26, - "message": "Legacy calls are not allowed; found CLEARGIF. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", + "message": "Calls to removed code are not allowed; found CLEARGIF. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.CLEARGIF", "type": "WARNING" @@ -52,7 +52,7 @@ "column": 10, "fixable": false, "line": 27, - "message": "Legacy calls are not allowed; found COLUMNS. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", + "message": "Calls to removed code are not allowed; found COLUMNS. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.COLUMNS", "type": "WARNING" @@ -61,7 +61,7 @@ "column": 10, "fixable": false, "line": 28, - "message": "Legacy calls are not allowed; found CTABLE. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", + "message": "Calls to removed code are not allowed; found CTABLE. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.CTABLE", "type": "WARNING" @@ -70,7 +70,7 @@ "column": 10, "fixable": false, "line": 29, - "message": "Legacy calls are not allowed; found OTABLE. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", + "message": "Calls to removed code are not allowed; found OTABLE. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.OTABLE", "type": "WARNING" @@ -79,7 +79,7 @@ "column": 10, "fixable": false, "line": 30, - "message": "Legacy calls are not allowed; found HRULER. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", + "message": "Calls to removed code are not allowed; found HRULER. Removed in 7.1. Any installation should migrate to alternatives such as FLUIDTEMPLATE to customize the output of the content. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.1/Breaking-64639-RemovedContentObjects.html", "severity": 5, "source": "Typo3Update.Removed.TypoScript.HRULER", "type": "WARNING" From bcbd1f96bc5740bdf19150ed813d31ff03390316 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 13:33:28 +0200 Subject: [PATCH 075/100] TASK: Migrate GenericConstantUsageSniff * Migrate GenericConstantUsageSniff to new architecture. * Move non common functionality from AbstractGenericPhpUsage to concrete classes. Relates: #71 --- .../Removed/AbstractGenericPhpUsage.php | 21 +++------- .../Removed/GenericConstantUsageSniff.php | 40 ++++--------------- .../Removed/GenericFunctionCallSniff.php | 38 ++++++++++-------- 3 files changed, 35 insertions(+), 64 deletions(-) diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php index d93645f..c426721 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php @@ -21,11 +21,13 @@ namespace Typo3Update\Sniffs\Removed; */ use PHP_CodeSniffer_File as PhpCsFile; -use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; abstract class AbstractGenericPhpUsage extends AbstractGenericUsage { - use ExtendedPhpCsSupportTrait; + public function register() + { + return [T_STRING]; + } protected function prepareStructure(array $typo3Versions) { @@ -51,10 +53,6 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) { - if (!$this->isFunctionCall($phpcsFile, $stackPtr)) { - return []; - } - $tokens = $phpcsFile->getTokens(); $staticPosition = $phpcsFile->findPrevious(T_WHITESPACE, $stackPtr - 1, null, true, null, true); @@ -120,15 +118,6 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage } } - protected function getOldUsage(array $config) - { - $concat = '->'; - if ($config['static']) { - $concat = '::'; - } - return $config['fqcn'] . $concat . $config['name']; - } - protected function getIdentifier(array $config) { $name = $config['name']; @@ -138,4 +127,6 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage return $name; } + + abstract protected function getOldUsage(array $config); } diff --git a/src/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff.php index 1ee46b1..e42a07d 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/GenericConstantUsageSniff.php @@ -19,42 +19,11 @@ * 02110-1301, USA. */ -use PHP_CodeSniffer_File as PhpCsFile; -use Typo3Update\Sniffs\Removed\AbstractGenericUsage; +use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage; use Typo3Update\Options; -/** - * Sniff that handles all calls to removed constants. - */ -class Typo3Update_Sniffs_Removed_GenericConstantUsageSniff extends AbstractGenericUsage +class Typo3Update_Sniffs_Removed_GenericConstantUsageSniff extends AbstractGenericPhpUsage { - /** - * Return file names containing removed configurations. - * - * @return array - */ - protected function getRemovedConfigFiles() - { - return Options::getRemovedConstantConfigFiles(); - } - - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_STRING]; - } - - /** - * The original constant call, to allow user to check matches. - * - * @param array $config - * - * @return string - */ protected function getOldUsage(array $config) { $old = $config['name']; @@ -64,4 +33,9 @@ class Typo3Update_Sniffs_Removed_GenericConstantUsageSniff extends AbstractGener return 'constant ' . $old; } + + protected function getRemovedConfigFiles() + { + return Options::getRemovedConstantConfigFiles(); + } } diff --git a/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php index 7fa8a12..4d1784b 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php @@ -19,32 +19,38 @@ * 02110-1301, USA. */ -use PHP_CodeSniffer_Tokens as Tokens; -use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage; +use PHP_CodeSniffer_File as PhpCsFile; use Typo3Update\Options; +use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; +use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage; /** * Sniff that handles all calls to removed functions. */ class Typo3Update_Sniffs_Removed_GenericFunctionCallSniff extends AbstractGenericPhpUsage { - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ - public function register() - { - return [T_STRING]; - } + use ExtendedPhpCsSupportTrait; - /** - * Return file names containing removed configurations. - * - * @return array - */ protected function getRemovedConfigFiles() { return Options::getRemovedFunctionConfigFiles(); } + + protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) + { + if (!$this->isFunctionCall($phpcsFile, $stackPtr)) { + return []; + } + + return parent::findRemoved($phpcsFile, $stackPtr); + } + + protected function getOldUsage(array $config) + { + $concat = '->'; + if ($config['static']) { + $concat = '::'; + } + return $config['fqcn'] . $concat . $config['name']; + } } From b9bdd5dd3b89b4661994f4123622db14c88e2fb0 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 14:05:05 +0200 Subject: [PATCH 076/100] TASK: Migrate RemovedClassFeature * Also migrate RemovedClassFeature to new structure with AbstractYamlRemovedUsage Relates: #71 --- .../Feature/AbstractYamlRemovedUsage.php | 103 ++++++++++++++++++ .../Typo3Update/Feature/FeatureInterface.php | 6 + .../Feature/RemovedClassFeature.php | 51 +++++---- src/Standards/Typo3Update/Options.php | 2 +- .../PhpDocCommentSniff/Expected.json | 4 +- 5 files changed, 140 insertions(+), 26 deletions(-) create mode 100644 src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php diff --git a/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php b/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php new file mode 100644 index 0000000..9395d44 --- /dev/null +++ b/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php @@ -0,0 +1,103 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use PHP_CodeSniffer as PhpCs; +use PHP_CodeSniffer_File as PhpCsFile; +use PHP_CodeSniffer_Sniff as PhpCsSniff; +use Typo3Update\RemovedByYamlConfiguration; + +/** + * Contains common functionality for removed code like constants or functions. + * + * Removed parts are configured using YAML-Files, for examples see + * src/Standards/Typo3Update/Configuration/Removed/Constants/7.0.yaml Also + * check out the configuration options in Readme.rst. + */ +abstract class AbstractYamlRemovedUsage implements FeatureInterface +{ + /** + * @var array + */ + protected $configured; + + /** + * @var PhpCsSniff + */ + protected $sniff; + + public function __construct(PhpCsSniff $sniff) + { + $this->sniff = $sniff; + $this->configured = new RemovedByYamlConfiguration( + $this->getRemovedConfigFiles(), + \Closure::fromCallable([$this, 'prepareStructure']) + ); + } + + /** + * Prepares structure from config for later usage. + * + * @param array $typo3Versions + * @return array + */ + abstract protected function prepareStructure(array $typo3Versions); + + /** + * Return file names containing removed configurations. + * + * @return array + */ + abstract protected function getRemovedConfigFiles(); + + protected function addWarning(PhpCsFile $phpcsFile, $stackPtr, array $removed) + { + $phpcsFile->addWarning( + 'Calls to removed code are not allowed; found %s. Removed in %s. %s. See: %s', + $stackPtr, + $removed['identifier'], + [ + $removed['oldUsage'], + $removed['versionRemoved'], + $this->getReplacement($removed), + $removed['docsUrl'], + ] + ); + } + + /** + * The new call, or information how to migrate. + * + * To provide feedback for user to ease migration. + * + * @param array $config + * + * @return string + */ + protected function getReplacement(array $config) + { + $newCall = $config['replacement']; + if ($newCall !== null) { + return $newCall; + } + return 'There is no replacement, just remove call'; + } +} diff --git a/src/Standards/Typo3Update/Feature/FeatureInterface.php b/src/Standards/Typo3Update/Feature/FeatureInterface.php index 39de10c..ac8b7a9 100644 --- a/src/Standards/Typo3Update/Feature/FeatureInterface.php +++ b/src/Standards/Typo3Update/Feature/FeatureInterface.php @@ -21,12 +21,18 @@ namespace Typo3Update\Feature; */ use PHP_CodeSniffer_File as PhpCsFile; +use PHP_CodeSniffer_Sniff as PhpCsSniff; /** * See "Features" in documentation. */ interface FeatureInterface { + /** + * @var PhpCsSniff $sniff + */ + public function __construct(PhpCsSniff $sniff); + /** * Process like a PHPCS Sniff. * diff --git a/src/Standards/Typo3Update/Feature/RemovedClassFeature.php b/src/Standards/Typo3Update/Feature/RemovedClassFeature.php index d81c34d..ffc61df 100644 --- a/src/Standards/Typo3Update/Feature/RemovedClassFeature.php +++ b/src/Standards/Typo3Update/Feature/RemovedClassFeature.php @@ -20,37 +20,42 @@ namespace Typo3Update\Feature; * 02110-1301, USA. */ -use PHP_CodeSniffer as PhpCs; use PHP_CodeSniffer_File as PhpCsFile; -use PHP_CodeSniffer_Sniff as PhpCsSniff; +use Typo3Update\Options; -/** - * This feature will add fixable errors for old legacy classnames. - * - * Can be attached to sniffs returning classnames. - */ -class RemovedClassFeature implements FeatureInterface +class RemovedClassFeature extends AbstractYamlRemovedUsage { - /** - * Process like a PHPCS Sniff. - * - * @param PhpCsFile $phpcsFile - * @param int $classnamePosition - * @param string $classname - * - * @return void - */ public function process(PhpCsFile $phpcsFile, $classnamePosition, $classname) { - if ($this->isClassnameRemoved($classname) === false) { + if (! $this->configured->isRemoved($classname)) { return; } - - $phpcsFile->addError( - 'Removed classes are not allowed; found "%s", use "%s" instead', + $this->addWarning( + $phpcsFile, $classnamePosition, - 'removedClassname', - [$classname] + $this->configured->getRemoved($classname) ); } + + protected function prepareStructure(array $typo3Versions) + { + $newStructure = []; + foreach ($typo3Versions as $typo3Version => $removals) { + foreach ($removals as $removed => $config) { + $config['name'] = $removed; + $config['identifier'] = 'RemovedClass.' . str_replace('\\', '_', ltrim($removed, '\\')); + $config['versionRemoved'] = $typo3Version; + $config['oldUsage'] = $removed; + + $newStructure[$removed] = $config; + } + } + + return $newStructure; + } + + protected function getRemovedConfigFiles() + { + return Options::getRemovedClassConfigFiles(); + } } diff --git a/src/Standards/Typo3Update/Options.php b/src/Standards/Typo3Update/Options.php index 6db1bd2..62b8a78 100644 --- a/src/Standards/Typo3Update/Options.php +++ b/src/Standards/Typo3Update/Options.php @@ -104,7 +104,7 @@ class Options { return static::getOptionFileNames( 'removedClassConfigFiles', - __DIR__ . '/../Configuration/Removed/Classes/*.yaml' + __DIR__ . '/Configuration/Removed/Classes/*.yaml' ); } diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json index c528d04..89158c7 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/Expected.json @@ -25,9 +25,9 @@ "column": 15, "fixable": false, "line": 32, - "message": "Legacy calls are not allowed; found \\TYPO3\\CMS\\Backend\\Template\\MediumDocumentTemplate. Removed in 7.0. Use \\TYPO3\\CMS\\Backend\\Template\\DocumentTemplate instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61782-DeprecatedDocumentTemplateClassesRemoved.html", + "message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Backend\\Template\\MediumDocumentTemplate. Removed in 7.0. Use \\TYPO3\\CMS\\Backend\\Template\\DocumentTemplate instead. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61782-DeprecatedDocumentTemplateClassesRemoved.html", "severity": 5, - "source": "Typo3Update.LegacyClassnames.DocComment.TYPO3_CMS_Backend_Template_MediumDocumentTemplate", + "source": "Typo3Update.Classname.PhpDocComment.RemovedClass.TYPO3_CMS_Backend_Template_MediumDocumentTemplate", "type": "WARNING" }, { From 510774a3cc47bf6dabd498815e597a18b2d752c5 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 14:16:22 +0200 Subject: [PATCH 077/100] TASK: Support at least PHP 5.6 * Adjust CI , composer and docs. * Migrate modern code to 5.6 supported code. Relates: #71 --- .gitlab-ci.yml | 12 ++++++++++-- Documentation/source/index.rst | 3 ++- composer.json | 2 +- .../Typo3Update/Feature/AbstractYamlRemovedUsage.php | 9 ++++++++- .../Sniffs/Removed/AbstractGenericUsage.php | 9 ++++++++- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 202f4e0..af289ad 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,12 +41,20 @@ lint:php-mass-detection: script: - ./vendor/bin/phpmd src text phpmd.xml > result/phpmd.txt -test:7.1: &PHP-UNITTESTING - image: php:7.1-alpine +test:5.6: &PHP-UNITTESTING + image: php:5.6-alpine stage: test script: - ./vendor/bin/phpunit +test:7.0: + <<: *PHP-UNITTESTING + image: php:7.0-alpine + +test:7.1: + <<: *PHP-UNITTESTING + image: php:7.1-alpine + test:latest: <<: *PHP-UNITTESTING image: php:7-alpine diff --git a/Documentation/source/index.rst b/Documentation/source/index.rst index 709f4ec..1dd04c3 100644 --- a/Documentation/source/index.rst +++ b/Documentation/source/index.rst @@ -19,7 +19,8 @@ Requirements To install the project you need ``composer`` to be installed and inside your ``$PATH``. Otherwise run ``make install-composer`` to install composer. -At least PHP 7.1 is required. +We recommend to use at least PHP 5.6, we do not test with lower versions as 5.6 is latest maintained +version. Installation ============ diff --git a/composer.json b/composer.json index 87aab93..623bfde 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ ] }, "require": { - "php": "~7.1", + "php": ">=5.6", "helmich/typo3-typoscript-parser": "1.1.*", "squizlabs/php_codesniffer": "2.8.*", "symfony/yaml": "3.2.*", diff --git a/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php b/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php index 9395d44..d5463d6 100644 --- a/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php +++ b/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php @@ -49,10 +49,17 @@ abstract class AbstractYamlRemovedUsage implements FeatureInterface $this->sniff = $sniff; $this->configured = new RemovedByYamlConfiguration( $this->getRemovedConfigFiles(), - \Closure::fromCallable([$this, 'prepareStructure']) + $this->getPrepateStructure() ); } + protected function getPrepateStructure() + { + return function (array $typo3Versions) { + return call_user_func_array([$this, 'prepareStructure'], [$typo3Versions]); + }; + } + /** * Prepares structure from config for later usage. * diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php index ff67d4f..ba2ba40 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php @@ -39,10 +39,17 @@ abstract class AbstractGenericUsage implements PhpCsSniff { $this->configured = new RemovedByYamlConfiguration( $this->getRemovedConfigFiles(), - \Closure::fromCallable([$this, 'prepareStructure']) + $this->getPrepateStructure() ); } + protected function getPrepateStructure() + { + return function (array $typo3Versions) { + return call_user_func_array([$this, 'prepareStructure'], [$typo3Versions]); + }; + } + /** * Prepares structure from config for later usage. * From 003609342edb40beb14d176aa9e09fd724112742 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 14:37:24 +0200 Subject: [PATCH 078/100] TASK: Refactor DRY * Don't duplicate code and logic. * Move common code to parent class. Relates: #71 --- .../Typo3Update/AbstractYamlRemovedUsage.php | 72 ++++++++++++++++ .../Feature/AbstractYamlRemovedUsage.php | 84 +------------------ .../Sniffs/Removed/AbstractGenericUsage.php | 73 +--------------- 3 files changed, 78 insertions(+), 151 deletions(-) create mode 100644 src/Standards/Typo3Update/AbstractYamlRemovedUsage.php diff --git a/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php b/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php new file mode 100644 index 0000000..84aee44 --- /dev/null +++ b/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php @@ -0,0 +1,72 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use PHP_CodeSniffer_File as PhpCsFile; +use Typo3Update\RemovedByYamlConfiguration; + +abstract class AbstractYamlRemovedUsage +{ + protected $configured; + + public function __construct() + { + $this->configured = new RemovedByYamlConfiguration( + $this->getRemovedConfigFiles(), + $this->getPrepareStructureCallback() + ); + } + + protected function getPrepareStructureCallback() + { + return function (array $typo3Versions) { + return call_user_func_array([$this, 'prepareStructure'], [$typo3Versions]); + }; + } + + abstract protected function prepareStructure(array $typo3Versions); + + abstract protected function getRemovedConfigFiles(); + + protected function addWarning(PhpCsFile $phpcsFile, $stackPtr, array $removed) + { + $phpcsFile->addWarning( + 'Calls to removed code are not allowed; found %s. Removed in %s. %s. See: %s', + $stackPtr, + $removed['identifier'], + [ + $removed['oldUsage'], + $removed['versionRemoved'], + $this->getReplacement($removed), + $removed['docsUrl'], + ] + ); + } + + protected function getReplacement(array $config) + { + $newCall = $config['replacement']; + if ($newCall !== null) { + return $newCall; + } + return 'There is no replacement, just remove call'; + } +} diff --git a/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php b/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php index d5463d6..2a1fb9f 100644 --- a/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php +++ b/src/Standards/Typo3Update/Feature/AbstractYamlRemovedUsage.php @@ -20,91 +20,13 @@ namespace Typo3Update\Feature; * 02110-1301, USA. */ -use PHP_CodeSniffer as PhpCs; -use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Sniff as PhpCsSniff; -use Typo3Update\RemovedByYamlConfiguration; +use Typo3Update\AbstractYamlRemovedUsage as BaseAbstractYamlRemovedUsage; -/** - * Contains common functionality for removed code like constants or functions. - * - * Removed parts are configured using YAML-Files, for examples see - * src/Standards/Typo3Update/Configuration/Removed/Constants/7.0.yaml Also - * check out the configuration options in Readme.rst. - */ -abstract class AbstractYamlRemovedUsage implements FeatureInterface +abstract class AbstractYamlRemovedUsage extends BaseAbstractYamlRemovedUsage implements FeatureInterface { - /** - * @var array - */ - protected $configured; - - /** - * @var PhpCsSniff - */ - protected $sniff; - public function __construct(PhpCsSniff $sniff) { - $this->sniff = $sniff; - $this->configured = new RemovedByYamlConfiguration( - $this->getRemovedConfigFiles(), - $this->getPrepateStructure() - ); - } - - protected function getPrepateStructure() - { - return function (array $typo3Versions) { - return call_user_func_array([$this, 'prepareStructure'], [$typo3Versions]); - }; - } - - /** - * Prepares structure from config for later usage. - * - * @param array $typo3Versions - * @return array - */ - abstract protected function prepareStructure(array $typo3Versions); - - /** - * Return file names containing removed configurations. - * - * @return array - */ - abstract protected function getRemovedConfigFiles(); - - protected function addWarning(PhpCsFile $phpcsFile, $stackPtr, array $removed) - { - $phpcsFile->addWarning( - 'Calls to removed code are not allowed; found %s. Removed in %s. %s. See: %s', - $stackPtr, - $removed['identifier'], - [ - $removed['oldUsage'], - $removed['versionRemoved'], - $this->getReplacement($removed), - $removed['docsUrl'], - ] - ); - } - - /** - * The new call, or information how to migrate. - * - * To provide feedback for user to ease migration. - * - * @param array $config - * - * @return string - */ - protected function getReplacement(array $config) - { - $newCall = $config['replacement']; - if ($newCall !== null) { - return $newCall; - } - return 'There is no replacement, just remove call'; + parent::__construct(); } } diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php index ba2ba40..b7ab259 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php @@ -22,83 +22,16 @@ namespace Typo3Update\Sniffs\Removed; use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_Sniff as PhpCsSniff; -use Typo3Update\RemovedByYamlConfiguration; +use Typo3Update\AbstractYamlRemovedUsage as BaseAbstractYamlRemovedUsage; -/** - * Contains common functionality for removed code like constants or functions. - * - * Removed parts are configured using YAML-Files, for examples see - * src/Standards/Typo3Update/Configuration/Removed/Constants/7.0.yaml Also - * check out the configuration options in Readme.rst. - */ -abstract class AbstractGenericUsage implements PhpCsSniff +abstract class AbstractGenericUsage extends BaseAbstractYamlRemovedUsage implements PhpCsSniff { - protected $configured; - - public function __construct() - { - $this->configured = new RemovedByYamlConfiguration( - $this->getRemovedConfigFiles(), - $this->getPrepateStructure() - ); - } - - protected function getPrepateStructure() - { - return function (array $typo3Versions) { - return call_user_func_array([$this, 'prepareStructure'], [$typo3Versions]); - }; - } - - /** - * Prepares structure from config for later usage. - * - * @param array $typo3Versions - * @return array - */ - abstract protected function prepareStructure(array $typo3Versions); - - /** - * Return file names containing removed configurations. - * - * @return array - */ - abstract protected function getRemovedConfigFiles(); - abstract protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr); public function process(PhpCsFile $phpcsFile, $stackPtr) { foreach ($this->findRemoved($phpcsFile, $stackPtr) as $removed) { - $phpcsFile->addWarning( - 'Calls to removed code are not allowed; found %s. Removed in %s. %s. See: %s', - $stackPtr, - $removed['identifier'], - [ - $removed['oldUsage'], - $removed['versionRemoved'], - $this->getReplacement($removed), - $removed['docsUrl'], - ] - ); + $this->addWarning($phpcsFile, $stackPtr, $removed); } } - - /** - * The new call, or information how to migrate. - * - * To provide feedback for user to ease migration. - * - * @param array $config - * - * @return string - */ - protected function getReplacement(array $config) - { - $newCall = $config['replacement']; - if ($newCall !== null) { - return $newCall; - } - return 'There is no replacement, just remove call'; - } } From 11db09a3038861154bd4bad524deb0b083208d1c Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 15:40:02 +0200 Subject: [PATCH 079/100] TASK: Update phpdocs * Remove unnecessary docs. * Add necessary docs. --- .../Typo3Update/AbstractYamlRemovedUsage.php | 25 ++++++++++++++++++ .../RemovedByYamlConfiguration.php | 14 ++++++++++ .../Removed/AbstractGenericPhpUsage.php | 24 +++++++++++++++++ .../Sniffs/Removed/AbstractGenericUsage.php | 9 +++++++ .../Removed/GenericFunctionCallSniff.php | 3 --- .../Sniffs/Removed/TypoScriptSniff.php | 26 ------------------- 6 files changed, 72 insertions(+), 29 deletions(-) diff --git a/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php b/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php index 84aee44..37d1c4e 100644 --- a/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php +++ b/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php @@ -23,8 +23,14 @@ namespace Typo3Update; use PHP_CodeSniffer_File as PhpCsFile; use Typo3Update\RemovedByYamlConfiguration; +/** + * Base class for all classes working with removed configuration through yaml files. + */ abstract class AbstractYamlRemovedUsage { + /** + * @var array + */ protected $configured; public function __construct() @@ -35,6 +41,9 @@ abstract class AbstractYamlRemovedUsage ); } + /** + * @return \Callable + */ protected function getPrepareStructureCallback() { return function (array $typo3Versions) { @@ -42,10 +51,22 @@ abstract class AbstractYamlRemovedUsage }; } + /** + * @param array $typo3Versions + * @return array + */ abstract protected function prepareStructure(array $typo3Versions); + /** + * @return array + */ abstract protected function getRemovedConfigFiles(); + /** + * @param PhpCsFile $phpcsFile + * @param int $stackPtr + * @param array $removed + */ protected function addWarning(PhpCsFile $phpcsFile, $stackPtr, array $removed) { $phpcsFile->addWarning( @@ -61,6 +82,10 @@ abstract class AbstractYamlRemovedUsage ); } + /** + * @param array $config + * @return string + */ protected function getReplacement(array $config) { $newCall = $config['replacement']; diff --git a/src/Standards/Typo3Update/RemovedByYamlConfiguration.php b/src/Standards/Typo3Update/RemovedByYamlConfiguration.php index a527e43..f1596a9 100644 --- a/src/Standards/Typo3Update/RemovedByYamlConfiguration.php +++ b/src/Standards/Typo3Update/RemovedByYamlConfiguration.php @@ -31,6 +31,10 @@ class RemovedByYamlConfiguration */ protected $configured = []; + /** + * @param array $configFiles + * @param Callable $prepareStructure + */ public function __construct(array $configFiles, $prepareStructure) { foreach ($configFiles as $file) { @@ -41,16 +45,26 @@ class RemovedByYamlConfiguration } } + /** + * @param string $identifier + * @return bool + */ public function isRemoved($identifier) { return isset($this->configured[$identifier]); } + /** + * @return array + */ public function getAllRemoved() { return $this->configured; } + /** + * @return array + */ public function getRemoved($identifier) { if (!$this->isRemoved($identifier)) { diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php index c426721..99c81d1 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericPhpUsage.php @@ -24,11 +24,18 @@ use PHP_CodeSniffer_File as PhpCsFile; abstract class AbstractGenericPhpUsage extends AbstractGenericUsage { + /** + * @return int[] + */ public function register() { return [T_STRING]; } + /** + * @param array $typo3Versions + * @return array + */ protected function prepareStructure(array $typo3Versions) { $newStructure = []; @@ -51,6 +58,11 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage return $newStructure; } + /** + * @param PhpCsFile $phpcsFile + * @param int $stackPtr + * @return array + */ protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -104,6 +116,10 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage ); } + /** + * @param string $identifier + * @param array &$config + */ protected function handleStatic($identifier, array &$config) { $split = preg_split('/::|->/', $identifier); @@ -118,6 +134,10 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage } } + /** + * @param array $config + * @return string + */ protected function getIdentifier(array $config) { $name = $config['name']; @@ -128,5 +148,9 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage return $name; } + /** + * @param array $config + * @return string + */ abstract protected function getOldUsage(array $config); } diff --git a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php index b7ab259..557dcb5 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/AbstractGenericUsage.php @@ -26,8 +26,17 @@ use Typo3Update\AbstractYamlRemovedUsage as BaseAbstractYamlRemovedUsage; abstract class AbstractGenericUsage extends BaseAbstractYamlRemovedUsage implements PhpCsSniff { + /** + * @param PhpCsFile $phpcsFile + * @param int $stackPtr + * @return array + */ abstract protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr); + /** + * @param PhpCsFile $phpcsFile + * @param int $stackPtr + */ public function process(PhpCsFile $phpcsFile, $stackPtr) { foreach ($this->findRemoved($phpcsFile, $stackPtr) as $removed) { diff --git a/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php index 4d1784b..2915a87 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/GenericFunctionCallSniff.php @@ -24,9 +24,6 @@ use Typo3Update\Options; use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait; use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage; -/** - * Sniff that handles all calls to removed functions. - */ class Typo3Update_Sniffs_Removed_GenericFunctionCallSniff extends AbstractGenericPhpUsage { use ExtendedPhpCsSupportTrait; diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php index 419b55a..6638b34 100644 --- a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptSniff.php @@ -24,9 +24,6 @@ use PHP_CodeSniffer_File as PhpCsFile; use Typo3Update\Options; use Typo3Update\Sniffs\Removed\AbstractGenericUsage; -/** - * Check usage of removed or breaking changed TypoScript. - */ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage { /** @@ -37,11 +34,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage 'TYPOSCRIPT', ]; - /** - * Returns the token types that this sniff is interested in. - * - * @return array - */ public function register() { return [ @@ -50,12 +42,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage ]; } - /** - * Prepares structure from config for later usage. - * - * @param array $typo3Versions - * @return array - */ protected function prepareStructure(array $typo3Versions) { $newStructure = []; @@ -80,13 +66,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage return $newStructure; } - /** - * Check whether the current token is removed. - * - * @param PhpCsFile $phpcsFile - * @param int $stackPtr - * @return bool - */ protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -105,11 +84,6 @@ class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage return []; } - /** - * Return file names containing removed configurations. - * - * @return array - */ protected function getRemovedConfigFiles() { return Options::getRemovedTypoScriptConfigFiles(); From 0e3f487681bbda466bd506b4d60d7a71d283ed9f Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 16:10:28 +0200 Subject: [PATCH 080/100] TASK: Add removed classes in 7.0 Relates: #41 --- .../Configuration/Removed/Classes/7.0.yaml | 45 +++++++++++++++++++ .../Expected.diff | 3 +- .../InputFileForIssues.php | 1 + 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/Standards/Typo3Update/Configuration/Removed/Classes/7.0.yaml b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.0.yaml index 2341204..c50d9c9 100644 --- a/src/Standards/Typo3Update/Configuration/Removed/Classes/7.0.yaml +++ b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.0.yaml @@ -9,3 +9,48 @@ \TYPO3\CMS\Backend\Template\StandardDocumentTemplate: replacement: 'Use \TYPO3\CMS\Backend\Template\DocumentTemplate instead' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61782-DeprecatedDocumentTemplateClassesRemoved.html' + \TYPO3\CMS\Extbase\Mvc\Controller\ArgumentError: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Mvc\Controller\ArgumentsValidator: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Property\Mapper: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Property\MappingResults: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Security\Channel\RequestHashService: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Validation\PropertyError: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Validation\Validator\AbstractObjectValidator: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Fluid\ViewHelpers\Form\ErrorsViewHelper: + replacement: 'Migrate to rewritten property mapper' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57396-ExtbaseDeprecatedPropertyMapperRemoved.html' + \TYPO3\CMS\Extbase\Mvc\Controller\FlashMessageContainer: + replacement: 'Change the API calls to not be of static kind anymore. Extbase extensions have to use getFlashMessageQueue() of the controllerContext' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-57382-FlashMessageApi.html' + \TYPO3\CMS\Extbase\Service\TypeHandlingService: + replacement: 'Replace all calls to \TYPO3\CMS\Extbase\Service\TypeHandlingService functions to their new static functions in \TYPO3\CMS\Extbase\Utility\TypeHandlingUtility' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-61786-ExtbaseDeprecatedTypeHandlingServiceRemoved.html' + \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelConstantsInterface: + replacement: 'Use \TYPO3\CMS\Extbase\Persistence\QueryInterface::*' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62673-ExtbaseDeprecatedCodeRemoved.html#removed-php-classes' + \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactoryInterface: + replacement: null + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62673-ExtbaseDeprecatedCodeRemoved.html#removed-php-classes' + \TYPO3\CMS\Scheduler\Task\FileIndexingTask: + replacement: null + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62670-DeprecatedCodeRemovalInMultipleSysexts.html#removed-php-classes' + \TYPO3\CMS\Core\Compatibility\GlobalObjectDeprecationDecorator: + replacement: null + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62416-DeprecatedCodeRemovalInCoreSysext.html#removed-php-classes' + \TYPO3\CMS\Core\Resource\Service\IndexerService: + replacement: null + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-62416-DeprecatedCodeRemovalInCoreSysext.html#removed-php-classes' diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff index 41f28ef..80accd3 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/Expected.diff @@ -1,10 +1,11 @@ --- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php +++ PHP_CodeSniffer -@@ -19,6 +19,6 @@ +@@ -19,7 +19,7 @@ * 02110-1301, USA. */ -t3lib_div::makeInstance('Tx_Extbase_Command_HelpCommandController'); +t3lib_div::makeInstance('\TYPO3\CMS\Extbase\Command\HelpCommandController'); + t3lib_div::makeInstance(\TYPO3\CMS\Core\Resource\Service\IndexerService::class); // Not handled by this sniff, but StaticCallSniff, as this uses double colon. t3lib_div::makeInstance(Tx_Extbase_Command_HelpCommandController::class); diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php index 12550c5..ccc9a0c 100644 --- a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php @@ -20,5 +20,6 @@ */ t3lib_div::makeInstance('Tx_Extbase_Command_HelpCommandController'); +t3lib_div::makeInstance(\TYPO3\CMS\Core\Resource\Service\IndexerService::class); // Not handled by this sniff, but StaticCallSniff, as this uses double colon. t3lib_div::makeInstance(Tx_Extbase_Command_HelpCommandController::class); From 98b93316521c20a5ca79a343aa3d6435299cba68 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 16:20:14 +0200 Subject: [PATCH 081/100] TASK: Add removed classes for TYPO3 7.3 Relates: #41 --- .../Configuration/Removed/Classes/7.3.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/Standards/Typo3Update/Configuration/Removed/Classes/7.3.yaml diff --git a/src/Standards/Typo3Update/Configuration/Removed/Classes/7.3.yaml b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.3.yaml new file mode 100644 index 0000000..d9fa51d --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.3.yaml @@ -0,0 +1,14 @@ +# Breaking changes in 7.3: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Index.html#breaking-changes +'7.3': + \TYPO3\CMS\T3editor\FormWizard: + replacement: 'Use the newly introduced API' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-67229-FormEngineRelatedClasses.html' + \TYPO3\CMS\Rtehtmlarea\Controller\FrontendRteController: + replacement: 'Use the newly introduced API' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-67229-FormEngineRelatedClasses.html' + \TYPO3\CMS\Rsaauth\Hook\LoginFormHook: + replacement: 'Use the new backend login form API' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-66669-BackendLoginControllerRefactored.html' + \TYPO3\CMS\Extbase\Persistence\Generic\IdentityMap: + replacement: 'Existing code can be migrated to the persistence Session class which provides a drop-in replacement for the IdentityMap' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-66429-RemoveIdentityMapFromPersistence.html' From 3663af3755e354293d5bfe60d893c19f56d0076a Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 16:33:36 +0200 Subject: [PATCH 082/100] TASK: Add removed classes for TYPO3 7.3 Relates: #41 --- .../Configuration/Removed/Classes/7.4.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/Standards/Typo3Update/Configuration/Removed/Classes/7.4.yaml diff --git a/src/Standards/Typo3Update/Configuration/Removed/Classes/7.4.yaml b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.4.yaml new file mode 100644 index 0000000..23c4838 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.4.yaml @@ -0,0 +1,14 @@ +# Breaking changes in 7.4: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Index.html#breaking-changes +'7.4': + \TYPO3\CMS\Backend\Rte\AbstractRte: + replacement: 'Take a look at the docs' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-67811-RteApi.html' + \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaBase: + replacement: 'Take a look at the docs' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-67811-RteApi.html' + \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaApi: + replacement: 'Not removed but refactored, see docs' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-67811-RteApi.html' + \TYPO3\CMS\Backend\Template\FrontendDocumentTemplate: + replacement: null + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-68243-MoveNotUsedFrontendDocumentTemplate.html' From cfdf58f7d47163af419d0fd6250bf4cc947dffb2 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 16:33:55 +0200 Subject: [PATCH 083/100] TASK: Add removed classes for TYPO3 7.5 Relates: #41 --- .../Configuration/Removed/Classes/7.5.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/Standards/Typo3Update/Configuration/Removed/Classes/7.5.yaml diff --git a/src/Standards/Typo3Update/Configuration/Removed/Classes/7.5.yaml b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.5.yaml new file mode 100644 index 0000000..8fdb755 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.5.yaml @@ -0,0 +1,17 @@ +# Breaking changes in 7.5: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Index.html#breaking-changes +'7.5': + \TYPO3\CMS\Backend\Form\DataPreprocessor: + replacement: 'Take a look at the docs' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Breaking-69568-FormEngine.html' + \TYPO3\CMS\Backend\Form\FormEngine: + replacement: 'Take a look at the docs' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Breaking-69568-FormEngine.html' + \TYPO3\CMS\Backend\Form\FlexFormsHelper: + replacement: 'Take a look at the docs' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Breaking-69568-FormEngine.html' + \TYPO3\CMS\Core\Database\SqlParser: + replacement: 'Use \TYPO3\CMS\Dbal\Database\SqlParser instead' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Breaking-68401-SqlParserMovedIntoEXTdbal.html' + \TYPO3\CMS\Cshmanual\Controller\HelpModuleController: + replacement: 'Use the Extbase controller or Repository class' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Breaking-63000-MigrateCshmanualToExtbase.html' From 4fdc15d71532fcd7043b4c207e76f12341c9bd81 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 16:41:22 +0200 Subject: [PATCH 084/100] TASK: Add removed classes for TYPO3 7.5 Relates: #41 --- .../Configuration/Removed/Classes/7.6.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Standards/Typo3Update/Configuration/Removed/Classes/7.6.yaml diff --git a/src/Standards/Typo3Update/Configuration/Removed/Classes/7.6.yaml b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.6.yaml new file mode 100644 index 0000000..4a497e3 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/Classes/7.6.yaml @@ -0,0 +1,23 @@ +# Breaking changes in 7.6: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Index.html#breaking-changes +'7.6': + \TYPO3\CMS\Recordlist\Browser\ElementBrowser: + replacement: 'Use the new API for adding element browsers or link handlers' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-66369-RemovedElementBrowserRelatedClasses.html' + \TYPO3\CMS\Rtehtmlarea\BrowseLinks: + replacement: 'Use the new API for adding element browsers or link handlers' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-66369-RemovedElementBrowserRelatedClasses.html' + \TYPO3\CMS\Rtehtmlarea\FolderTree: + replacement: 'Use the new API for adding element browsers or link handlers' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-66369-RemovedElementBrowserRelatedClasses.html' + \TYPO3\CMS\Rtehtmlarea\LinkHandler\RemoveLinkHandler: + replacement: 'Use the new API for adding element browsers or link handlers' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-66369-RemovedElementBrowserRelatedClasses.html' + \TYPO3\CMS\Rtehtmlarea\PageTree: + replacement: 'Use the new API for adding element browsers or link handlers' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-66369-RemovedElementBrowserRelatedClasses.html' + \TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface: + replacement: 'Use the new API for adding element browsers or link handlers' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-66369-RemovedElementBrowserRelatedClasses.html' + \TYPO3\CMS\Impexp\ImportExport: + replacement: 'Use or extend one or both of the new classes (TYPO3CMSImpexpImport and TYPO3CMSImpexpExport).' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Breaking-45899-SplitClassImportExportIntoClassesImportAndExport.html' From 8781a8e715b1cc157d677e6509be44d189ec272d Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 16:45:39 +0200 Subject: [PATCH 085/100] TASK: Add gitlab template for merge requests * To make writing merge requests easier. * Also this should keep them in same structure. --- .gitlab/merge_request_templates/default.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitlab/merge_request_templates/default.md diff --git a/.gitlab/merge_request_templates/default.md b/.gitlab/merge_request_templates/default.md new file mode 100644 index 0000000..67ad892 --- /dev/null +++ b/.gitlab/merge_request_templates/default.md @@ -0,0 +1,6 @@ +* Write some info about what has been done. +* Also don't forget to mention why this has been done, e.g. introduced new + feature? + +Resolves: #IssueNumber + From 380398a0afeea1271060e411d48700ddb5a3d877 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 16:54:51 +0200 Subject: [PATCH 086/100] TASK: Document yaml format for features * To enable others to configure their own features. Resolves: #76 --- Documentation/source/configuration.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst index 7f8ffc7..effb38b 100644 --- a/Documentation/source/configuration.rst +++ b/Documentation/source/configuration.rst @@ -288,3 +288,29 @@ Two examples:: new HRULER: replacement: 'Any installation should migrate to alternatives such as F...' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog...' + +Features +^^^^^^^^ + +Configures which Features should be attached to x Sniffs, where Key is the FQCN of the feature and +the values are FQCN of the sniffs. + +Works only if the sniff respects execution of features. + +One example:: + + Typo3Update\Feature\LegacyClassnameFeature: + - Typo3Update_Sniffs_Classname_InheritanceSniff + - Typo3Update_Sniffs_Classname_InlineCommentSniff + - Typo3Update_Sniffs_Classname_InstanceofSniff + - Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff + - Typo3Update_Sniffs_Classname_InstantiationWithNewSniff + - Typo3Update_Sniffs_Classname_InstantiationWithObjectManagerSniff + - Typo3Update_Sniffs_Classname_IsACallSniff + - Typo3Update_Sniffs_Classname_MissingVendorForPluginsAndModulesSniff + - Typo3Update_Sniffs_Classname_PhpDocCommentSniff + - Typo3Update_Sniffs_Classname_StaticCallSniff + - Typo3Update_Sniffs_Classname_TypeHintCatchExceptionSniff + - Typo3Update_Sniffs_Classname_TypeHintSniff + - Typo3Update_Sniffs_Classname_UseSniff + - Typo3Update_Sniffs_LegacyClassname_MissingNamespaceSniff From 28d6e875d243f0a8b2eb23df6bbdc3573051bac1 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 17:01:06 +0200 Subject: [PATCH 087/100] TASK: Fix typo --- Documentation/source/features.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/source/features.rst b/Documentation/source/features.rst index e055e92..2ae12ad 100644 --- a/Documentation/source/features.rst +++ b/Documentation/source/features.rst @@ -15,7 +15,7 @@ Possible configurations for all sniffs: Implemented sniffs: -- PHPDocuments, like Includes and annotations for IDEs. +- PHPDocComments, like Includes and annotations for IDEs. Possible extra configurations: From 06e0578df28bfe373e662d1f16755d502e4a4d8a Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 17:01:30 +0200 Subject: [PATCH 088/100] TASK: Add removed TypoScript feature to docs --- Documentation/source/features.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/source/features.rst b/Documentation/source/features.rst index 2ae12ad..51c8910 100644 --- a/Documentation/source/features.rst +++ b/Documentation/source/features.rst @@ -103,6 +103,15 @@ information. For configuration options see :ref:`configuration-removedFunctionCo Check for usage of *removed constants*. The constants are configured in same way as removed functions. For configuration options see :ref:`configuration-removedConstantConfigFiles`. +Check for usage of *removed TypoScript*. The TypoScript objects are configured in same way as +removed functions. For configuration options see :ref:`configuration-removedTypoScriptConfigFiles`. +This will check whether you are using already removed TypoScript parts, supported are: + +- Objects, e.g. ``CLEARGIF``, ``FORM`` + +- Paths like ``styles.insertContent`` + +For a complete list, take a look at the corresponding YAML-Files. Further checks -------------- From d23bc4d2215fa75500273fd8c266287eabc0b1d5 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 17:05:02 +0200 Subject: [PATCH 089/100] TASK: Add documentation for new feature Relates: #41 --- Documentation/source/configuration.rst | 22 ++++++++++++++++++++++ Documentation/source/features.rst | 11 +++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst index 7f8ffc7..fa5fce1 100644 --- a/Documentation/source/configuration.rst +++ b/Documentation/source/configuration.rst @@ -165,6 +165,28 @@ Using ``runtime-set``: --runtime-set removedConstantConfigFiles "/Some/Absolute/Path/*.yaml" +.. _configuration-removedClassConfigFiles: + +removedClassConfigFiles +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Configure where to look for configuration files defining the removed classes. Default is +``Configuration/Removed/Classes/*.yaml`` inside the standard itself. We already try to deliver as +much as possible. Globing is used, so placeholders like ``*`` are possible, see +https://secure.php.net/manual/en/function.glob.php + +Using :file:`ruleset.xml`: + +.. code:: xml + + + +Using ``runtime-set``: + +.. code:: bash + + --runtime-set removedClassConfigFiles "/Some/Absolute/Path/*.yaml" + .. _configuration-removedTypoScriptConfigFiles: removedTypoScriptConfigFiles diff --git a/Documentation/source/features.rst b/Documentation/source/features.rst index e055e92..5955b9b 100644 --- a/Documentation/source/features.rst +++ b/Documentation/source/features.rst @@ -96,13 +96,16 @@ Check for removed calls Also we check for the following deprecated calls: -Check for usage of *removed functions* in general. The functions are configured via yaml files. The -location of them is configurable, default is inside the standard itself, and we try to deliver all -information. For configuration options see :ref:`configuration-removedFunctionConfigFiles`. +Check for usage of *removed PHP functions* in general. The functions are configured via yaml files. +The location of them is configurable, default is inside the standard itself, and we try to deliver +all information. For configuration options see :ref:`configuration-removedFunctionConfigFiles`. -Check for usage of *removed constants*. The constants are configured in same way as removed +Check for usage of *removed PHP constants*. The constants are configured in same way as removed functions. For configuration options see :ref:`configuration-removedConstantConfigFiles`. +Check for usage of *removed PHP classes*. The classes are configured in same way as removed +functions. For configuration options see :ref:`configuration-removedClassConfigFiles`. + Further checks -------------- From 9e3f7ac1e507713d021c39967428dabb58c2dc59 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 2 May 2017 08:09:10 +0200 Subject: [PATCH 090/100] TASK: Fix MR issues * Remove construct from interface. * Fix wrong type hints. * Keep naming of variable in sync. * Also keep conditions format in sync. Relates: #71 --- .../Typo3Update/AbstractYamlRemovedUsage.php | 16 ++++++++-------- .../Typo3Update/Feature/FeatureInterface.php | 5 ----- .../Typo3Update/Feature/RemovedClassFeature.php | 2 +- .../Typo3Update/RemovedByYamlConfiguration.php | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php b/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php index 37d1c4e..e753605 100644 --- a/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php +++ b/src/Standards/Typo3Update/AbstractYamlRemovedUsage.php @@ -29,7 +29,7 @@ use Typo3Update\RemovedByYamlConfiguration; abstract class AbstractYamlRemovedUsage { /** - * @var array + * @var RemovedByYamlConfiguration */ protected $configured; @@ -65,19 +65,19 @@ abstract class AbstractYamlRemovedUsage /** * @param PhpCsFile $phpcsFile * @param int $stackPtr - * @param array $removed + * @param array $config */ - protected function addWarning(PhpCsFile $phpcsFile, $stackPtr, array $removed) + protected function addWarning(PhpCsFile $phpcsFile, $stackPtr, array $config) { $phpcsFile->addWarning( 'Calls to removed code are not allowed; found %s. Removed in %s. %s. See: %s', $stackPtr, - $removed['identifier'], + $config['identifier'], [ - $removed['oldUsage'], - $removed['versionRemoved'], - $this->getReplacement($removed), - $removed['docsUrl'], + $config['oldUsage'], + $config['versionRemoved'], + $this->getReplacement($config), + $config['docsUrl'], ] ); } diff --git a/src/Standards/Typo3Update/Feature/FeatureInterface.php b/src/Standards/Typo3Update/Feature/FeatureInterface.php index ac8b7a9..8ab83a7 100644 --- a/src/Standards/Typo3Update/Feature/FeatureInterface.php +++ b/src/Standards/Typo3Update/Feature/FeatureInterface.php @@ -28,11 +28,6 @@ use PHP_CodeSniffer_Sniff as PhpCsSniff; */ interface FeatureInterface { - /** - * @var PhpCsSniff $sniff - */ - public function __construct(PhpCsSniff $sniff); - /** * Process like a PHPCS Sniff. * diff --git a/src/Standards/Typo3Update/Feature/RemovedClassFeature.php b/src/Standards/Typo3Update/Feature/RemovedClassFeature.php index ffc61df..5584dfc 100644 --- a/src/Standards/Typo3Update/Feature/RemovedClassFeature.php +++ b/src/Standards/Typo3Update/Feature/RemovedClassFeature.php @@ -27,7 +27,7 @@ class RemovedClassFeature extends AbstractYamlRemovedUsage { public function process(PhpCsFile $phpcsFile, $classnamePosition, $classname) { - if (! $this->configured->isRemoved($classname)) { + if ($this->configured->isRemoved($classname) === false) { return; } $this->addWarning( diff --git a/src/Standards/Typo3Update/RemovedByYamlConfiguration.php b/src/Standards/Typo3Update/RemovedByYamlConfiguration.php index f1596a9..046c180 100644 --- a/src/Standards/Typo3Update/RemovedByYamlConfiguration.php +++ b/src/Standards/Typo3Update/RemovedByYamlConfiguration.php @@ -33,7 +33,7 @@ class RemovedByYamlConfiguration /** * @param array $configFiles - * @param Callable $prepareStructure + * @param \Callable $prepareStructure */ public function __construct(array $configFiles, $prepareStructure) { From 3fbceb9bbf2c7bb44e7a27e6d56eba5d454ded96 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 16:45:39 +0200 Subject: [PATCH 091/100] TASK: Add gitlab template for merge requests * To make writing merge requests easier. * Also this should keep them in same structure. --- .gitlab/merge_request_templates/default.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitlab/merge_request_templates/default.md diff --git a/.gitlab/merge_request_templates/default.md b/.gitlab/merge_request_templates/default.md new file mode 100644 index 0000000..67ad892 --- /dev/null +++ b/.gitlab/merge_request_templates/default.md @@ -0,0 +1,6 @@ +* Write some info about what has been done. +* Also don't forget to mention why this has been done, e.g. introduced new + feature? + +Resolves: #IssueNumber + From a0c9df56675606969b542d627428ed469e9fd75a Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 16:54:51 +0200 Subject: [PATCH 092/100] TASK: Document yaml format for features * To enable others to configure their own features. Resolves: #76 --- Documentation/source/configuration.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst index 7f8ffc7..effb38b 100644 --- a/Documentation/source/configuration.rst +++ b/Documentation/source/configuration.rst @@ -288,3 +288,29 @@ Two examples:: new HRULER: replacement: 'Any installation should migrate to alternatives such as F...' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog...' + +Features +^^^^^^^^ + +Configures which Features should be attached to x Sniffs, where Key is the FQCN of the feature and +the values are FQCN of the sniffs. + +Works only if the sniff respects execution of features. + +One example:: + + Typo3Update\Feature\LegacyClassnameFeature: + - Typo3Update_Sniffs_Classname_InheritanceSniff + - Typo3Update_Sniffs_Classname_InlineCommentSniff + - Typo3Update_Sniffs_Classname_InstanceofSniff + - Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff + - Typo3Update_Sniffs_Classname_InstantiationWithNewSniff + - Typo3Update_Sniffs_Classname_InstantiationWithObjectManagerSniff + - Typo3Update_Sniffs_Classname_IsACallSniff + - Typo3Update_Sniffs_Classname_MissingVendorForPluginsAndModulesSniff + - Typo3Update_Sniffs_Classname_PhpDocCommentSniff + - Typo3Update_Sniffs_Classname_StaticCallSniff + - Typo3Update_Sniffs_Classname_TypeHintCatchExceptionSniff + - Typo3Update_Sniffs_Classname_TypeHintSniff + - Typo3Update_Sniffs_Classname_UseSniff + - Typo3Update_Sniffs_LegacyClassname_MissingNamespaceSniff From a84f164c49096e6f790f0267b9c347c385b07a15 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 17:01:06 +0200 Subject: [PATCH 093/100] TASK: Fix typo --- Documentation/source/features.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/source/features.rst b/Documentation/source/features.rst index e055e92..2ae12ad 100644 --- a/Documentation/source/features.rst +++ b/Documentation/source/features.rst @@ -15,7 +15,7 @@ Possible configurations for all sniffs: Implemented sniffs: -- PHPDocuments, like Includes and annotations for IDEs. +- PHPDocComments, like Includes and annotations for IDEs. Possible extra configurations: From 582ede251381a7600748974bce3b3bb8762a828f Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 27 Apr 2017 17:01:30 +0200 Subject: [PATCH 094/100] TASK: Add removed TypoScript feature to docs --- Documentation/source/features.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/source/features.rst b/Documentation/source/features.rst index 2ae12ad..51c8910 100644 --- a/Documentation/source/features.rst +++ b/Documentation/source/features.rst @@ -103,6 +103,15 @@ information. For configuration options see :ref:`configuration-removedFunctionCo Check for usage of *removed constants*. The constants are configured in same way as removed functions. For configuration options see :ref:`configuration-removedConstantConfigFiles`. +Check for usage of *removed TypoScript*. The TypoScript objects are configured in same way as +removed functions. For configuration options see :ref:`configuration-removedTypoScriptConfigFiles`. +This will check whether you are using already removed TypoScript parts, supported are: + +- Objects, e.g. ``CLEARGIF``, ``FORM`` + +- Paths like ``styles.insertContent`` + +For a complete list, take a look at the corresponding YAML-Files. Further checks -------------- From 299c33a075f09d539d7e6cad001cfa94f5609f72 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 2 May 2017 12:44:04 +0200 Subject: [PATCH 095/100] FEATURE: Add warning for removed TypoScript Constants * Configure removed constants in TYPO3 7.x. * Add code / sniff. * Add test. * Update docs. Resolves: #74 --- Documentation/source/configuration.rst | 22 +++++ Documentation/source/features.rst | 4 + .../Removed/TypoScriptConstant/7.0.yaml | 20 +++++ src/Standards/Typo3Update/Options.php | 13 +++ .../Removed/TypoScriptConstantSniff.php | 86 +++++++++++++++++++ .../TypoScriptConstantSniff/Expected.json | 42 +++++++++ .../InputFileForIssues.ts | 8 ++ 7 files changed, 195 insertions(+) create mode 100644 src/Standards/Typo3Update/Configuration/Removed/TypoScriptConstant/7.0.yaml create mode 100644 src/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff.php create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/Expected.json create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/InputFileForIssues.ts diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst index effb38b..ce735c6 100644 --- a/Documentation/source/configuration.rst +++ b/Documentation/source/configuration.rst @@ -187,6 +187,28 @@ Using ``runtime-set``: --runtime-set removedTypoScriptConfigFiles "/Some/Absolute/Path/*.yaml" +.. _configuration-removedTypoScriptConstantConfigFiles: + +removedTypoScriptConstantsConfigFiles +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Configure where to look for configuration files defining the removed TypoScript constants. +Default is ``Configuration/Removed/TypoScriptConstants/*.yaml`` inside the standard itself. +We already try to deliver as much as possible. Globing is used, so placeholders like ``*`` are +possible, see https://secure.php.net/manual/en/function.glob.php + +Using :file:`ruleset.xml`: + +.. code:: xml + + + +Using ``runtime-set``: + +.. code:: bash + + --runtime-set removedTypoScriptConstantConfigFiles "/Some/Absolute/Path/*.yaml" + .. _configuration-features: features diff --git a/Documentation/source/features.rst b/Documentation/source/features.rst index 51c8910..648e91b 100644 --- a/Documentation/source/features.rst +++ b/Documentation/source/features.rst @@ -111,6 +111,10 @@ This will check whether you are using already removed TypoScript parts, supporte - Paths like ``styles.insertContent`` +Check for usage of *removed TypoScript constants*. The TypoScript constants are configured in same +way as removed functions. For configuration options see +:ref:`configuration-removedTypoScriptConstantConfigFiles`. + For a complete list, take a look at the corresponding YAML-Files. Further checks diff --git a/src/Standards/Typo3Update/Configuration/Removed/TypoScriptConstant/7.0.yaml b/src/Standards/Typo3Update/Configuration/Removed/TypoScriptConstant/7.0.yaml new file mode 100644 index 0000000..80d7e28 --- /dev/null +++ b/src/Standards/Typo3Update/Configuration/Removed/TypoScriptConstant/7.0.yaml @@ -0,0 +1,20 @@ +# Breaking changes in 7.0: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Index.html#breaking-changes +'7.0': + _clear: + replacement: 'Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html' + _blackBorderWrap: + replacement: 'Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html' + _tableWrap: + replacement: 'Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html' + _tableWrap_DEBUG: + replacement: 'Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html' + _stdFrameParams: + replacement: 'Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html' + _stdFramesetParams: + replacement: 'Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility' + docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html' diff --git a/src/Standards/Typo3Update/Options.php b/src/Standards/Typo3Update/Options.php index 62b8a78..f5a4777 100644 --- a/src/Standards/Typo3Update/Options.php +++ b/src/Standards/Typo3Update/Options.php @@ -95,6 +95,19 @@ class Options ); } + /** + * Returns an array of absolute file names containing removed typoscript constants. + * + * @return array + */ + public static function getRemovedTypoScriptConstantConfigFiles() + { + return static::getOptionFileNames( + 'removedTypoScriptConstant', + __DIR__ . '/Configuration/Removed/TypoScriptConstant/*.yaml' + ); + } + /** * Returns an array of absolute file names containing removed class configurations. * diff --git a/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff.php b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff.php new file mode 100644 index 0000000..c396d32 --- /dev/null +++ b/src/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff.php @@ -0,0 +1,86 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Helmich\TypoScriptParser\Tokenizer\TokenInterface; +use PHP_CodeSniffer_File as PhpCsFile; +use Typo3Update\Options; +use Typo3Update\Sniffs\Removed\AbstractGenericUsage; + +class Typo3Update_Sniffs_Removed_TypoScriptConstantSniff extends AbstractGenericUsage +{ + /** + * Register sniff only for TypoScript. + * @var array + */ + public $supportedTokenizers = [ + 'TYPOSCRIPT', + ]; + + public function register() + { + return [ + TokenInterface::TYPE_RIGHTVALUE_MULTILINE, + TokenInterface::TYPE_RIGHTVALUE, + ]; + } + + protected function prepareStructure(array $typo3Versions) + { + $newStructure = []; + + foreach ($typo3Versions as $typo3Version => $removals) { + foreach ($removals as $removed => $config) { + $config['name'] = $removed; + $config['identifier'] = $removed; + $config['oldUsage'] = $removed; + $config['versionRemoved'] = $typo3Version; + $newStructure[$removed] = $config; + } + } + + return $newStructure; + } + + protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr) + { + $removed = []; + $tokens = $phpcsFile->getTokens(); + $token = $tokens[$stackPtr]; + $matches = []; + preg_match_all('/\{\$.*\}/', $token['content'], $matches); + + foreach ($matches as $constants) { + foreach ($constants as $constant) { + $constant = substr($constant, 2, -1); + if ($this->configured->isRemoved($constant)) { + $removed[] = $this->configured->getRemoved($constant); + } + } + } + + return $removed; + } + + protected function getRemovedConfigFiles() + { + return Options::getRemovedTypoScriptConstantConfigFiles(); + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/Expected.json b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/Expected.json new file mode 100644 index 0000000..e353a62 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/Expected.json @@ -0,0 +1,42 @@ +{ + "files": { + "InputFileForIssues.ts": { + "errors": 0, + "messages": [ + { + "column": 13, + "fixable": false, + "line": 3, + "message": "Calls to removed code are not allowed; found _clear. Removed in 7.0. Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScriptConstant._clear", + "type": "WARNING" + }, + { + "column": 11, + "fixable": false, + "line": 4, + "message": "Calls to removed code are not allowed; found _tableWrap_DEBUG. Removed in 7.0. Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScriptConstant._tableWrap_DEBUG", + "type": "WARNING" + }, + { + "column": 11, + "fixable": false, + "line": 4, + "message": "Calls to removed code are not allowed; found _tableWrap. Removed in 7.0. Either remove usage of constant or add a snippet at an early point in TypoScript for backwards compatibility. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.0/Breaking-60561-DefaultTypoScriptConstantsRemoved.html", + "severity": 5, + "source": "Typo3Update.Removed.TypoScriptConstant._tableWrap", + "type": "WARNING" + } + ], + "warnings": 3 + } + }, + "totals": { + "errors": 0, + "fixable": 0, + "warnings": 3 + } +} diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/InputFileForIssues.ts b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/InputFileForIssues.ts new file mode 100644 index 0000000..e8cc475 --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Removed/TypoScriptConstantSniff/InputFileForIssues.ts @@ -0,0 +1,8 @@ +test = TEXT +test { + value = Some stuff {$_clear} and some more. + value ( + Some values {$_tableWrap_DEBUG} + {$_tableWrap} + ) +} From ea0dc99e14c2991091e4b0187b829f11ccc743fa Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 2 May 2017 15:05:01 +0200 Subject: [PATCH 096/100] TASK: Use test class for each sniff. * Allow executing tests for single sniff through phpunit '--filter'. * Provide structure to add further tests for a single sniff. * Make output more clear, which sniff was tested. --- .../Typo3Update/Sniffs/Classname.php | 28 +++++++++++++++++++ .../Sniffs/Classname/InheritanceSniffTest.php | 28 +++++++++++++++++++ .../Classname/InlineCommentSniffTest.php | 28 +++++++++++++++++++ .../Sniffs/Classname/InstanceofSniffTest.php | 28 +++++++++++++++++++ ...InstantiationWithMakeInstanceSniffTest.php | 28 +++++++++++++++++++ .../InstantiationWithNewSniffTest.php | 28 +++++++++++++++++++ ...nstantiationWithObjectManagerSniffTest.php | 28 +++++++++++++++++++ tests/Sniffs/Classname/IsACallSniffTest.php | 28 +++++++++++++++++++ .../Classname/PhpDocCommentSniffTest.php | 28 +++++++++++++++++++ .../Sniffs/Classname/StaticCallSniffTest.php | 28 +++++++++++++++++++ .../TypeHintCatchExceptionSniffTest.php | 28 +++++++++++++++++++ tests/Sniffs/Classname/TypeHintSniffTest.php | 28 +++++++++++++++++++ tests/Sniffs/Classname/UseSniffTest.php | 28 +++++++++++++++++++ .../Deprecated/AjaxRegistrationTest.php | 28 +++++++++++++++++++ .../MissingNamespaceSniffTest.php | 28 +++++++++++++++++++ ...ingVendorForPluginsAndModulesSniffTest.php | 28 +++++++++++++++++++ .../Removed/GenericConstantUsageSniffTest.php | 28 +++++++++++++++++++ .../Removed/GenericFunctionCallSniffTest.php | 28 +++++++++++++++++++ tests/Sniffs/Removed/TypoScriptSniffTest.php | 28 +++++++++++++++++++ tests/SniffsTest.php | 24 +++++++++------- 20 files changed, 546 insertions(+), 10 deletions(-) create mode 100644 tests/Fixtures/Standards/Typo3Update/Sniffs/Classname.php create mode 100644 tests/Sniffs/Classname/InheritanceSniffTest.php create mode 100644 tests/Sniffs/Classname/InlineCommentSniffTest.php create mode 100644 tests/Sniffs/Classname/InstanceofSniffTest.php create mode 100644 tests/Sniffs/Classname/InstantiationWithMakeInstanceSniffTest.php create mode 100644 tests/Sniffs/Classname/InstantiationWithNewSniffTest.php create mode 100644 tests/Sniffs/Classname/InstantiationWithObjectManagerSniffTest.php create mode 100644 tests/Sniffs/Classname/IsACallSniffTest.php create mode 100644 tests/Sniffs/Classname/PhpDocCommentSniffTest.php create mode 100644 tests/Sniffs/Classname/StaticCallSniffTest.php create mode 100644 tests/Sniffs/Classname/TypeHintCatchExceptionSniffTest.php create mode 100644 tests/Sniffs/Classname/TypeHintSniffTest.php create mode 100644 tests/Sniffs/Classname/UseSniffTest.php create mode 100644 tests/Sniffs/Deprecated/AjaxRegistrationTest.php create mode 100644 tests/Sniffs/LegacyClassname/MissingNamespaceSniffTest.php create mode 100644 tests/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniffTest.php create mode 100644 tests/Sniffs/Removed/GenericConstantUsageSniffTest.php create mode 100644 tests/Sniffs/Removed/GenericFunctionCallSniffTest.php create mode 100644 tests/Sniffs/Removed/TypoScriptSniffTest.php diff --git a/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname.php b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname.php new file mode 100644 index 0000000..ca3784e --- /dev/null +++ b/tests/Fixtures/Standards/Typo3Update/Sniffs/Classname.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InlineCommentSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/InheritanceSniffTest.php b/tests/Sniffs/Classname/InheritanceSniffTest.php new file mode 100644 index 0000000..56c8bcb --- /dev/null +++ b/tests/Sniffs/Classname/InheritanceSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InheritanceSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/InlineCommentSniffTest.php b/tests/Sniffs/Classname/InlineCommentSniffTest.php new file mode 100644 index 0000000..ca3784e --- /dev/null +++ b/tests/Sniffs/Classname/InlineCommentSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InlineCommentSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/InstanceofSniffTest.php b/tests/Sniffs/Classname/InstanceofSniffTest.php new file mode 100644 index 0000000..49f9210 --- /dev/null +++ b/tests/Sniffs/Classname/InstanceofSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InstanceofSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/InstantiationWithMakeInstanceSniffTest.php b/tests/Sniffs/Classname/InstantiationWithMakeInstanceSniffTest.php new file mode 100644 index 0000000..a54ab8f --- /dev/null +++ b/tests/Sniffs/Classname/InstantiationWithMakeInstanceSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InstantiationWithMakeInstanceSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/InstantiationWithNewSniffTest.php b/tests/Sniffs/Classname/InstantiationWithNewSniffTest.php new file mode 100644 index 0000000..3c07834 --- /dev/null +++ b/tests/Sniffs/Classname/InstantiationWithNewSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InstantiationWithNewSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/InstantiationWithObjectManagerSniffTest.php b/tests/Sniffs/Classname/InstantiationWithObjectManagerSniffTest.php new file mode 100644 index 0000000..c2348bf --- /dev/null +++ b/tests/Sniffs/Classname/InstantiationWithObjectManagerSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class InstantiationWithObjectManagerSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/IsACallSniffTest.php b/tests/Sniffs/Classname/IsACallSniffTest.php new file mode 100644 index 0000000..6930ddf --- /dev/null +++ b/tests/Sniffs/Classname/IsACallSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class IsACallSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/PhpDocCommentSniffTest.php b/tests/Sniffs/Classname/PhpDocCommentSniffTest.php new file mode 100644 index 0000000..fb7fa8c --- /dev/null +++ b/tests/Sniffs/Classname/PhpDocCommentSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class PhpDocCommentSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/StaticCallSniffTest.php b/tests/Sniffs/Classname/StaticCallSniffTest.php new file mode 100644 index 0000000..e3b5faa --- /dev/null +++ b/tests/Sniffs/Classname/StaticCallSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class StaticCallSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/TypeHintCatchExceptionSniffTest.php b/tests/Sniffs/Classname/TypeHintCatchExceptionSniffTest.php new file mode 100644 index 0000000..a7d14b9 --- /dev/null +++ b/tests/Sniffs/Classname/TypeHintCatchExceptionSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class TypeHintCatchExceptionSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/TypeHintSniffTest.php b/tests/Sniffs/Classname/TypeHintSniffTest.php new file mode 100644 index 0000000..e8c1637 --- /dev/null +++ b/tests/Sniffs/Classname/TypeHintSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class TypeHintSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Classname/UseSniffTest.php b/tests/Sniffs/Classname/UseSniffTest.php new file mode 100644 index 0000000..ee03896 --- /dev/null +++ b/tests/Sniffs/Classname/UseSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class UseSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Deprecated/AjaxRegistrationTest.php b/tests/Sniffs/Deprecated/AjaxRegistrationTest.php new file mode 100644 index 0000000..b67c1ec --- /dev/null +++ b/tests/Sniffs/Deprecated/AjaxRegistrationTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class AjaxRegistrationSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/LegacyClassname/MissingNamespaceSniffTest.php b/tests/Sniffs/LegacyClassname/MissingNamespaceSniffTest.php new file mode 100644 index 0000000..07239dc --- /dev/null +++ b/tests/Sniffs/LegacyClassname/MissingNamespaceSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class MissingNamespaceSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniffTest.php b/tests/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniffTest.php new file mode 100644 index 0000000..d73ca67 --- /dev/null +++ b/tests/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class MissingVendorForPluginsAndModulesSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Removed/GenericConstantUsageSniffTest.php b/tests/Sniffs/Removed/GenericConstantUsageSniffTest.php new file mode 100644 index 0000000..c955042 --- /dev/null +++ b/tests/Sniffs/Removed/GenericConstantUsageSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class GenericConstantUsageSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Removed/GenericFunctionCallSniffTest.php b/tests/Sniffs/Removed/GenericFunctionCallSniffTest.php new file mode 100644 index 0000000..a0176b8 --- /dev/null +++ b/tests/Sniffs/Removed/GenericFunctionCallSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class GenericFunctionCallSniffTest extends SniffsTest +{ +} diff --git a/tests/Sniffs/Removed/TypoScriptSniffTest.php b/tests/Sniffs/Removed/TypoScriptSniffTest.php new file mode 100644 index 0000000..f7f91cc --- /dev/null +++ b/tests/Sniffs/Removed/TypoScriptSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class TypoScriptSniffTest extends SniffsTest +{ +} diff --git a/tests/SniffsTest.php b/tests/SniffsTest.php index 9f7a3b9..39f5ac4 100644 --- a/tests/SniffsTest.php +++ b/tests/SniffsTest.php @@ -29,7 +29,7 @@ use Symfony\Component\Finder\Finder; * * To add a test, just create the necessary fixture folder structure with files. */ -class SniffsTest extends TestCase +abstract class SniffsTest extends TestCase { /** * Get all fixtures for sniffs. @@ -61,16 +61,20 @@ class SniffsTest extends TestCase public function getSniffs() { $sniffs = []; - $finder = new Finder(); - $finder->in( - __DIR__ - . DIRECTORY_SEPARATOR . 'Fixtures' - . DIRECTORY_SEPARATOR . 'Standards' - . DIRECTORY_SEPARATOR . 'Typo3Update' - . DIRECTORY_SEPARATOR . 'Sniffs' - ); - foreach ($finder->directories()->name('*Sniff') as $folder) { + $classnameParts = array_slice(explode('\\', get_class($this)), 3); + $lastIndex = count($classnameParts) - 1; + $classnameParts[$lastIndex] = substr($classnameParts[$lastIndex], 0, -4); + $folderName = array_pop($classnameParts); + $folder = array_merge([ + __DIR__, + 'Fixtures', 'Standards', 'Typo3Update', 'Sniffs', + ], $classnameParts); + + $finder = new Finder(); + $finder->in(implode(DIRECTORY_SEPARATOR, $folder)); + + foreach ($finder->directories()->name($folderName) as $folder) { $sniff = [ $folder, [], From e78931186244ff388551ce53d42507145d064db1 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 4 May 2017 08:30:14 +0200 Subject: [PATCH 097/100] TASK: Migrate added test * As test was added to develop, also migrate it. --- .../Removed/TypoScriptConstantSniffTest.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/Sniffs/Removed/TypoScriptConstantSniffTest.php diff --git a/tests/Sniffs/Removed/TypoScriptConstantSniffTest.php b/tests/Sniffs/Removed/TypoScriptConstantSniffTest.php new file mode 100644 index 0000000..cec7d71 --- /dev/null +++ b/tests/Sniffs/Removed/TypoScriptConstantSniffTest.php @@ -0,0 +1,28 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +use Typo3Update\Tests\SniffsTest; + +class TypoScriptConstantSniffTest extends SniffsTest +{ +} From 9e3f8b81954f9e2de19cfaf23fac15b13b7a6743 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 4 May 2017 08:35:13 +0200 Subject: [PATCH 098/100] TASK: Document new test implementation --- Documentation/source/extending.rst | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Documentation/source/extending.rst b/Documentation/source/extending.rst index cf899ba..63a8877 100644 --- a/Documentation/source/extending.rst +++ b/Documentation/source/extending.rst @@ -55,6 +55,44 @@ a folder named like the sniff. E.g. you want to add a test for sniff :file:`src/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff.php`, the following folder has to exist: :file:`tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/`. +Also for convenience add a test class with following content: + +.. code-block:: php + + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + + use Typo3Update\Tests\SniffsTest; + + class TypoScriptSniffTest extends SniffsTest + { + } + +Place it accordingly to namespace. Adjust namespace and class name. No code is needed, everything is +done in ``SniffsTest``. But this enables you to add ``--filter`` to ``phpunit`` to run just one +test. Also IDEs support to run the single test file. This makes development much faster and failing +tests more helpfull as they contain the class name. + .. _extending-tests-single: Single test per sniff From 7f17db504c88f950c6a103aee06ed180c64bd03f Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 4 May 2017 08:35:25 +0200 Subject: [PATCH 099/100] BUGFIX: Fix broken rst syntax --- Documentation/source/configuration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/source/configuration.rst b/Documentation/source/configuration.rst index 72cae65..5cc0c0e 100644 --- a/Documentation/source/configuration.rst +++ b/Documentation/source/configuration.rst @@ -212,7 +212,7 @@ Using ``runtime-set``: .. _configuration-removedTypoScriptConstantConfigFiles: removedTypoScriptConstantsConfigFiles -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Configure where to look for configuration files defining the removed TypoScript constants. Default is ``Configuration/Removed/TypoScriptConstants/*.yaml`` inside the standard itself. From 4031055210841ad20c19c31bfe8ba14dc78a9ba6 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 4 May 2017 08:38:02 +0200 Subject: [PATCH 100/100] TASK: Rename ci documentation jobs * To have them much shorter, enabling full title to show up in gitlab ui. --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index af289ad..a0412df 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -59,7 +59,7 @@ test:latest: <<: *PHP-UNITTESTING image: php:7-alpine -test:documentation:syntax: &SPHINX-DOCS +test:doc:syntax: &SPHINX-DOCS image: 'danielsiepmann/sphinx:latest' stage: test before_script: @@ -67,12 +67,12 @@ test:documentation:syntax: &SPHINX-DOCS script: - make dummy -test:documentation:external-links: +test:doc:external-links: <<: *SPHINX-DOCS script: - make linkcheck -render:documentation: +render:doc: <<: *SPHINX-DOCS stage: render script: