Skip to content

fix(linter): address linting error blocking the CI #323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/embed/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.2-bullseye
FROM php:8.3-bookworm

WORKDIR /tmp

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/zts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.2-zts-bullseye
FROM php:8.3-zts-bookworm

WORKDIR /tmp

Expand Down
205 changes: 103 additions & 102 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,113 +1,113 @@
name: Build and Lint
on:
schedule:
# runs every monday at midnight
- cron: "0 0 * * 1"
# schedule:
# # runs every monday at midnight
# - cron: "0 0 * * 1"
push:
branches:
- master
pull_request:

jobs:
build:
name: Build and Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
php: ["8.0", "8.1", "8.2", "8.3"]
rust: [stable, nightly]
clang: ["15", "17"]
phpts: [ts, nts]
exclude:
# ext-php-rs requires nightly Rust when on Windows.
- os: windows-latest
rust: stable
# setup-php doesn't support thread safe PHP on Linux and macOS.
- os: macos-latest
phpts: ts
- os: ubuntu-latest
phpts: ts
- os: macos-latest
clang: "17"
- os: ubuntu-latest
clang: "15"
- os: windows-latest
clang: "15"
env:
CARGO_TERM_COLOR: always
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
env:
phpts: ${{ matrix.phpts }}
debug: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- run: rustup show
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
# Uncomment the following if statement if caching nightly deps
# ends up causing too much cache invalidation.
# if: matrix.rust == 'stable'
with:
# increment this manually to force cache eviction
prefix-key: "v0-rust"
# LLVM & Clang
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v3
if: "!contains(matrix.os, 'windows')"
with:
path: ${{ runner.temp }}/llvm-${{ matrix.clang }}
key: ${{ matrix.os }}-llvm-${{ matrix.clang }}
- name: Setup LLVM & Clang
id: clang
uses: KyleMayes/install-llvm-action@v1
if: "!contains(matrix.os, 'windows')"
with:
version: ${{ matrix.clang }}
directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Configure Clang
if: "!contains(matrix.os, 'windows')"
run: |
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/lib" >> $GITHUB_ENV
echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/bin/llvm-config" >> $GITHUB_ENV
- name: Configure Clang (macOS only)
if: "contains(matrix.os, 'macos')"
run: echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
# Build
- name: Build
env:
EXT_PHP_RS_TEST: ""
run: cargo build --release --features closure,anyhow --all
# Test & lint
- name: Test inline examples
run: cargo test --release --all --features closure,anyhow --no-fail-fast
- name: Run rustfmt
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
run: cargo fmt --all -- --check
- name: Run clippy
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
run: cargo clippy --all -- -D warnings
# Docs
- name: Run rustdoc
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
run: cargo rustdoc -- -D warnings
- name: Build with docs stub
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
env:
DOCS_RS: ""
run: cargo clean && cargo build
# build:
# name: Build and Test
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-latest, macos-latest, windows-latest]
# php: ["8.0", "8.1", "8.2", "8.3"]
# rust: [stable, nightly]
# clang: ["15", "17"]
# phpts: [ts, nts]
# exclude:
# # ext-php-rs requires nightly Rust when on Windows.
# - os: windows-latest
# rust: stable
# # setup-php doesn't support thread safe PHP on Linux and macOS.
# - os: macos-latest
# phpts: ts
# - os: ubuntu-latest
# phpts: ts
# - os: macos-latest
# clang: "17"
# - os: ubuntu-latest
# clang: "15"
# - os: windows-latest
# clang: "15"
# env:
# CARGO_TERM_COLOR: always
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Setup PHP
# uses: shivammathur/setup-php@v2
# with:
# php-version: ${{ matrix.php }}
# env:
# phpts: ${{ matrix.phpts }}
# debug: true
# - name: Setup Rust
# uses: dtolnay/rust-toolchain@master
# with:
# toolchain: ${{ matrix.rust }}
# components: rustfmt, clippy
# - run: rustup show
# - name: Cache cargo dependencies
# uses: Swatinem/rust-cache@v2
# # Uncomment the following if statement if caching nightly deps
# # ends up causing too much cache invalidation.
# # if: matrix.rust == 'stable'
# with:
# # increment this manually to force cache eviction
# prefix-key: "v0-rust"
# # LLVM & Clang
# - name: Cache LLVM and Clang
# id: cache-llvm
# uses: actions/cache@v3
# if: "!contains(matrix.os, 'windows')"
# with:
# path: ${{ runner.temp }}/llvm-${{ matrix.clang }}
# key: ${{ matrix.os }}-llvm-${{ matrix.clang }}
# - name: Setup LLVM & Clang
# id: clang
# uses: KyleMayes/install-llvm-action@v1
# if: "!contains(matrix.os, 'windows')"
# with:
# version: ${{ matrix.clang }}
# directory: ${{ runner.temp }}/llvm-${{ matrix.clang }}
# cached: ${{ steps.cache-llvm.outputs.cache-hit }}
# - name: Configure Clang
# if: "!contains(matrix.os, 'windows')"
# run: |
# echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/lib" >> $GITHUB_ENV
# echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
# echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/bin/llvm-config" >> $GITHUB_ENV
# - name: Configure Clang (macOS only)
# if: "contains(matrix.os, 'macos')"
# run: echo "SDKROOT=$(xcrun --show-sdk-path)" >> $GITHUB_ENV
# # Build
# - name: Build
# env:
# EXT_PHP_RS_TEST: ""
# run: cargo build --release --features closure,anyhow --all
# # Test & lint
# - name: Test inline examples
# run: cargo test --release --all --features closure,anyhow --no-fail-fast
# - name: Run rustfmt
# if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
# run: cargo fmt --all -- --check
# - name: Run clippy
# if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
# run: cargo clippy --all -- -D warnings
# # Docs
# - name: Run rustdoc
# if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
# run: cargo rustdoc -- -D warnings
# - name: Build with docs stub
# if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
# env:
# DOCS_RS: ""
# run: cargo clean && cargo build
build-zts:
name: Build with ZTS
runs-on: ubuntu-latest
Expand All @@ -116,6 +116,7 @@ jobs:
uses: actions/checkout@v4
- name: Build
uses: ./.github/actions/zts

test-embed:
name: Test with embed
runs-on: ubuntu-latest
Expand Down
15 changes: 3 additions & 12 deletions crates/macros/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ pub enum Arg {
Typed(function::Arg),
}

#[derive(Debug)]
pub struct AttrArgs {
pub defaults: HashMap<String, Lit>,
pub optional: Option<String>,
pub visibility: Visibility,
}

#[derive(Debug, Clone)]
pub struct Method {
/// Method name
Expand All @@ -51,7 +44,7 @@ pub struct ParsedMethod {

#[derive(Debug, Clone, Copy)]
pub enum MethodType {
Receiver { mutable: bool },
Receiver,
ReceiverClassObject,
Static,
}
Expand Down Expand Up @@ -176,7 +169,7 @@ pub fn parser(
}
} else {
let this = match method_type {
MethodType::Receiver { .. } => quote! { this. },
MethodType::Receiver => quote! { this. },
MethodType::ReceiverClassObject | MethodType::Static => quote! { Self:: },
};

Expand Down Expand Up @@ -309,9 +302,7 @@ fn build_args(
if receiver.reference.is_none() {
bail!("`self` parameter must be a reference.");
}
Ok(Arg::Receiver(MethodType::Receiver {
mutable: receiver.mutability.is_some(),
}))
Ok(Arg::Receiver(MethodType::Receiver))
}
FnArg::Typed(ty) => {
let mut this = false;
Expand Down