Merge remote-tracking branch 'origin/develop' into feature/44-add-checks-for-deprecated-removed-extensions

This commit is contained in:
Daniel Siepmann 2017-05-04 16:04:51 +02:00
commit c7112c0fae
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
146 changed files with 4132 additions and 1261 deletions

View file

@ -5,46 +5,78 @@ before_script:
- mkdir -p result
stages:
- sync
- test
- render
lint:coding-guideline:
image: php:7.0-alpine
sync:github:
image: 'bash:latest'
stage: sync
before_script:
- apk add --no-cache openssh-client git
# SSH deploy key
- eval $(ssh-agent -s)
- 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:
- git clone --mirror ${CI_REPOSITORY_URL} mirror
- cd mirror
- git push --mirror ${MIRROR_GIT_URL}
lint:coding-guideline: &PHP-LINTING
image: php:7.1-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:
- 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
- ./vendor/bin/phpmd src html phpmd.xml > result/phpmd.html
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:7.1:
<<: *PHP-UNITTESTING
image: php:7.1-alpine
test:latest:
<<: *PHP-UNITTESTING
image: php:7-alpine
stage: test
script:
- ./vendor/bin/phpunit
# Further stages, and jobs e.g. linting, cgl, etc.
test:doc:syntax: &SPHINX-DOCS
image: 'danielsiepmann/sphinx:latest'
stage: test
before_script:
- cd Documentation
script:
- make dummy
test:doc:external-links:
<<: *SPHINX-DOCS
script:
- make linkcheck
render:doc:
<<: *SPHINX-DOCS
stage: render
script:
- make html
artifacts:
paths:
- Documentation/build/html

View file

@ -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

View file

@ -1,13 +0,0 @@
build:
tests:
before:
- make install
environment:
php:
version: 5.6
ini:
'date.timezone': 'Europe/Berlin'
filter:
excluded_paths:
- "tests/Fixtures/"

1
Documentation/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
build

230
Documentation/Makefile Normal file
View file

@ -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 <target>' where <target> 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."

View file

View file

@ -0,0 +1 @@
guzzle_sphinx_theme == 0.7

View file

@ -0,0 +1,313 @@
# -*- 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 ----------------------------------------------
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'
# 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.
# "<project> v<release> 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 = {
'**': ['logo-text.html',
'globaltoc.html',
'localtoc.html',
'searchbox.html',
],
}
# 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 <link> 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}

View file

@ -0,0 +1,360 @@
.. _highlight: yaml
.. _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.
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`.
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:
legacyExtensions
^^^^^^^^^^^^^^^^
Configures which extension names are legacy. Used to provide further checks and warnings about
possible legacy code. All class usages starting with ``Tx_<ExtensionName>`` 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 ``PhpDocComment``.
Example:
.. code:: xml
<rule ref="Typo3Update.Classname.Instanceof">
<properties>
<property name="legacyExtensions" type="array" value="Extbase,Fluid,Frontend,Core"/>
</properties>
</rule>
.. _configuration-allowedTags:
allowedTags
^^^^^^^^^^^
Only used inside Sniff ``Typo3Update.Classname.PhpDocComment``.
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
<rule ref="Typo3Update.Classname.PhpDocComment">
<properties>
<property name="allowedTags" type="array" value="@param,@return,@var,@see,@throws"/>
</properties>
</rule>
.. _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
<config name="mappingFile" value="/projects/typo3_installation/vendor/composer/autoload_classaliasmap.php"/>
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
<config name="vendor" value="YourVendor"/>
Using ``runtime-set``:
.. 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
<config name="removedFunctionConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
Using ``runtime-set``:
.. 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
<config name="removedConstantConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
Using ``runtime-set``:
.. code:: bash
--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
<config name="removedClassConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
Using ``runtime-set``:
.. code:: bash
--runtime-set removedClassConfigFiles "/Some/Absolute/Path/*.yaml"
.. _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.
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
<config name="removedTypoScriptConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
Using ``runtime-set``:
.. code:: bash
--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
<config name="removedTypoScriptConstantConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
Using ``runtime-set``:
.. code:: bash
--runtime-set removedTypoScriptConstantConfigFiles "/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
<config name="features" value="/Some/Absolute/Path/*.yaml"/>
Using ``runtime-set``:
.. code:: bash
--runtime-set features "/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...'
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

View file

@ -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/?redir=%2Fmessages%2F%40danielsiepmann
.. _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/

View file

@ -0,0 +1,151 @@
.. _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#user-content-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-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
-----
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/`.
Also for convenience add a test class with following content:
.. code-block:: php
<?php
namespace Typo3Update\Tests\Sniffs\Removed;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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
^^^^^^^^^^^^^^^^^^^^^
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
<?php
return [
'defaultVendor' => [],
'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/

View file

@ -0,0 +1,126 @@
.. _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:
- PHPDocComments, 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 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 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`.
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``
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
--------------
- Legacy ajax registrations for TYPO3 Backend.

View file

@ -0,0 +1,72 @@
.. _highlight: bash
About
=====
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.
We recommend to use at least PHP 5.6, we do not test with lower versions as 5.6 is latest maintained
version.
Installation
============
Run::
make install
Afterwards the :ref:`configuration-mappingFile` is required.
What does it look like?
=======================
.. code::
$ ./vendor/bin/phpcs -p --colors -s <path>
E
FILE: <path>
----------------------------------------------------------------------
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:
features
configuration
usage
extending
contribution

View file

@ -0,0 +1,56 @@
.. _highlight: bash
Usage
=====
If everything is configured, you can run::
./vendor/bin/phpcbf <path>
This will run the auto fixer recursive for ``<path>`` 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 <path>
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 <pathToMappingFile> <pathToCodeToCheck>
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.
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
---
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 <path>
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.

View file

@ -1,5 +1,3 @@
.. _highlight: bash
About
=====
@ -7,238 +5,9 @@ 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.
Requirements
============
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.
- ``composer`` needs to be installed and inside your ``$PATH``.
Github is just used as a mirror for the project.
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 <path>
This will run the auto fixer recursive for ``<path>`` fixing all issues.
Afterwards you should run::
./vendor/bin/phpcs <path>
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 <path>
E
FILE: <path>
----------------------------------------------------------------------
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
<rule ref="Typo3Update.LegacyClassnames.Instanceof">
<properties>
<property name="legacyExtensions" type="array" value="Extbase,Fluid,Frontend,Core"/>
</properties>
</rule>
Typo3Update.LegacyClassnames.DocComment: ``allowedTags``
Configures which tags are checked for legacy class names.
Example:
.. code:: xml
<rule ref="Typo3Update.LegacyClassnames.DocComment">
<properties>
<property name="allowedTags" type="array" value="@param,@return,@var,@see,@throws"/>
</properties>
</rule>
``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
<config name="mappingFile" value="/projects/typo3_installation/vendor/composer/autoload_classaliasmap.php"/>
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
<config name="vendor" value="YourVendor"/>
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
<config name="removedFunctionConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
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
<config name="removedConstantConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
Example:
.. code:: bash
--runtime-set removedConstantConfigFiles "/Some/Absolute/Path/*.yaml"
Check out the official documentation at: https://automated-typo3-update.readthedocs.io

View file

@ -1,7 +1,7 @@
{
"name": "siepmann/typo3_update",
"description": "Auto migrate PHP Source of extensions to be compatible.",
"type": "project",
"type": "php-codesniffer-standards",
"license": "GPL-2.0+",
"authors": [
{
@ -23,9 +23,11 @@
]
},
"require": {
"php": ">=5.6",
"helmich/typo3-typoscript-parser": "1.1.*",
"squizlabs/php_codesniffer": "2.8.*",
"symfony/yaml": "3.2.*"
"symfony/yaml": "3.2.*",
"higidi/composer-phpcodesniffer-standards-plugin": "*"
},
"require-dev": {
"phpunit/phpunit": "5.7.*",

View file

@ -0,0 +1,97 @@
<?php
namespace Typo3Update;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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;
/**
* Base class for all classes working with removed configuration through yaml files.
*/
abstract class AbstractYamlRemovedUsage
{
/**
* @var RemovedByYamlConfiguration
*/
protected $configured;
public function __construct()
{
$this->configured = new RemovedByYamlConfiguration(
$this->getRemovedConfigFiles(),
$this->getPrepareStructureCallback()
);
}
/**
* @return \Callable
*/
protected function getPrepareStructureCallback()
{
return function (array $typo3Versions) {
return call_user_func_array([$this, 'prepareStructure'], [$typo3Versions]);
};
}
/**
* @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 $config
*/
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,
$config['identifier'],
[
$config['oldUsage'],
$config['versionRemoved'],
$this->getReplacement($config),
$config['docsUrl'],
]
);
}
/**
* @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';
}
}

View file

@ -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_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

View file

@ -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

View file

@ -0,0 +1,56 @@
# 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'
\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'

View file

@ -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'

View file

@ -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'

View file

@ -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'

View file

@ -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'

View file

@ -0,0 +1,26 @@
# 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'
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'

View file

@ -0,0 +1,35 @@
# 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)'
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'
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'

View file

@ -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'

View file

@ -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'

View file

@ -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'

View file

@ -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'

View file

@ -0,0 +1,32 @@
<?php
namespace Typo3Update\Feature;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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;
use Typo3Update\AbstractYamlRemovedUsage as BaseAbstractYamlRemovedUsage;
abstract class AbstractYamlRemovedUsage extends BaseAbstractYamlRemovedUsage implements FeatureInterface
{
public function __construct(PhpCsSniff $sniff)
{
parent::__construct();
}
}

View file

@ -0,0 +1,41 @@
<?php
namespace Typo3Update\Feature;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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;
/**
* See "Features" in documentation.
*/
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);
}

View file

@ -0,0 +1,88 @@
<?php
namespace Typo3Update\Feature;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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;
use Typo3Update\Options;
/**
* Contains all configured features for a single sniff.
*/
class Features implements \Iterator
{
/**
* Internal array
* @var array
*/
protected $features = [];
/**
* @param PhpCsSniff $sniff The sniff to collect features for.
*/
public function __construct(PhpCsSniff $sniff)
{
foreach (Options::getFeaturesConfiguration() as $featureName => $sniffs) {
if (in_array(get_class($sniff), $sniffs)) {
$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()
{
return current($this->features);
}
public function key()
{
return key($this->features);
}
public function next()
{
next($this->features);
}
public function rewind()
{
reset($this->features);
}
public function valid()
{
return current($this->features) !== false;
}
}

View file

@ -0,0 +1,63 @@
<?php
namespace Typo3Update\Feature;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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;
/**
* Provides "feature" support for sniffs.
*/
trait FeaturesSupport
{
/**
* @return Features
*/
protected function getFeatures()
{
return 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->getFeatures() as $featureClassName) {
$feature = $this->createFeature($featureClassName);
$feature->process($phpcsFile, $stackPtr, $content);
}
}
/**
* Create a new instance of the given feature.
*
* @param string $featureClassname
* @return FeatureInterface
*/
protected function createFeature($featureClassname)
{
return new $featureClassname($this);
}
}

View file

@ -0,0 +1,212 @@
<?php
namespace Typo3Update\Feature;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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 LegacyClassnameFeature implements FeatureInterface
{
/**
* A list of extension names that might contain legacy class names.
* Used to check clas names for warnings.
*
* Configure through ruleset.xml.
*
* @var array<string>
*/
public $legacyExtensions = ['Extbase', 'Fluid'];
/**
* @var LegacyClassnameMapping
*/
protected $legacyMapping;
/**
* @var PhpCsSniff
*/
protected $sniff;
public function __construct(PhpCsSniff $sniff)
{
$this->sniff = $sniff;
$this->legacyMapping = LegacyClassnameMapping::getInstance();
}
/**
* Process like a PHPCS Sniff.
*
* @param PhpCsFile $phpcsFile
* @param int $classnamePosition
* @param string $classname
*
* @return void
*/
public function process(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);
}
}
/**
* Checks whether a mapping exists for the given $classname,
* indicating it's legacy.
*
* @param string $classname
* @return bool
*/
protected function isLegacyClassname($classname)
{
return $this->legacyMapping->isLegacyClassname($classname);
}
/**
* Guesses whether the given classname is legacy. Will not check
* isLegacyClassname
*
* @param string $classname
* @return bool
*/
protected function isMaybeLegacyClassname($classname)
{
if (strpos($classname, 'Tx_') === false) {
return false;
}
$extensionName = call_user_func(function ($classname) {
$nameParts = explode('_', $classname);
return $nameParts[1];
}, $classname);
if (!in_array($extensionName, $this->legacyExtensions)) {
return false;
}
return true;
}
/**
* @param string $classname
* @return string
*/
protected function getNewClassname($classname)
{
return $this->legacyMapping->getNewClassname($classname);
}
/**
* Add an warning if given $classname is maybe legacy.
*
* @param PhpCsFile $phpcsFile
* @param int $classnamePosition
* @param string $classname
*/
protected function addMaybeWarning(PhpCsFile $phpcsFile, $classnamePosition, $classname)
{
if ($this->isLegacyClassname($classname) || $this->isMaybeLegacyClassname($classname) === false) {
return;
}
$phpcsFile->addWarning(
'Legacy classes are not allowed; found %s that might be a legacy class that does not exist anymore',
$classnamePosition,
'mightBeLegacyClassname',
[$classname]
);
}
/**
* Replaces the classname at $classnamePosition with $classname in $phpcsFile.
*
* @param PhpCsFile $phpcsFile
* @param int $classnamePosition
* @param string $classname
*/
protected function replaceLegacyClassname(
PhpCsFile $phpcsFile,
$classnamePosition,
$classname
) {
$prefix = '\\';
if ($this->useEmptyPrefix($phpcsFile, $classnamePosition)) {
$prefix = '';
}
$newClassname = str_replace(
$classname,
$prefix . $this->getNewClassname($classname),
$phpcsFile->getTokens()[$classnamePosition]['content']
);
// Handle double quotes, with special escaping.
if ($newClassname[0] === '"') {
$newClassname = '"\\\\' . str_replace('\\', '\\\\', ltrim(substr($newClassname, 1), '\\'));
}
$phpcsFile->fixer->replaceToken($classnamePosition, $newClassname);
}
/**
* Check whether new class name for replacment should not contain the "\" as prefix.
*
* @return bool
*/
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;
}
}

View file

@ -1,5 +1,5 @@
<?php
namespace Typo3Update\Sniffs\LegacyClassnames;
namespace Typo3Update\Feature;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
@ -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;

View file

@ -0,0 +1,61 @@
<?php
namespace Typo3Update\Feature;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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\Options;
class RemovedClassFeature extends AbstractYamlRemovedUsage
{
public function process(PhpCsFile $phpcsFile, $classnamePosition, $classname)
{
if ($this->configured->isRemoved($classname) === false) {
return;
}
$this->addWarning(
$phpcsFile,
$classnamePosition,
$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();
}
}

View file

@ -1,5 +1,5 @@
<?php
namespace Typo3Update\Sniffs;
namespace Typo3Update;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
@ -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,46 @@ class Options
{
return static::getOptionFileNames(
'removedConstantConfigFiles',
__DIR__ . '/../Configuration/Removed/Constants/*.yaml'
__DIR__ . '/Configuration/Removed/Constants/*.yaml'
);
}
/**
* Returns an array of absolute file names containing removed typoscript.
*
* @return array<string>
*/
public static function getRemovedTypoScriptConfigFiles()
{
return static::getOptionFileNames(
'removedTypoScript',
__DIR__ . '/Configuration/Removed/TypoScript/*.yaml'
);
}
/**
* Returns an array of absolute file names containing removed typoscript constants.
*
* @return array<string>
*/
public static function getRemovedTypoScriptConstantConfigFiles()
{
return static::getOptionFileNames(
'removedTypoScriptConstant',
__DIR__ . '/Configuration/Removed/TypoScriptConstant/*.yaml'
);
}
/**
* Returns an array of absolute file names containing removed class configurations.
*
* @return array<string>
*/
public static function getRemovedClassConfigFiles()
{
return static::getOptionFileNames(
'removedClassConfigFiles',
__DIR__ . '/Configuration/Removed/Classes/*.yaml'
);
}
@ -99,6 +139,30 @@ class Options
return $option;
}
/**
* Get the configured features.
*
* @return array
*/
public static function getFeaturesConfiguration()
{
$option = [];
$fileNames = static::getOptionFileNames(
'features',
__DIR__ . '/Configuration/Features/*.yaml'
);
foreach ($fileNames as $file) {
$content = Yaml::parse(file_get_contents((string) $file));
if ($content === null) {
$content = [];
}
$option = array_merge($option, $content);
}
return $option;
}
/**
* Get file names defined by option using optionName, if not defined, use default.
*

View file

@ -0,0 +1,79 @@
<?php
namespace Typo3Update;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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 = [];
/**
* @param array $configFiles
* @param \Callable $prepareStructure
*/
public function __construct(array $configFiles, $prepareStructure)
{
foreach ($configFiles as $file) {
$this->configured = array_merge(
$this->configured,
$prepareStructure(Yaml::parse(file_get_contents((string) $file)))
);
}
}
/**
* @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)) {
throw new \Exception(
sprintf('Identifier "%s" is not configured to be removed.', $identifier),
1493289133
);
}
return $this->configured[$identifier];
}
}

View file

@ -0,0 +1,80 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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\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
{
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);
}
}

View file

@ -20,12 +20,9 @@
*/
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.
@ -34,10 +31,7 @@ class Typo3Update_Sniffs_LegacyClassnames_InheritanceSniff extends AbstractClass
*/
public function register()
{
return [
T_EXTENDS,
T_IMPLEMENTS,
];
return [T_EXTENDS, T_IMPLEMENTS];
}
/**
@ -79,16 +73,12 @@ class Typo3Update_Sniffs_LegacyClassnames_InheritanceSniff extends AbstractClass
}
foreach ($interfaces as $interface) {
if (! $this->isLegacyClassname($interface)) {
continue;
}
$position = $phpcsFile->findNext(T_STRING, $stackPtr, null, false, $interface);
if ($position === false) {
continue;
}
$this->addFixableError($phpcsFile, $position, $interface);
$this->processFeatures($phpcsFile, $position, $interface);
}
}
}

View file

@ -20,12 +20,9 @@
*/
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.
@ -34,9 +31,7 @@ class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff extends AbstractCla
*/
public function register()
{
return [
T_COMMENT,
];
return [T_COMMENT];
}
/**
@ -59,7 +54,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)]);
}
/**
@ -77,25 +72,4 @@ class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff extends AbstractCla
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);
}
}

View file

@ -19,12 +19,9 @@
* 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.
@ -33,8 +30,6 @@ class Typo3Update_Sniffs_LegacyClassnames_InstanceofSniff extends AbstractClassn
*/
public function register()
{
return [
T_INSTANCEOF,
];
return [T_INSTANCEOF];
}
}

View file

@ -21,12 +21,9 @@
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,19 +64,6 @@ class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithMakeInstanceSniff ext
$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);
}
}

View file

@ -19,12 +19,9 @@
* 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.

View file

@ -21,12 +21,9 @@
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 +77,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);
}
}

View file

@ -20,12 +20,9 @@
*/
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 +66,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);
}
}

View file

@ -20,15 +20,20 @@
*/
use PHP_CodeSniffer_File as PhpCsFile;
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use Typo3Update\Feature\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<string>
@ -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);
}
}

View file

@ -19,12 +19,9 @@
* 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

View file

@ -19,12 +19,9 @@
* 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.

View file

@ -20,12 +20,9 @@
*/
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 +55,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']);
}
}
}

View file

@ -20,14 +20,9 @@
*/
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 +33,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);
}
}

View file

@ -20,13 +20,14 @@
*/
use PHP_CodeSniffer_File as PhpCsFile;
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
use Typo3Update\Sniffs\Options;
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use Typo3Update\Feature\LegacyClassnameMapping;
use Typo3Update\Options;
/**
* Detect missing namespaces for class definitions.
*/
class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends AbstractClassnameChecker
class Typo3Update_Sniffs_LegacyClassname_MissingNamespaceSniff implements PhpCsSniff
{
/**
* Returns the token types that this sniff is interested in.
@ -66,27 +67,16 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
}
$classname = $tokens[$classnamePosition]['content'];
$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);
}
}
/**
@ -94,18 +84,12 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
* @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;
@ -114,16 +98,29 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
$suffix .= $lineEndings;
}
$phpcsFile->fixer->replaceToken(
$classnamePosition,
substr($classname, strrpos($classname, '_') + 1)
);
$phpcsFile->fixer->replaceToken(
$this->getNamespacePosition($phpcsFile),
'<?php' . $lineEndings . $this->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

View file

@ -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;

View file

@ -1,279 +0,0 @@
<?php
namespace Typo3Update\Sniffs\LegacyClassnames;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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\Sniffs\LegacyClassnames\Mapping;
/**
* Provide common uses for all sniffs, regarding class name checks.
*/
abstract class AbstractClassnameChecker implements PhpCsSniff
{
/**
* A list of extension names that might contain legacy class names.
* Used to check clas names for warnings.
*
* Configure through ruleset.xml.
*
* @var array<string>
*/
public $legacyExtensions = ['Extbase', 'Fluid'];
/**
* @var Mapping
*/
protected $legacyMapping;
/**
* 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()
{
$this->legacyMapping = Mapping::getInstance();
}
/**
* 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->addFixableError($phpcsFile, $classnamePosition, $classname);
}
/**
* Checks whether a mapping exists for the given $classname,
* indicating it's legacy.
*
* @param string $classname
* @return bool
*/
protected function isLegacyClassname($classname)
{
return $this->legacyMapping->isLegacyClassname($classname);
}
/**
* Guesses whether the given classname is legacy. Will not check
* isLegacyClassname
*
* @param string $classname
* @return bool
*/
private function isMaybeLegacyClassname($classname)
{
if (strpos($classname, 'Tx_') === false) {
return false;
}
$extensionName = call_user_func(function ($classname) {
$nameParts = explode('_', $classname);
return $nameParts[1];
}, $classname);
if (!in_array($extensionName, $this->legacyExtensions)) {
return false;
}
return true;
}
/**
* @param string $classname
* @return string
*/
protected function getNewClassname($classname)
{
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 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.
*
* @param PhpCsFile $phpcsFile
* @param int $classnamePosition
* @param string $classname
*/
private function addMaybeWarning(PhpCsFile $phpcsFile, $classnamePosition, $classname)
{
if ($this->isLegacyClassname($classname) || $this->isMaybeLegacyClassname($classname) === false) {
return;
}
$phpcsFile->addWarning(
'Legacy classes are not allowed; found %s that might be a legacy class that does not exist anymore',
$classnamePosition,
'mightBeLegacyClassname',
[$classname]
);
}
/**
* Replaces the classname at $classnamePosition with $classname in $phpcsFile.
*
* @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
) {
$prefix = '\\';
if ($forceEmptyPrefix || $phpcsFile->getTokens()[$classnamePosition -1]['code'] === T_NS_SEPARATOR) {
$prefix = '';
}
$phpcsFile->fixer->replaceToken(
$classnamePosition,
$this->getTokenForReplacement($prefix . $this->getNewClassname($classname), $classname, $phpcsFile)
);
}
/**
* 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.
*
* @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 = "'";
}
return implode($stringSign, $token);
}
}

View file

@ -0,0 +1,156 @@
<?php
namespace Typo3Update\Sniffs\Removed;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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;
abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
{
/**
* @return int[]
*/
public function register()
{
return [T_STRING];
}
/**
* @param array $typo3Versions
* @return array
*/
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;
}
/**
* @param PhpCsFile $phpcsFile
* @param int $stackPtr
* @return array
*/
protected function findRemoved(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'];
}
}
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
)
;
}
);
}
/**
* @param string $identifier
* @param array &$config
*/
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];
}
}
/**
* @param array $config
* @return string
*/
protected function getIdentifier(array $config)
{
$name = $config['name'];
if ($config['class']) {
$name = $config['class'] . '.' . $name;
}
return $name;
}
/**
* @param array $config
* @return string
*/
abstract protected function getOldUsage(array $config);
}

View file

@ -22,273 +22,25 @@ 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\Sniffs\Options;
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
{
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<string>
*/
abstract protected function getRemovedConfigFiles();
/**
* Prepares structure from config for later usage.
*
* @param array $typo3Versions
* @param PhpCsFile $phpcsFile
* @param int $stackPtr
* @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;
}
abstract protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr);
/**
* 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
* @param PhpCsFile $phpcsFile
* @param int $stackPtr
*/
public function process(PhpCsFile $phpcsFile, $stackPtr)
{
if (!$this->isRemoved($phpcsFile, $stackPtr)) {
return;
foreach ($this->findRemoved($phpcsFile, $stackPtr) as $removed) {
$this->addWarning($phpcsFile, $stackPtr, $removed);
}
$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'];
}
}

View file

@ -19,42 +19,11 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use Typo3Update\Sniffs\Removed\AbstractGenericUsage;
use Typo3Update\Sniffs\Options;
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<string>
*/
protected function getRemovedConfigFiles()
{
return Options::getRemovedConstantConfigFiles();
}
/**
* Returns the token types that this sniff is interested in.
*
* @return array<int>
*/
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();
}
}

View file

@ -20,60 +20,28 @@
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Tokens as Tokens;
use Typo3Update\Sniffs\Removed\AbstractGenericUsage;
use Typo3Update\Sniffs\Options;
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 AbstractGenericUsage
class Typo3Update_Sniffs_Removed_GenericFunctionCallSniff extends AbstractGenericPhpUsage
{
/**
* Return file names containing removed configurations.
*
* @return array<string>
*/
use ExtendedPhpCsSupportTrait;
protected function getRemovedConfigFiles()
{
return Options::getRemovedFunctionConfigFiles();
}
/**
* Returns the token types that this sniff is interested in.
*
* @return array<int>
*/
public function register()
{
return Tokens::$functionNameTokens;
}
/**
* Check whether function at given point is removed.
*
* @return bool
*/
protected function isRemoved(PhpCsFile $phpcsFile, $stackPtr)
protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr)
{
if (!$this->isFunctionCall($phpcsFile, $stackPtr)) {
return false;
return [];
}
return parent::isRemoved($phpcsFile, $stackPtr);
return parent::findRemoved($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 = '->';

View file

@ -0,0 +1,86 @@
<?php
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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<string>
*/
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();
}
}

View file

@ -0,0 +1,91 @@
<?php
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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_TypoScriptSniff extends AbstractGenericUsage
{
/**
* Register sniff only for TypoScript.
* @var array<string>
*/
public $supportedTokenizers = [
'TYPOSCRIPT',
];
public function register()
{
return [
TokenInterface::TYPE_OBJECT_CONSTRUCTOR,
TokenInterface::TYPE_OBJECT_IDENTIFIER,
];
}
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['identifier'] = str_replace('.', '-', $removed);
$config['versionRemoved'] = $typo3Version;
$config['oldUsage'] = $removed;
$newStructure[$removed] = $config;
}
}
return $newStructure;
}
protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];
$objectIdentifier = $token['content'];
if (!$this->configured->isRemoved($objectIdentifier)) {
return [];
}
$removed = $this->configured->getRemoved($objectIdentifier);
if ($token['type'] === $removed['type']) {
return [$removed];
}
return [];
}
protected function getRemovedConfigFiles()
{
return Options::getRemovedTypoScriptConfigFiles();
}
}

View file

@ -2,18 +2,14 @@
<ruleset name="TYPO3 Update">
<description>Provides sniffs and fixes for TYPO3 Updates.</description>
<rule ref="Typo3Update.LegacyClassnames.Instanceof">
<rule ref="Typo3Update.Classname.Instanceof">
<properties>
<property name="legacyExtensions" type="array" value="Extbase,Fluid,Frontend,Core"/>
</properties>
</rule>
<rule ref="Typo3Update.LegacyClassnames.DocComment">
<rule ref="Typo3Update.Classname.PhpDocComment">
<properties>
<property name="allowedTags" type="array" value="@param,@return,@var,@see,@throws"/>
</properties>
</rule>
<rule ref="Typo3Update.LegacyClassnames.MissingNamespace.legacyClassname">
<message>Legacy class definitions are not allowed; found "%s". Wrap your class inside a namespace.</message>
</rule>
</ruleset>

View file

@ -0,0 +1,28 @@
<?php
namespace Typo3Update\Tests\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* 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
{
}

View file

@ -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.

View file

@ -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"
}
],

View file

@ -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 @@
{

View file

@ -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"
}
],

View file

@ -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.

View file

@ -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"
}
],

View file

@ -1,10 +1,11 @@
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/InputFileForIssues.php
--- 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);

View file

@ -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"
}
],

View file

@ -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);

View file

@ -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.

View file

@ -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"
}
],

View file

@ -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 @@

View file

@ -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"
}
],

View file

@ -0,0 +1,22 @@
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/InputFileForIssues.php
+++ PHP_CodeSniffer
@@ -23,15 +23,15 @@
if (is_a($a, t3lib_Singleton::class)) {
// 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
}
-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
}

View file

@ -0,0 +1,51 @@
{
"files": {
"InputFileForIssues.php": {
"errors": 4,
"messages": [
{
"column": 14,
"fixable": true,
"line": 26,
"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": 29,
"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": 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": 4,
"fixable": 4,
"warnings": 0
}
}

View file

@ -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
}

View file

@ -1,6 +1,6 @@
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/InputFileForIssues.php
--- 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

View file

@ -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,34 +18,43 @@
"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"
},
{
"column": 15,
"fixable": false,
"line": 32,
"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.Classname.PhpDocComment.RemovedClass.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.LegacyClassnames.DocComment.legacyClassname",
"source": "Typo3Update.Classname.PhpDocComment.legacyClassname",
"type": "ERROR"
},
{
"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.LegacyClassnames.DocComment.legacyClassname",
"source": "Typo3Update.Classname.PhpDocComment.legacyClassname",
"type": "ERROR"
}
],
"warnings": 0
"warnings": 1
}
},
"totals": {
"errors": 4,
"fixable": 4,
"warnings": 0
"warnings": 1
}
}

View file

@ -29,6 +29,7 @@ class InputFileForIssues
/**
* @param t3lib_div
* @param \TYPO3\CMS\Backend\Template\MediumDocumentTemplate
*
* @return Tx_Extbase_Configuration_Configurationmanager
*/

View file

@ -1,4 +1,4 @@
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/StaticCallSniff/InputFileForIssues.php
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff/InputFileForIssues.php
+++ PHP_CodeSniffer
@@ -19,13 +19,13 @@
* 02110-1301, USA.

View file

@ -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"
}
],

View file

@ -1,4 +1,4 @@
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintCatchExceptionSniff/InputFileForIssues.php
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff/InputFileForIssues.php
+++ PHP_CodeSniffer
@@ -21,13 +21,13 @@

View file

@ -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"
}
],

View file

@ -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)

View file

@ -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"
}
],

View file

@ -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.

View file

@ -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"
}
],

Some files were not shown because too many files have changed in this diff Show more